'Determine from the text (a namelist) what scope the text is referring
to. Returns the scope found or None.'

def _findScopeFromContext(self, styles, text):

    log.debug(('_findScopeFromContext:    %r' % (text,)))
    scope = None
    try:
        idx = text.index('prototype')
    except ValueError:
        pass
    else:
        if ((idx >= 2) and (text[(idx - 1)] == '.')):
            (namelist, p) = self._getIdentifiersFromPos(styles[:(idx - 1)], text[:(idx - 1)], 0)
            if namelist:
                scope = self._locateScopeForName(namelist, attrlist=('classes',))
                if (not scope):
                    self._locateScopeForName(namelist, attrlist=('functions',))
                    if isinstance(scope, JSFunction):
                        scope = self._convertFunctionToClass(scope)
                if scope:
                    log.debug('_findScopeFromContext:    found    %s    %r', scope.cixname, scope.name)
    return scope
