'Get the type of the variable
@param styles {list} The (scintilla) styles for the text
@param text {list} The tokens to examine
@param p {int} Offset into text/styles to start looking
@param assignmentChar {str} The assignment character used
@returns {tuple} {list} type names,
{int} new offset (p),
{bool} true if this is a new instance'

def _getVariableType(self, styles, text, p, assignmentChar='='):

    log.debug('_getVariableType:    text:    %r,    assign    char:    %s', text[p:], assignmentChar)
    typeNames = []
    if (p >= len(styles)):
        return (typeNames, p, False)
    if (assignmentChar and (styles[p] == self.JS_OPERATOR) and (text[p] == assignmentChar)):
        p += 1
    if ((p < len(styles)) and (styles[p] == self.JS_OPERATOR) and (text[p] in '+-')):
        p += 1
    isNew = False
    isAlias = False
    if (p < len(styles)):
        if (styles[p] == self.JS_WORD):
            keyword = text[p]
            if (keyword == 'new'):
                (typeNames, p) = self._getCitdlTypeInfo(styles, text, (p + 1))
                p -= 1
                for (i, t) in enumerate(typeNames):
                    if t.endswith('()'):
                        typeNames[i] = t[:(-2)]
                        break
                isNew = True
            elif (keyword in ('true', 'false')):
                typeNames = ['boolean']
            elif (keyword == 'this'):
                (typeNames, p) = self._getCitdlTypeInfo(styles, text, p)
                p -= 1
            p += 1
        elif (styles[p] in self.JS_STRINGS):
            typeNames = ['string']
            p += 1
        elif (styles[p] == self.JS_NUMBER):
            typeNames = ['int']
            p += 1
        elif (styles[p] == self.JS_IDENTIFIER):
            (typeNames, p) = self._getCitdlTypeInfo(styles, text, p)
            if (not isNew):
                isAlias = True
        elif (styles[p] == self.JS_OPERATOR):
            if (text[p] == '{'):
                typeNames = ['Object']
                p += 1
            elif (text[p] == '['):
                while ((p + 1) < len(styles)):
                    if ((text[p] == ']') and (styles[p] == self.JS_OPERATOR)):
                        break
                    p += 1
                typeNames = ['Array']
                p += 1
    return (typeNames, p, isAlias)
