Introduced Snapshot::findMatchingDefinition().

This commit is contained in:
Roberto Raggi
2010-05-11 12:47:20 +02:00
parent 7eae51507c
commit c282da7d1e
6 changed files with 143 additions and 89 deletions

View File

@@ -46,12 +46,12 @@
using namespace CPlusPlus;
static void fullyQualifiedName(Symbol *symbol, QList<const Name *> *names)
static void fullyQualifiedName_helper(Symbol *symbol, QList<const Name *> *names)
{
if (! symbol)
return;
fullyQualifiedName(symbol->enclosingSymbol(), names);
fullyQualifiedName_helper(symbol->enclosingSymbol(), names);
if (symbol->name() && (symbol->isClass() || symbol->isNamespace())) {
if (const QualifiedNameId *q = symbol->name()->asQualifiedNameId()) {
@@ -119,6 +119,13 @@ LookupContext &LookupContext::operator = (const LookupContext &other)
return *this;
}
QList<const Name *> LookupContext::fullyQualifiedName(Symbol *symbol)
{
QList<const Name *> names;
fullyQualifiedName_helper(symbol, &names);
return names;
}
QSharedPointer<CreateBindings> LookupContext::bindings() const
{
if (! _bindings)
@@ -230,8 +237,7 @@ QList<Symbol *> LookupContext::lookup(const Name *name, Scope *scope) const
if (fun->name() && fun->name()->isQualifiedNameId()) {
const QualifiedNameId *q = fun->name()->asQualifiedNameId();
QList<const Name *> path;
fullyQualifiedName(scope->owner(), &path);
QList<const Name *> path = fullyQualifiedName(scope->owner());
for (unsigned index = 0; index < q->nameCount() - 1; ++index) { // ### TODO remove me.
const Name *name = q->nameAt(index);
@@ -681,8 +687,7 @@ ClassOrNamespace *CreateBindings::globalNamespace() const
ClassOrNamespace *CreateBindings::findClassOrNamespace(Symbol *symbol)
{
QList<const Name *> names;
fullyQualifiedName(symbol, &names);
const QList<const Name *> names = LookupContext::fullyQualifiedName(symbol);
if (names.isEmpty())
return _globalNamespace;