From 05f2fd666902e7246b7110187d4964644291e26f Mon Sep 17 00:00:00 2001 From: Roberto Raggi <roberto.raggi@nokia.com> Date: Thu, 26 Aug 2010 16:16:22 +0200 Subject: [PATCH] Renamed Symbol::scope() to Symbol::enclosingScope(). --- src/libs/cplusplus/CppDocument.cpp | 2 +- .../cplusplus/DeprecatedGenTemplateInstance.cpp | 2 +- src/libs/cplusplus/FindUsages.cpp | 4 ++-- src/libs/cplusplus/Icons.cpp | 2 +- src/libs/cplusplus/LookupContext.cpp | 6 +++--- src/libs/cplusplus/LookupItem.cpp | 2 +- src/libs/cplusplus/OverviewModel.cpp | 6 +++--- src/libs/cplusplus/ResolveExpression.cpp | 12 ++++++------ src/plugins/cppeditor/cppchecksymbols.cpp | 10 +++++----- src/plugins/cppeditor/cppeditor.cpp | 6 +++--- src/plugins/cppeditor/cppelementevaluator.cpp | 12 ++++++------ src/plugins/cppeditor/cpplocalsymbols.cpp | 2 +- src/plugins/cpptools/abstracteditorsupport.cpp | 2 +- src/plugins/cpptools/cppcodecompletion.cpp | 6 +++--- src/plugins/cpptools/cppfindreferences.cpp | 4 ++-- src/shared/cplusplus/Scope.cpp | 2 +- src/shared/cplusplus/Symbol.cpp | 14 +++++++------- src/shared/cplusplus/Symbol.h | 4 ++-- tests/auto/cplusplus/lookup/tst_lookup.cpp | 14 +++++++------- tests/auto/cplusplus/semantic/tst_semantic.cpp | 4 ++-- tests/manual/plain-cplusplus/main.cpp | 14 +++++++------- 21 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 7fc43e3e53f..006cbfff474 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -748,7 +748,7 @@ Symbol *Snapshot::findMatchingDefinition(Symbol *declaration) const continue; // nothing to do foreach (Function *fun, result) { - const QList<LookupItem> declarations = context.lookup(fun->name(), fun->scope()); + const QList<LookupItem> declarations = context.lookup(fun->name(), fun->enclosingScope()); if (declarations.isEmpty()) continue; diff --git a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp index b82e16cf6e5..7edc44d7345 100644 --- a/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp +++ b/src/libs/cplusplus/DeprecatedGenTemplateInstance.cpp @@ -129,7 +129,7 @@ private: virtual void visit(Function *funTy) { Function *fun = control()->newFunction(/*sourceLocation=*/ 0, funTy->name()); - fun->setScope(funTy->scope()); + fun->setScope(funTy->enclosingScope()); fun->setConst(funTy->isConst()); fun->setVolatile(funTy->isVolatile()); fun->setVirtual(funTy->isVirtual()); diff --git a/src/libs/cplusplus/FindUsages.cpp b/src/libs/cplusplus/FindUsages.cpp index e78ae898872..d96d8046fa7 100644 --- a/src/libs/cplusplus/FindUsages.cpp +++ b/src/libs/cplusplus/FindUsages.cpp @@ -224,8 +224,8 @@ bool FindUsages::checkCandidates(const QList<LookupItem> &candidates) const return false; } - if (isLocalScope(_declSymbol->scope()) || isLocalScope(s->scope())) { - if (s->scope() != _declSymbol->scope()) + if (isLocalScope(_declSymbol->enclosingScope()) || isLocalScope(s->enclosingScope())) { + if (s->enclosingScope() != _declSymbol->enclosingScope()) return false; } diff --git a/src/libs/cplusplus/Icons.cpp b/src/libs/cplusplus/Icons.cpp index ade66db3024..f272737358b 100644 --- a/src/libs/cplusplus/Icons.cpp +++ b/src/libs/cplusplus/Icons.cpp @@ -104,7 +104,7 @@ Icons::IconType Icons::iconTypeForSymbol(const Symbol *symbol) } else if (symbol->isPrivate()) { return FuncPrivateIconType; } - } else if (symbol->scope() && symbol->scope()->isEnum()) { + } else if (symbol->enclosingScope() && symbol->enclosingScope()->isEnum()) { return EnumeratorIconType; } else if (symbol->isDeclaration() || symbol->isArgument()) { if (symbol->isPublic()) { diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index e788c529d75..68522a74a01 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -68,7 +68,7 @@ static void path_helper(Symbol *symbol, QList<const Name *> *names) if (! symbol) return; - path_helper(symbol->scope(), names); + path_helper(symbol->enclosingScope(), names); if (symbol->name()) { if (symbol->isClass() || symbol->isNamespace()) { @@ -142,7 +142,7 @@ LookupContext &LookupContext::operator = (const LookupContext &other) QList<const Name *> LookupContext::fullyQualifiedName(Symbol *symbol) { - QList<const Name *> qualifiedName = path(symbol->scope()); + QList<const Name *> qualifiedName = path(symbol->enclosingScope()); addNames(symbol->name(), &qualifiedName, /*add all names*/ true); return qualifiedName; } @@ -256,7 +256,7 @@ QList<LookupItem> LookupContext::lookup(const Name *name, Scope *scope) const if (! name) return candidates; - for (; scope; scope = scope->scope()) { + for (; scope; scope = scope->enclosingScope()) { if ((name->isNameId() || name->isTemplateNameId()) && scope->isBlock()) { bindings()->lookupInScope(name, scope, &candidates, /*templateId = */ 0, /*binding=*/ 0); diff --git a/src/libs/cplusplus/LookupItem.cpp b/src/libs/cplusplus/LookupItem.cpp index 1bc49303a31..d3e7ebef877 100644 --- a/src/libs/cplusplus/LookupItem.cpp +++ b/src/libs/cplusplus/LookupItem.cpp @@ -67,7 +67,7 @@ void LookupItem::setDeclaration(Symbol *declaration) Scope *LookupItem::scope() const { if (! _scope && _declaration) - return _declaration->scope(); + return _declaration->enclosingScope(); return _scope; } diff --git a/src/libs/cplusplus/OverviewModel.cpp b/src/libs/cplusplus/OverviewModel.cpp index a90c7f88ae5..e2b1e58e69c 100644 --- a/src/libs/cplusplus/OverviewModel.cpp +++ b/src/libs/cplusplus/OverviewModel.cpp @@ -90,10 +90,10 @@ QModelIndex OverviewModel::parent(const QModelIndex &child) const if (!symbol) // account for no symbol item return QModelIndex(); - if (Scope *scope = symbol->scope()) { - if (scope->scope()) { + if (Scope *scope = symbol->enclosingScope()) { + if (scope->enclosingScope()) { QModelIndex index; - if (scope->scope() && scope->scope()->scope()) // the parent doesn't have a parent + if (scope->enclosingScope() && scope->enclosingScope()->enclosingScope()) // the parent doesn't have a parent index = createIndex(scope->index(), 0, scope); else //+1 to account for no symbol item index = createIndex(scope->index() + 1, 0, scope); diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index c2525e6f3ff..3533b1f2397 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -115,7 +115,7 @@ void ResolveExpression::addResults(const QList<Symbol *> &symbols) foreach (Symbol *symbol, symbols) { LookupItem item; item.setType(symbol->type()); - item.setScope(symbol->scope()); + item.setScope(symbol->enclosingScope()); item.setDeclaration(symbol); _results.append(item); } @@ -313,18 +313,18 @@ bool ResolveExpression::visit(ThisExpressionAST *) void ResolveExpression::thisObject() { Scope *scope = _scope; - for (; scope; scope = scope->scope()) { + for (; scope; scope = scope->enclosingScope()) { if (Function *fun = scope->asFunction()) { if (Class *klass = scope->enclosingClass()) { FullySpecifiedType classTy(control()->namedType(klass->name())); FullySpecifiedType ptrTy(control()->pointerType(classTy)); - addResult(ptrTy, fun->scope()); + addResult(ptrTy, fun->enclosingScope()); break; } else if (const QualifiedNameId *q = fun->name()->asQualifiedNameId()) { if (q->base()) { FullySpecifiedType classTy(control()->namedType(q->base())); FullySpecifiedType ptrTy(control()->pointerType(classTy)); - addResult(ptrTy, fun->scope()); + addResult(ptrTy, fun->enclosingScope()); } break; } @@ -666,10 +666,10 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas FullySpecifiedType retTy = instantiatedFunction->returnType().simplified(); if (PointerType *ptrTy = retTy->asPointerType()) { - if (ClassOrNamespace *retBinding = findClass(ptrTy->elementType(), overload->scope())) + if (ClassOrNamespace *retBinding = findClass(ptrTy->elementType(), overload->enclosingScope())) return retBinding; - else if (scope != overload->scope()) { + else if (scope != overload->enclosingScope()) { if (ClassOrNamespace *retBinding = findClass(ptrTy->elementType(), scope)) return retBinding; } diff --git a/src/plugins/cppeditor/cppchecksymbols.cpp b/src/plugins/cppeditor/cppchecksymbols.cpp index add8b3fbe3a..20ad4e265e9 100644 --- a/src/plugins/cppeditor/cppchecksymbols.cpp +++ b/src/plugins/cppeditor/cppchecksymbols.cpp @@ -205,7 +205,7 @@ protected: if (symbol->isTypedef()) addType(symbol->name()); - else if (! symbol->type()->isFunctionType() && symbol->scope()->isClass()) + else if (! symbol->type()->isFunctionType() && symbol->enclosingScope()->isClass()) addMember(symbol->name()); return true; @@ -465,7 +465,7 @@ bool CheckSymbols::visit(SimpleDeclarationAST *ast) if (funTy->isVirtual()) { addUse(declId, Use::VirtualMethod); } else if (maybeVirtualMethod(decl->name())) { - addVirtualMethod(_context.lookup(decl->name(), decl->scope()), declId, funTy->argumentCount()); + addVirtualMethod(_context.lookup(decl->name(), decl->enclosingScope()), declId, funTy->argumentCount()); } } } @@ -768,7 +768,7 @@ bool CheckSymbols::visit(FunctionDefinitionAST *ast) if (fun->isVirtual()) { addUse(declId, Use::VirtualMethod); } else if (maybeVirtualMethod(fun->name())) { - addVirtualMethod(_context.lookup(fun->name(), fun->scope()), declId, fun->argumentCount()); + addVirtualMethod(_context.lookup(fun->name(), fun->enclosingScope()), declId, fun->argumentCount()); } } } @@ -932,7 +932,7 @@ void CheckSymbols::addClassMember(const QList<LookupItem> &candidates, NameAST * continue; else if (! c->isDeclaration()) return; - else if (! (c->scope() && c->scope()->isClass())) + else if (! (c->enclosingScope() && c->enclosingScope()->isClass())) return; // shadowed else if (c->isTypedef() || c->type()->isFunctionType()) return; // shadowed @@ -961,7 +961,7 @@ void CheckSymbols::addStatic(const QList<LookupItem> &candidates, NameAST *ast) Symbol *c = r.declaration(); if (! c) return; - if (c->scope()->isEnum()) { + if (c->enclosingScope()->isEnum()) { unsigned line, column; getTokenStartPosition(startToken, &line, &column); const unsigned length = tok.length(); diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 406b1d10c3c..c13b3da5f1b 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -346,10 +346,10 @@ struct CanonicalSymbol const LookupItem &r = results.at(i); Symbol *decl = r.declaration(); - if (! (decl && decl->scope())) + if (! (decl && decl->enclosingScope())) break; - if (Class *classScope = r.declaration()->scope()->asClass()) { + if (Class *classScope = r.declaration()->enclosingScope()->asClass()) { const Identifier *declId = decl->identifier(); const Identifier *classId = classScope->identifier(); @@ -1092,7 +1092,7 @@ void CPPEditor::switchDeclarationDefinition() LookupContext context(thisDocument, snapshot); Function *functionDefinition = functionScope->asFunction(); - const QList<LookupItem> declarations = context.lookup(functionDefinition->name(), functionDefinition->scope()); + const QList<LookupItem> declarations = context.lookup(functionDefinition->name(), functionDefinition->enclosingScope()); foreach (const LookupItem &r, declarations) { Symbol *decl = r.declaration(); // TODO: check decl. diff --git a/src/plugins/cppeditor/cppelementevaluator.cpp b/src/plugins/cppeditor/cppelementevaluator.cpp index 2902051d6ac..8086b89e0b5 100644 --- a/src/plugins/cppeditor/cppelementevaluator.cpp +++ b/src/plugins/cppeditor/cppelementevaluator.cpp @@ -183,7 +183,7 @@ void CppElementEvaluator::handleLookupItemMatch(const Snapshot &snapshot, if (m_lookupBaseClasses) cppClass->lookupBases(declaration, context); m_element = QSharedPointer<CppElement>(cppClass); - } else if (declaration->isEnum() || declaration->scope()->isEnum()) { + } else if (declaration->isEnum() || declaration->enclosingScope()->isEnum()) { m_element = QSharedPointer<CppElement>(new CppEnum(declaration)); } else if (declaration->isTypedef()) { m_element = QSharedPointer<CppElement>(new CppTypedef(declaration)); @@ -310,9 +310,9 @@ CppDeclarableElement::CppDeclarableElement(Symbol *declaration) : CppElement() m_icon = Icons().iconForSymbol(declaration); m_name = overview.prettyName(declaration->name()); - if (declaration->scope()->isClass() || - declaration->scope()->isNamespace() || - declaration->scope()->isEnum()) { + if (declaration->enclosingScope()->isClass() || + declaration->enclosingScope()->isNamespace() || + declaration->enclosingScope()->isEnum()) { m_qualifiedName = overview.prettyName(LookupContext::fullyQualifiedName(declaration)); } else { m_qualifiedName = m_name; @@ -440,8 +440,8 @@ CppEnum::CppEnum(Symbol *declaration) : CppDeclarableElement(declaration) { setHelpCategory(CppHoverHandler::HelpCandidate::Enum); - if (declaration->scope()->isEnum()) { - Symbol *enumSymbol = declaration->scope()->asEnum(); + if (declaration->enclosingScope()->isEnum()) { + Symbol *enumSymbol = declaration->enclosingScope()->asEnum(); Overview overview; setHelpMark(overview.prettyName(enumSymbol->name())); setTooltip(overview.prettyName(LookupContext::fullyQualifiedName(enumSymbol))); diff --git a/src/plugins/cppeditor/cpplocalsymbols.cpp b/src/plugins/cppeditor/cpplocalsymbols.cpp index 537c645f514..7c917ed5aa9 100644 --- a/src/plugins/cppeditor/cpplocalsymbols.cpp +++ b/src/plugins/cppeditor/cpplocalsymbols.cpp @@ -111,7 +111,7 @@ protected: if (Symbol *member = _scopeStack.at(i)->find(id)) { if (member->isTypedef()) continue; - else if (!member->isGenerated() && (member->sourceLocation() < ast->firstToken() || member->scope()->isFunction())) { + else if (!member->isGenerated() && (member->sourceLocation() < ast->firstToken() || member->enclosingScope()->isFunction())) { unsigned line, column; getTokenStartPosition(simpleName->identifier_token, &line, &column); localUses[member].append(SemanticInfo::Use(line, column, id->size(), SemanticInfo::Use::Local)); diff --git a/src/plugins/cpptools/abstracteditorsupport.cpp b/src/plugins/cpptools/abstracteditorsupport.cpp index 938e23c0ede..e29f45f2fb2 100644 --- a/src/plugins/cpptools/abstracteditorsupport.cpp +++ b/src/plugins/cpptools/abstracteditorsupport.cpp @@ -67,7 +67,7 @@ QString AbstractEditorSupport::functionAt(const CppModelManagerInterface *modelM if (!document) return QString(); if (const CPlusPlus::Symbol *symbol = document->lastVisibleSymbolAt(line, column)) - if (const CPlusPlus::Scope *scope = symbol->scope()) + if (const CPlusPlus::Scope *scope = symbol->enclosingScope()) if (const CPlusPlus::Scope *functionScope = scope->enclosingFunction()) if (const CPlusPlus::Symbol *function = functionScope) { const CPlusPlus::Overview o; diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 87f7b5bfaf3..4e6f013d797 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -1055,7 +1055,7 @@ void CppCodeCompletion::globalCompletion(Scope *currentScope) QList<ClassOrNamespace *> usingBindings; ClassOrNamespace *currentBinding = 0; - for (Scope *scope = currentScope; scope; scope = scope->scope()) { + for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) { if (scope->isBlock()) { if (ClassOrNamespace *binding = context.lookupType(scope)) { for (unsigned i = 0; i < scope->memberCount(); ++i) { @@ -1074,7 +1074,7 @@ void CppCodeCompletion::globalCompletion(Scope *currentScope) } } - for (Scope *scope = currentScope; scope; scope = scope->scope()) { + for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) { if (scope->isBlock()) { for (unsigned i = 0; i < scope->memberCount(); ++i) { addCompletionItem(scope->memberAt(i)); @@ -1153,7 +1153,7 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<LookupItem> &r if (! fun->name()) continue; - else if (! functions.isEmpty() && functions.first()->scope() != fun->scope()) + else if (! functions.isEmpty() && functions.first()->enclosingScope() != fun->enclosingScope()) continue; // skip fun, it's an hidden declaration. bool newOverload = true; diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp index 4d33e04f727..514dd287228 100644 --- a/src/plugins/cpptools/cppfindreferences.cpp +++ b/src/plugins/cpptools/cppfindreferences.cpp @@ -190,8 +190,8 @@ static void find_helper(QFutureInterface<Usage> &future, const QString sourceFile = QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()); QStringList files(sourceFile); - if (symbol->isClass() || symbol->isForwardClassDeclaration() || (symbol->scope() && ! symbol->isStatic() && - symbol->scope()->isNamespace())) { + if (symbol->isClass() || symbol->isForwardClassDeclaration() || (symbol->enclosingScope() && ! symbol->isStatic() && + symbol->enclosingScope()->isNamespace())) { foreach (const Document::Ptr &doc, context.snapshot()) { if (doc->fileName() == sourceFile) continue; diff --git a/src/shared/cplusplus/Scope.cpp b/src/shared/cplusplus/Scope.cpp index e5bfee9e1c2..72d2b774aa4 100644 --- a/src/shared/cplusplus/Scope.cpp +++ b/src/shared/cplusplus/Scope.cpp @@ -143,7 +143,7 @@ void SymbolTable::enterSymbol(Symbol *symbol) _symbols = reinterpret_cast<Symbol **>(realloc(_symbols, sizeof(Symbol *) * _allocatedSymbols)); } - assert(! symbol->_scope || symbol->scope() == _owner); + assert(! symbol->_scope || symbol->enclosingScope() == _owner); symbol->_index = _symbolCount; symbol->_scope = _owner; _symbols[_symbolCount] = symbol; diff --git a/src/shared/cplusplus/Symbol.cpp b/src/shared/cplusplus/Symbol.cpp index 40d51c65cad..4bc78da935c 100644 --- a/src/shared/cplusplus/Symbol.cpp +++ b/src/shared/cplusplus/Symbol.cpp @@ -233,7 +233,7 @@ const Identifier *Symbol::identifier() const return 0; } -Scope *Symbol::scope() const +Scope *Symbol::enclosingScope() const { return _scope; } void Symbol::setScope(Scope *scope) @@ -244,7 +244,7 @@ void Symbol::setScope(Scope *scope) Namespace *Symbol::enclosingNamespace() const { - for (Scope *s = _scope; s; s = s->scope()) { + for (Scope *s = _scope; s; s = s->enclosingScope()) { if (Namespace *ns = s->asNamespace()) return ns; } @@ -253,7 +253,7 @@ Namespace *Symbol::enclosingNamespace() const Template *Symbol::enclosingTemplate() const { - for (Scope *s = _scope; s; s = s->scope()) { + for (Scope *s = _scope; s; s = s->enclosingScope()) { if (Template *templ = s->asTemplate()) return templ; } @@ -262,7 +262,7 @@ Template *Symbol::enclosingTemplate() const Class *Symbol::enclosingClass() const { - for (Scope *s = _scope; s; s = s->scope()) { + for (Scope *s = _scope; s; s = s->enclosingScope()) { if (Class *klass = s->asClass()) return klass; } @@ -271,7 +271,7 @@ Class *Symbol::enclosingClass() const Enum *Symbol::enclosingEnum() const { - for (Scope *s = _scope; s; s = s->scope()) { + for (Scope *s = _scope; s; s = s->enclosingScope()) { if (Enum *e = s->asEnum()) return e; } @@ -280,7 +280,7 @@ Enum *Symbol::enclosingEnum() const Function *Symbol::enclosingFunction() const { - for (Scope *s = _scope; s; s = s->scope()) { + for (Scope *s = _scope; s; s = s->enclosingScope()) { if (Function *fun = s->asFunction()) return fun; } @@ -289,7 +289,7 @@ Function *Symbol::enclosingFunction() const Block *Symbol::enclosingBlock() const { - for (Scope *s = _scope; s; s = s->scope()) { + for (Scope *s = _scope; s; s = s->enclosingScope()) { if (Block *block = s->asBlock()) return block; } diff --git a/src/shared/cplusplus/Symbol.h b/src/shared/cplusplus/Symbol.h index 3781305fd9d..96d8707cdb9 100644 --- a/src/shared/cplusplus/Symbol.h +++ b/src/shared/cplusplus/Symbol.h @@ -287,7 +287,7 @@ public: void setUnavailable(bool isUnavailable); /// Returns this Symbol's eclosing scope. - Scope *scope() const; + Scope *enclosingScope() const; /// Returns the eclosing namespace scope. Namespace *enclosingNamespace() const; @@ -307,7 +307,7 @@ public: /// Returns the enclosing Block scope. Block *enclosingBlock() const; - void setScope(Scope *scope); // ### make me private + void setScope(Scope *enclosingScope); // ### make me private void setSourceLocation(unsigned sourceLocation, TranslationUnit *translationUnit); // ### make me private void visitSymbol(SymbolVisitor *visitor); diff --git a/tests/auto/cplusplus/lookup/tst_lookup.cpp b/tests/auto/cplusplus/lookup/tst_lookup.cpp index a05c610199d..0d4578b232c 100644 --- a/tests/auto/cplusplus/lookup/tst_lookup.cpp +++ b/tests/auto/cplusplus/lookup/tst_lookup.cpp @@ -100,7 +100,7 @@ void tst_Lookup::base_class_defined_1() const LookupContext ctx(doc, snapshot); - ClassOrNamespace *klass = ctx.lookupType(derivedClass->baseClassAt(0)->name(), derivedClass->scope()); + ClassOrNamespace *klass = ctx.lookupType(derivedClass->baseClassAt(0)->name(), derivedClass->enclosingScope()); QVERIFY(klass != 0); QCOMPARE(klass->symbols().size(), 1); @@ -169,7 +169,7 @@ void tst_Lookup::simple_class_1() const LookupContext context(doc, snapshot); // check class resolving: - ClassOrNamespace *klass = context.lookupType(impl->name(), impl->scope()); + ClassOrNamespace *klass = context.lookupType(impl->name(), impl->enclosingScope()); QVERIFY(klass != 0); QCOMPARE(klass->symbols().size(), 2); QVERIFY(klass->symbols().contains(iface)); @@ -233,7 +233,7 @@ void tst_Lookup::class_with_baseclass() const LookupContext context(doc, snapshot); - ClassOrNamespace *objClass = context.lookupType(baseZoo->name(), zooImpl->scope()); + ClassOrNamespace *objClass = context.lookupType(baseZoo->name(), zooImpl->enclosingScope()); QVERIFY(objClass != 0); QVERIFY(objClass->symbols().contains(baseZoo)); @@ -286,13 +286,13 @@ void tst_Lookup::class_with_protocol_with_protocol() const LookupContext context(doc, snapshot); { - const QList<LookupItem> candidates = context.lookup(P1->name(), zooImpl->scope()); + const QList<LookupItem> candidates = context.lookup(P1->name(), zooImpl->enclosingScope()); QCOMPARE(candidates.size(), 1); QVERIFY(candidates.at(0).declaration() == P1); } { - const QList<LookupItem> candidates = context.lookup(P2->protocolAt(0)->name(), zooImpl->scope()); + const QList<LookupItem> candidates = context.lookup(P2->protocolAt(0)->name(), zooImpl->enclosingScope()); QCOMPARE(candidates.size(), 1); QVERIFY(candidates.first().declaration() == P1); } @@ -354,7 +354,7 @@ void tst_Lookup::iface_impl_scoping() QCOMPARE(arg->name()->identifier()->chars(), "arg"); QVERIFY(arg->type()->isIntegerType()); - const QList<LookupItem> candidates = context.lookup(arg->name(), method1Body->scope()); + const QList<LookupItem> candidates = context.lookup(arg->name(), method1Body->enclosingScope()); QCOMPARE(candidates.size(), 1); QVERIFY(candidates.at(0).declaration()->type()->asIntegerType()); } @@ -364,7 +364,7 @@ void tst_Lookup::iface_impl_scoping() QCOMPARE(method2->identifier()->chars(), "method2"); { // verify if we can resolve "method2" in the body - const QList<LookupItem> candidates = context.lookup(method2->name(), method1Body->scope()); + const QList<LookupItem> candidates = context.lookup(method2->name(), method1Body->enclosingScope()); QCOMPARE(candidates.size(), 1); QCOMPARE(candidates.at(0).declaration(), method2); } diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp index b11f8ca6341..5fb11f8ea75 100644 --- a/tests/auto/cplusplus/semantic/tst_semantic.cpp +++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp @@ -414,10 +414,10 @@ void tst_Semantic::pointer_to_function_1() QVERIFY(funTy); QEXPECT_FAIL("", "Requires initialize enclosing scope of pointer-to-function symbols", Continue); - QVERIFY(funTy->scope()); + QVERIFY(funTy->enclosingScope()); QEXPECT_FAIL("", "Requires initialize enclosing scope of pointer-to-function symbols", Continue); - QCOMPARE(funTy->scope(), decl->scope()); + QCOMPARE(funTy->enclosingScope(), decl->enclosingScope()); } void tst_Semantic::template_instance_1() diff --git a/tests/manual/plain-cplusplus/main.cpp b/tests/manual/plain-cplusplus/main.cpp index 675ae41ce2c..acf7a3bfda7 100644 --- a/tests/manual/plain-cplusplus/main.cpp +++ b/tests/manual/plain-cplusplus/main.cpp @@ -50,14 +50,14 @@ struct V: public ASTVisitor virtual bool visit(FunctionDeclaratorAST *ast) { if (ast->as_cpp_initializer) { - if (! (ast->symbol && ast->symbol->scope())) - ; //translationUnit()->warning(ast->firstToken(), "resolved as function declaration"); - else if (ast->symbol->scope()->isNamespace() || ast->symbol->scope()->isTemplate()) - ; //translationUnit()->warning(ast->firstToken(), "resolved as function declaration"); - else if (ast->symbol->scope()->isBlock()) - ; //translationUnit()->warning(ast->firstToken(), "resolved as C++ initializer"); + if (! (ast->symbol && ast->symbol->enclosingScope())) + ; //translationUnit()->warning(ast->firstToken(), "resolved as function declaration"); + else if (ast->symbol->enclosingScope()->isNamespace() || ast->symbol->enclosingScope()->isTemplate()) + ; //translationUnit()->warning(ast->firstToken(), "resolved as function declaration"); + else if (ast->symbol->enclosingScope()->isBlock()) + ; //translationUnit()->warning(ast->firstToken(), "resolved as C++ initializer"); else - translationUnit()->warning(ast->firstToken(), "ambiguous function declarator or C++ intializer"); + translationUnit()->warning(ast->firstToken(), "ambiguous function declarator or C++ intializer"); } return true; } -- GitLab