diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index 6c10f88c5716118e2928e2dd9328aaf80bfb16ef..f79ebfd701e3be743172f51996389406ac31efec 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -126,63 +126,71 @@ bool LookupContext::maybeValidSymbol(Symbol *symbol, return false; } -QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visibleScopes, - ResolveMode mode) const +QList<Symbol *> LookupContext::resolveQualifiedNameId(QualifiedNameId *q, + const QList<Scope *> &visibleScopes, + ResolveMode mode) const { + QList<Scope *> scopes = visibleScopes; QList<Symbol *> candidates; - if (!name) - return candidates; - - if (QualifiedNameId *q = name->asQualifiedNameId()) { - QList<Scope *> scopes = visibleScopes; - for (unsigned i = 0; i < q->nameCount(); ++i) { - Name *name = q->nameAt(i); + for (unsigned i = 0; i < q->nameCount(); ++i) { + Name *name = q->nameAt(i); - if (i + 1 == q->nameCount()) - candidates = resolve(name, scopes, mode); - else - candidates = resolveClassOrNamespace(name, scopes); + if (i + 1 == q->nameCount()) + candidates = resolve(name, scopes, mode); + else + candidates = resolveClassOrNamespace(name, scopes); - if (candidates.isEmpty() || i + 1 == q->nameCount()) - break; + if (candidates.isEmpty() || i + 1 == q->nameCount()) + break; - scopes.clear(); - foreach (Symbol *candidate, candidates) { - if (ScopedSymbol *scoped = candidate->asScopedSymbol()) { - scopes.append(scoped->members()); - } + scopes.clear(); + foreach (Symbol *candidate, candidates) { + if (ScopedSymbol *scoped = candidate->asScopedSymbol()) { + scopes.append(scoped->members()); } } + } - Identifier *id = identifier(name); - foreach (Scope *scope, visibleScopes) { - Symbol *symbol = scope->lookat(id); - for (; symbol; symbol = symbol->next()) { - if (! symbol->name()) - continue; - else if (! maybeValidSymbol(symbol, mode, candidates)) - continue; - QualifiedNameId *qq = symbol->name()->asQualifiedNameId(); - if (! qq) - continue; - if (q->nameCount() > qq->nameCount()) - continue; + Identifier *id = q->identifier(); + foreach (Scope *scope, visibleScopes) { + Symbol *symbol = scope->lookat(id); + for (; symbol; symbol = symbol->next()) { + if (! symbol->name()) + continue; + else if (! maybeValidSymbol(symbol, mode, candidates)) + continue; + QualifiedNameId *qq = symbol->name()->asQualifiedNameId(); + if (! qq) + continue; + if (q->nameCount() > qq->nameCount()) + continue; - for (int i = q->nameCount() - 1; i != -1; --i) { - Name *a = q->nameAt(i); - Name *b = qq->nameAt(i); + for (int i = q->nameCount() - 1; i != -1; --i) { + Name *a = q->nameAt(i); + Name *b = qq->nameAt(i); - if (! a->isEqualTo(b)) - break; - else if (i == 0) - candidates.append(symbol); - } + if (! a->isEqualTo(b)) + break; + else if (i == 0) + candidates.append(symbol); } } + } + return candidates; +} + +QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visibleScopes, + ResolveMode mode) const +{ + QList<Symbol *> candidates; + + if (!name) return candidates; - } + + if (QualifiedNameId *q = name->asQualifiedNameId()) + return resolveQualifiedNameId(q, visibleScopes, mode); if (Identifier *id = identifier(name)) { for (int scopeIndex = 0; scopeIndex < visibleScopes.size(); ++scopeIndex) { diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h index 9ba268fe1af2537662e1731e5a81a0223cfd1199..d9be051a77fc2381c4b486c5bda8e8efb98e6bf3 100644 --- a/src/libs/cplusplus/LookupContext.h +++ b/src/libs/cplusplus/LookupContext.h @@ -115,6 +115,10 @@ public: QList<Scope *> *expandedScopes) const; private: + QList<Symbol *> resolveQualifiedNameId(QualifiedNameId *q, + const QList<Scope *> &visibleScopes, + ResolveMode mode) const; + Identifier *identifier(const Name *name) const; QList<Scope *> buildVisibleScopes();