Commit a6006148 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Renamed classOrNamespace() and lookup/findClassOrNamespace().

parent fca0d359
......@@ -162,15 +162,15 @@ ClassOrNamespace *LookupContext::globalNamespace() const
return bindings()->globalNamespace();
}
ClassOrNamespace *LookupContext::classOrNamespace(const Name *name, Scope *scope) const
ClassOrNamespace *LookupContext::lookupType(const Name *name, Scope *scope) const
{
if (ClassOrNamespace *b = bindings()->findClassOrNamespace(scope->owner()))
return b->lookupClassOrNamespace(name);
return b->lookupType(name);
return 0;
}
ClassOrNamespace *LookupContext::classOrNamespace(Symbol *symbol) const
ClassOrNamespace *LookupContext::lookupType(Symbol *symbol) const
{
return bindings()->findClassOrNamespace(symbol);
}
......@@ -197,7 +197,7 @@ QList<Symbol *> LookupContext::lookup(const Name *name, Scope *scope) const
if (UsingNamespaceDirective *u = member->asUsingNamespaceDirective()) {
if (Namespace *enclosingNamespace = u->enclosingNamespaceScope()->owner()->asNamespace()) {
if (ClassOrNamespace *b = bindings()->findClassOrNamespace(enclosingNamespace)) {
if (ClassOrNamespace *uu = b->lookupClassOrNamespace(u->name())) {
if (ClassOrNamespace *uu = b->lookupType(u->name())) {
candidates = uu->lookup(name);
if (! candidates.isEmpty())
......@@ -322,10 +322,10 @@ QList<Symbol *> ClassOrNamespace::lookup_helper(const Name *name, bool searchInE
if (q->nameCount() == 1)
return binding->find(q->unqualifiedNameId());
binding = binding->lookupClassOrNamespace(q->nameAt(0));
binding = binding->lookupType(q->nameAt(0));
for (unsigned index = 1; binding && index < q->nameCount() - 1; ++index)
binding = binding->findClassOrNamespace(q->nameAt(index));
binding = binding->findType(q->nameAt(index));
if (binding)
result = binding->find(q->unqualifiedNameId());
......@@ -437,7 +437,7 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
}
}
ClassOrNamespace *ClassOrNamespace::lookupClassOrNamespace(const Name *name)
ClassOrNamespace *ClassOrNamespace::lookupType(const Name *name)
{
if (! name)
return 0;
......@@ -446,13 +446,13 @@ ClassOrNamespace *ClassOrNamespace::lookupClassOrNamespace(const Name *name)
return lookupClassOrNamespace_helper(name, &processed);
}
ClassOrNamespace *ClassOrNamespace::findClassOrNamespace(const Name *name)
ClassOrNamespace *ClassOrNamespace::findType(const Name *name)
{
QSet<ClassOrNamespace *> processed;
return findClassOrNamespace_helper(name, &processed);
}
ClassOrNamespace *ClassOrNamespace::findClassOrNamespace(const QList<const Name *> &path)
ClassOrNamespace *ClassOrNamespace::findType(const QList<const Name *> &path)
{
if (path.isEmpty())
return globalNamespace();
......@@ -481,7 +481,7 @@ ClassOrNamespace *ClassOrNamespace::lookupClassOrNamespace_helper(const Name *na
if (q->isGlobal())
e = globalNamespace();
e = e->lookupClassOrNamespace(q->nameAt(0));
e = e->lookupType(q->nameAt(0));
for (unsigned index = 1; e && index < q->nameCount(); ++index) {
QSet<ClassOrNamespace *> processed;
......@@ -674,17 +674,17 @@ ClassOrNamespace *CreateBindings::findClassOrNamespace(Symbol *symbol)
if (names.isEmpty())
return _globalNamespace;
ClassOrNamespace *b = _globalNamespace->lookupClassOrNamespace(names.at(0));
ClassOrNamespace *b = _globalNamespace->lookupType(names.at(0));
for (int i = 1; b && i < names.size(); ++i)
b = b->findClassOrNamespace(names.at(i));
b = b->findType(names.at(i));
return b;
}
ClassOrNamespace *CreateBindings::findClassOrNamespace(const QList<const Name *> &path)
{
ClassOrNamespace *e = _globalNamespace->findClassOrNamespace(path);
ClassOrNamespace *e = _globalNamespace->findType(path);
return e;
}
......@@ -768,7 +768,7 @@ bool CreateBindings::visit(Class *klass)
ClassOrNamespace *binding = 0;
if (klass->name() && klass->name()->isQualifiedNameId())
binding = _currentClassOrNamespace->lookupClassOrNamespace(klass->name());
binding = _currentClassOrNamespace->lookupType(klass->name());
if (! binding)
binding = _currentClassOrNamespace->findOrCreate(klass->name());
......@@ -810,7 +810,7 @@ bool CreateBindings::visit(Declaration *decl)
if (typedefId && ! (ty.isConst() || ty.isVolatile())) {
if (const NamedType *namedTy = ty->asNamedType()) {
if (ClassOrNamespace *e = _currentClassOrNamespace->lookupClassOrNamespace(namedTy->name())) {
if (ClassOrNamespace *e = _currentClassOrNamespace->lookupType(namedTy->name())) {
_currentClassOrNamespace->addNestedClassOrNamespace(decl->name(), e);
} else if (false) {
Overview oo;
......@@ -830,7 +830,7 @@ bool CreateBindings::visit(Function *)
bool CreateBindings::visit(BaseClass *b)
{
if (ClassOrNamespace *base = _currentClassOrNamespace->lookupClassOrNamespace(b->name())) {
if (ClassOrNamespace *base = _currentClassOrNamespace->lookupType(b->name())) {
_currentClassOrNamespace->addUsing(base);
} else if (false) {
Overview oo;
......@@ -841,7 +841,7 @@ bool CreateBindings::visit(BaseClass *b)
bool CreateBindings::visit(UsingNamespaceDirective *u)
{
if (ClassOrNamespace *e = _currentClassOrNamespace->lookupClassOrNamespace(u->name())) {
if (ClassOrNamespace *e = _currentClassOrNamespace->lookupType(u->name())) {
_currentClassOrNamespace->addUsing(e);
} else if (false) {
Overview oo;
......@@ -855,7 +855,7 @@ bool CreateBindings::visit(NamespaceAlias *a)
if (! a->identifier()) {
return false;
} else if (ClassOrNamespace *e = _currentClassOrNamespace->lookupClassOrNamespace(a->namespaceName())) {
} else if (ClassOrNamespace *e = _currentClassOrNamespace->lookupType(a->namespaceName())) {
if (a->name()->isNameId() || a->name()->isTemplateNameId())
_currentClassOrNamespace->addNestedClassOrNamespace(a->name(), e);
......@@ -885,7 +885,7 @@ bool CreateBindings::visit(ObjCClass *klass)
bool CreateBindings::visit(ObjCBaseClass *b)
{
if (ClassOrNamespace *base = _globalNamespace->lookupClassOrNamespace(b->name())) {
if (ClassOrNamespace *base = _globalNamespace->lookupType(b->name())) {
_currentClassOrNamespace->addUsing(base);
} else if (false) {
Overview oo;
......@@ -917,7 +917,7 @@ bool CreateBindings::visit(ObjCProtocol *proto)
bool CreateBindings::visit(ObjCBaseProtocol *b)
{
if (ClassOrNamespace *base = _globalNamespace->lookupClassOrNamespace(b->name())) {
if (ClassOrNamespace *base = _globalNamespace->lookupType(b->name())) {
_currentClassOrNamespace->addUsing(base);
} else if (false) {
Overview oo;
......
......@@ -59,9 +59,9 @@ public:
QList<Symbol *> lookup(const Name *name);
QList<Symbol *> find(const Name *name);
ClassOrNamespace *lookupClassOrNamespace(const Name *name);
ClassOrNamespace *findClassOrNamespace(const Name *name);
ClassOrNamespace *findClassOrNamespace(const QList<const Name *> &path);
ClassOrNamespace *lookupType(const Name *name);
ClassOrNamespace *findType(const Name *name);
ClassOrNamespace *findType(const QList<const Name *> &path);
private:
/// \internal
......@@ -215,12 +215,11 @@ public:
Document::Ptr document(const QString &fileName) const;
Snapshot snapshot() const;
QList<Symbol *> lookup(const Name *name, Scope *scope) const;
ClassOrNamespace *globalNamespace() const;
ClassOrNamespace *classOrNamespace(const Name *name, Scope *scope) const;
ClassOrNamespace *classOrNamespace(Symbol *symbol) const;
QList<Symbol *> lookup(const Name *name, Scope *scope) const;
ClassOrNamespace *lookupType(const Name *name, Scope *scope) const;
ClassOrNamespace *lookupType(Symbol *symbol) const;
/// \internal
QSharedPointer<CreateBindings> bindings() const;
......
......@@ -487,7 +487,7 @@ bool ResolveExpression::visit(CallAST *ast)
Scope *scope = result.scope();
if (NamedType *namedTy = ty->asNamedType()) {
if (ClassOrNamespace *b = _context.classOrNamespace(namedTy->name(), scope)) {
if (ClassOrNamespace *b = _context.lookupType(namedTy->name(), scope)) {
foreach (Symbol *overload, b->find(functionCallOp)) {
if (Function *funTy = overload->type()->asFunctionType()) {
if (maybeValidPrototype(funTy, actualArgumentCount)) {
......@@ -532,7 +532,7 @@ bool ResolveExpression::visit(ArrayAccessAST *ast)
addResult(arrTy->elementType().simplified(), scope);
} else if (NamedType *namedTy = ty->asNamedType()) {
if (ClassOrNamespace *b = _context.classOrNamespace(namedTy->name(), scope)) {
if (ClassOrNamespace *b = _context.lookupType(namedTy->name(), scope)) {
foreach (Symbol *overload, b->find(arrayAccessOp)) {
if (Function *funTy = overload->type()->asFunctionType()) {
Function *proto = instantiate(namedTy->name(), funTy)->asFunctionType();
......@@ -574,10 +574,10 @@ ClassOrNamespace *ResolveExpression::findClass(const FullySpecifiedType &origina
ClassOrNamespace *binding = 0;
if (Class *klass = ty->asClassType())
binding = _context.classOrNamespace(klass);
binding = _context.lookupType(klass);
else if (NamedType *namedTy = ty->asNamedType())
binding = _context.classOrNamespace(namedTy->name(), scope);
binding = _context.lookupType(namedTy->name(), scope);
else if (Function *funTy = ty->asFunctionType())
return findClass(funTy->returnType(), scope);
......
......@@ -947,7 +947,7 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<LookupItem> &r
Scope *scope = result.scope();
if (NamedType *namedTy = ty->asNamedType()) {
if (ClassOrNamespace *b = context.classOrNamespace(namedTy->name(), scope)) {
if (ClassOrNamespace *b = context.lookupType(namedTy->name(), scope)) {
foreach (Symbol *overload, b->lookup(functionCallOp)) {
FullySpecifiedType overloadTy = overload->type().simplified();
......@@ -1114,19 +1114,19 @@ bool CppCodeCompletion::completeScope(const QList<LookupItem> &results,
Scope *scope = result.scope();
if (NamedType *namedTy = ty->asNamedType()) {
if (ClassOrNamespace *b = context.classOrNamespace(namedTy->name(), scope)) {
if (ClassOrNamespace *b = context.lookupType(namedTy->name(), scope)) {
completeClass(b, context);
break;
}
} else if (Class *classTy = ty->asClassType()) {
if (ClassOrNamespace *b = context.classOrNamespace(classTy)) {
if (ClassOrNamespace *b = context.lookupType(classTy)) {
completeClass(b, context);
break;
}
} else if (Namespace *nsTy = ty->asNamespaceType()) {
if (ClassOrNamespace *b = context.classOrNamespace(nsTy)) {
if (ClassOrNamespace *b = context.lookupType(nsTy)) {
completeNamespace(b, context);
break;
}
......@@ -1379,7 +1379,7 @@ bool CppCodeCompletion::completeQtMethod(const QList<LookupItem> &results,
if (! namedTy) // not a class name.
continue;
ClassOrNamespace *b = newContext.classOrNamespace(namedTy->name(), p.scope());
ClassOrNamespace *b = newContext.lookupType(namedTy->name(), p.scope());
if (! b)
continue;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment