aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp2
-rw-r--r--src/plugins/cppeditor/cppelementevaluator.cpp12
-rw-r--r--src/plugins/cppeditor/cppfollowsymbolundercursor.cpp3
-rw-r--r--src/plugins/cppeditor/cppfunctiondecldeflink.cpp4
-rw-r--r--src/plugins/cppeditor/cppinsertvirtualmethods.cpp16
-rw-r--r--src/plugins/cppeditor/cppquickfixes.cpp24
-rw-r--r--src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp4
-rw-r--r--src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp16
-rw-r--r--src/plugins/cpptools/cppchecksymbols.cpp30
-rw-r--r--src/plugins/cpptools/cppchecksymbols.h6
-rw-r--r--src/plugins/cpptools/cppcompletion_test.cpp520
-rw-r--r--src/plugins/cpptools/cppcompletionassist.cpp76
-rw-r--r--src/plugins/cpptools/cppcompletionassist.h8
-rw-r--r--src/plugins/cpptools/cpptoolsreuse.cpp2
-rw-r--r--src/plugins/cpptools/symbolfinder.cpp16
-rw-r--r--src/plugins/cpptools/symbolfinder.h3
16 files changed, 119 insertions, 623 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 81c7dc71581..2abdef298ba 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -387,7 +387,7 @@ void CppEditorWidget::switchDeclarationDefinition(bool inNextSplit)
} else if (functionDefinitionSymbol) {
const Snapshot snapshot = d->m_modelManager->snapshot();
LookupContext context(d->m_lastSemanticInfo.doc, snapshot);
- LookupScope *binding = context.lookupType(functionDefinitionSymbol);
+ ClassOrNamespace *binding = context.lookupType(functionDefinitionSymbol);
const QList<LookupItem> declarations = context.lookup(functionDefinitionSymbol->name(),
functionDefinitionSymbol->enclosingScope());
diff --git a/src/plugins/cppeditor/cppelementevaluator.cpp b/src/plugins/cppeditor/cppelementevaluator.cpp
index 97b25d723f7..6740b935cc2 100644
--- a/src/plugins/cppeditor/cppelementevaluator.cpp
+++ b/src/plugins/cppeditor/cppelementevaluator.cpp
@@ -331,10 +331,10 @@ bool CppClass::operator==(const CppClass &other)
void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
{
- typedef QPair<LookupScope *, CppClass *> Data;
+ typedef QPair<ClassOrNamespace *, CppClass *> Data;
- if (LookupScope *clazz = context.lookupType(declaration)) {
- QSet<LookupScope *> visited;
+ if (ClassOrNamespace *clazz = context.lookupType(declaration)) {
+ QSet<ClassOrNamespace *> visited;
QQueue<Data> q;
q.enqueue(qMakePair(clazz, this));
@@ -342,8 +342,8 @@ void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
Data current = q.dequeue();
clazz = current.first;
visited.insert(clazz);
- const QList<LookupScope *> &bases = clazz->usings();
- foreach (LookupScope *baseClass, bases) {
+ const QList<ClassOrNamespace *> &bases = clazz->usings();
+ foreach (ClassOrNamespace *baseClass, bases) {
const QList<Symbol *> &symbols = baseClass->symbols();
foreach (Symbol *symbol, symbols) {
if (symbol->isClass() && (
@@ -433,7 +433,7 @@ CppVariable::CppVariable(Symbol *declaration, const LookupContext &context, Scop
}
if (typeName) {
- if (LookupScope *clazz = context.lookupType(typeName, scope)) {
+ if (ClassOrNamespace *clazz = context.lookupType(typeName, scope)) {
if (!clazz->symbols().isEmpty()) {
Overview overview;
Symbol *symbol = clazz->symbols().at(0);
diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
index a166e8d6412..407252ca507 100644
--- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
+++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp
@@ -38,7 +38,6 @@
#include <cplusplus/ExpressionUnderCursor.h>
#include <cplusplus/ResolveExpression.h>
#include <cplusplus/SimpleLexer.h>
-#include <cplusplus/Templates.h>
#include <cplusplus/TypeOfExpression.h>
#include <cpptools/cppmodelmanager.h>
#include <cpptools/functionutils.h>
@@ -184,7 +183,7 @@ Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() con
const QList<LookupItem> items = m_typeOfExpression(memberAccessAST->base_expression,
m_expressionDocument, m_scope);
ResolveExpression resolveExpression(m_typeOfExpression.context());
- LookupScope *binding = resolveExpression.baseExpression(items, m_accessTokenKind);
+ ClassOrNamespace *binding = resolveExpression.baseExpression(items, m_accessTokenKind);
if (binding) {
if (Class *klass = binding->rootClass()) {
result = klass;
diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp
index dfb0b1018a7..4c359ed9b62 100644
--- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp
+++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp
@@ -607,7 +607,7 @@ ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffse
SubstitutionEnvironment env;
env.setContext(sourceContext);
env.switchScope(sourceFunction->enclosingScope());
- LookupScope *targetCoN = targetContext.lookupType(targetFunction->enclosingScope());
+ ClassOrNamespace *targetCoN = targetContext.lookupType(targetFunction->enclosingScope());
if (!targetCoN)
targetCoN = targetContext.globalNamespace();
UseMinimalNames q(targetCoN);
@@ -653,7 +653,7 @@ ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffse
SubstitutionEnvironment env;
env.setContext(sourceContext);
env.switchScope(sourceFunction);
- LookupScope *targetCoN = targetContext.lookupType(targetFunction);
+ ClassOrNamespace *targetCoN = targetContext.lookupType(targetFunction);
if (!targetCoN)
targetCoN = targetContext.globalNamespace();
UseMinimalNames q(targetCoN);
diff --git a/src/plugins/cppeditor/cppinsertvirtualmethods.cpp b/src/plugins/cppeditor/cppinsertvirtualmethods.cpp
index ab6d15ead4a..222d8a90fff 100644
--- a/src/plugins/cppeditor/cppinsertvirtualmethods.cpp
+++ b/src/plugins/cppeditor/cppinsertvirtualmethods.cpp
@@ -566,15 +566,15 @@ public:
// Determine base classes
QList<const Class *> baseClasses;
- QQueue<LookupScope *> baseClassQueue;
- QSet<LookupScope *> visitedBaseClasses;
- if (LookupScope *clazz = interface.context().lookupType(m_classAST->symbol))
+ QQueue<ClassOrNamespace *> baseClassQueue;
+ QSet<ClassOrNamespace *> visitedBaseClasses;
+ if (ClassOrNamespace *clazz = interface.context().lookupType(m_classAST->symbol))
baseClassQueue.enqueue(clazz);
while (!baseClassQueue.isEmpty()) {
- LookupScope *clazz = baseClassQueue.dequeue();
+ ClassOrNamespace *clazz = baseClassQueue.dequeue();
visitedBaseClasses.insert(clazz);
- const QList<LookupScope *> bases = clazz->usings();
- foreach (LookupScope *baseClass, bases) {
+ const QList<ClassOrNamespace *> bases = clazz->usings();
+ foreach (ClassOrNamespace *baseClass, bases) {
foreach (Symbol *symbol, baseClass->symbols()) {
Class *base = symbol->asClass();
if (base
@@ -768,7 +768,7 @@ public:
const LookupContext targetContext(headerFile->cppDocument(), snapshot());
const Class *targetClass = m_classAST->symbol;
- LookupScope *targetCoN = targetContext.lookupType(targetClass->enclosingScope());
+ ClassOrNamespace *targetCoN = targetContext.lookupType(targetClass->enclosingScope());
if (!targetCoN)
targetCoN = targetContext.globalNamespace();
UseMinimalNames useMinimalNames(targetCoN);
@@ -865,7 +865,7 @@ public:
implementationDoc->translationUnit()->getPosition(insertPos, &line, &column);
Scope *targetScope = implementationDoc->scopeAt(line, column);
const LookupContext targetContext(implementationDoc, snapshot());
- LookupScope *targetCoN = targetContext.lookupType(targetScope);
+ ClassOrNamespace *targetCoN = targetContext.lookupType(targetScope);
if (!targetCoN)
targetCoN = targetContext.globalNamespace();
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index 176afcb7f9b..9ef84adad2d 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -219,7 +219,7 @@ Class *isMemberFunction(const LookupContext &context, Function *function)
if (!q->base())
return 0;
- if (LookupScope *binding = context.lookupType(q->base(), enclosingScope)) {
+ if (ClassOrNamespace *binding = context.lookupType(q->base(), enclosingScope)) {
foreach (Symbol *s, binding->symbols()) {
if (Class *matchingClass = s->asClass())
return matchingClass;
@@ -257,7 +257,7 @@ Namespace *isNamespaceFunction(const LookupContext &context, Function *function)
if (!q->base())
return 0;
- if (LookupScope *binding = context.lookupType(q->base(), enclosingScope)) {
+ if (ClassOrNamespace *binding = context.lookupType(q->base(), enclosingScope)) {
foreach (Symbol *s, binding->symbols()) {
if (Namespace *matchingNamespace = s->asNamespace())
return matchingNamespace;
@@ -1331,7 +1331,7 @@ void TranslateStringLiteral::match(const CppQuickFixInterface &interface,
for (int i = path.size() - 1; i >= 0; --i) {
if (FunctionDefinitionAST *definition = path.at(i)->asFunctionDefinition()) {
Function *function = definition->symbol;
- LookupScope *b = interface.context().lookupType(function);
+ ClassOrNamespace *b = interface.context().lookupType(function);
if (b) {
// Do we have a tr function?
foreach (const LookupItem &r, b->find(trName)) {
@@ -1592,7 +1592,7 @@ public:
SubstitutionEnvironment env;
env.setContext(context());
env.switchScope(result.first().scope());
- LookupScope *con = typeOfExpression.context().lookupType(scope);
+ ClassOrNamespace *con = typeOfExpression.context().lookupType(scope);
if (!con)
con = typeOfExpression.context().globalNamespace();
UseMinimalNames q(con);
@@ -2284,7 +2284,7 @@ Enum *findEnum(const QList<LookupItem> &results, const LookupContext &ctxt)
if (Enum *e = type->asEnumType())
return e;
if (const NamedType *namedType = type->asNamedType()) {
- if (LookupScope *con = ctxt.lookupType(namedType->name(), result.scope())) {
+ if (ClassOrNamespace *con = ctxt.lookupType(namedType->name(), result.scope())) {
const QList<Enum *> enums = con->unscopedEnums();
const Name *referenceName = namedType->name();
if (const QualifiedNameId *qualifiedName = referenceName->asQualifiedNameId())
@@ -2581,7 +2581,7 @@ public:
Document::Ptr targetDoc = targetFile->cppDocument();
Scope *targetScope = targetDoc->scopeAt(m_loc.line(), m_loc.column());
LookupContext targetContext(targetDoc, snapshot());
- LookupScope *targetCoN = targetContext.lookupType(targetScope);
+ ClassOrNamespace *targetCoN = targetContext.lookupType(targetScope);
if (!targetCoN)
targetCoN = targetContext.globalNamespace();
@@ -3215,7 +3215,7 @@ public:
SubstitutionEnvironment env;
env.setContext(context());
env.switchScope(refFunc);
- LookupScope *targetCoN = context().lookupType(refFunc->enclosingScope());
+ ClassOrNamespace *targetCoN = context().lookupType(refFunc->enclosingScope());
if (!targetCoN)
targetCoN = context().globalNamespace();
UseMinimalNames subs(targetCoN);
@@ -4644,7 +4644,7 @@ QString definitionSignature(const CppQuickFixInterface *assist,
QTC_ASSERT(func, return QString());
LookupContext cppContext(targetFile->cppDocument(), assist->snapshot());
- LookupScope *cppCoN = cppContext.lookupType(scope);
+ ClassOrNamespace *cppCoN = cppContext.lookupType(scope);
if (!cppCoN)
cppCoN = cppContext.globalNamespace();
SubstitutionEnvironment env;
@@ -5125,7 +5125,7 @@ public:
SubstitutionEnvironment env;
env.setContext(context());
env.switchScope(result.first().scope());
- LookupScope *con = typeOfExpression.context().lookupType(scope);
+ ClassOrNamespace *con = typeOfExpression.context().lookupType(scope);
if (!con)
con = typeOfExpression.context().globalNamespace();
UseMinimalNames q(con);
@@ -5724,7 +5724,7 @@ PointerType *determineConvertedType(NamedType *namedType, const LookupContext &c
{
if (!namedType)
return 0;
- if (LookupScope *binding = context.lookupType(namedType->name(), scope)) {
+ if (ClassOrNamespace *binding = context.lookupType(namedType->name(), scope)) {
if (Symbol *objectClassSymbol = skipForwardDeclarations(binding->symbols())) {
if (Class *klass = objectClassSymbol->asClass()) {
for (auto it = klass->memberBegin(), end = klass->memberEnd(); it != end; ++it) {
@@ -5782,7 +5782,7 @@ Class *senderOrReceiverClass(const CppQuickFixInterface &interface,
NamedType *objectType = objectTypeBase->asNamedType();
QTC_ASSERT(objectType, return 0);
- LookupScope *objectClassCON = context.lookupType(objectType->name(), objectPointerScope);
+ ClassOrNamespace *objectClassCON = context.lookupType(objectType->name(), objectPointerScope);
QTC_ASSERT(objectClassCON, return 0);
QTC_ASSERT(!objectClassCON->symbols().isEmpty(), return 0);
@@ -5834,7 +5834,7 @@ bool findConnectReplacement(const CppQuickFixInterface &interface,
// Minimize qualification
Control *control = context.bindings()->control().data();
- LookupScope *functionCON = context.lookupParent(scope);
+ ClassOrNamespace *functionCON = context.lookupParent(scope);
const Name *shortName = LookupContext::minimalName(method, functionCON, control);
if (!shortName->asQualifiedNameId())
shortName = control->qualifiedNameId(classOfMethod->name(), shortName);
diff --git a/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp b/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp
index 61828f1631d..3b4ba8baf50 100644
--- a/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp
+++ b/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp
@@ -152,8 +152,8 @@ public:
QTC_ASSERT(m_params.staticClass, return 0);
QTC_ASSERT(!m_params.snapshot.isEmpty(), return 0);
- Class *functionsClass = m_finder.findMatchingClassDeclaration(
- m_params.function, m_params.snapshot, &m_params.typeOfExpression->context());
+ Class *functionsClass = m_finder.findMatchingClassDeclaration(m_params.function,
+ m_params.snapshot);
if (!functionsClass)
return 0;
diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
index 956b02b5d98..fbcda2628e4 100644
--- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
+++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp
@@ -972,20 +972,6 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
"template<class $T>\n"
"using Foo = Bar<@T>;\n"
);
-
- QTest::newRow("qualifiedNames") << _(
- "struct C\n"
- "{\n"
- " struct Nested { int $member; };\n"
- " void f();\n"
- "};\n"
- "\n"
- "void C::f()\n"
- "{\n"
- " C::Nested object;\n"
- " object.@member;\n"
- "}\n"
- );
}
void CppEditorPlugin::test_FollowSymbolUnderCursor()
@@ -1390,7 +1376,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
"template <class T> struct A { virtual void virt() {} };\n"
"void f(A<int> *l) { l->$@virt(); }\n")
<< (OverrideItemList()
- << OverrideItem(QLatin1String("A<int>::virt"), 1));
+ << OverrideItem(QLatin1String("A::virt"), 1));
/// Check: Static type is nicely resolved, especially for QSharedPointers.
QTest::newRow("QSharedPointer") << _(
diff --git a/src/plugins/cpptools/cppchecksymbols.cpp b/src/plugins/cpptools/cppchecksymbols.cpp
index acf3d5c86f6..cbc6baf75e8 100644
--- a/src/plugins/cpptools/cppchecksymbols.cpp
+++ b/src/plugins/cpptools/cppchecksymbols.cpp
@@ -669,7 +669,7 @@ bool CheckSymbols::visit(NewExpressionAST *ast)
if (highlightCtorDtorAsType) {
accept(ast->new_type_id);
} else {
- LookupScope *binding = 0;
+ ClassOrNamespace *binding = 0;
NameAST *nameAST = 0;
if (ast->new_type_id) {
for (SpecifierListAST *it = ast->new_type_id->type_specifier_list; it; it = it->next) {
@@ -735,7 +735,7 @@ void CheckSymbols::checkNamespace(NameAST *name)
unsigned line, column;
getTokenStartPosition(name->firstToken(), &line, &column);
- if (LookupScope *b = _context.lookupType(name->name, enclosingScope())) {
+ if (ClassOrNamespace *b = _context.lookupType(name->name, enclosingScope())) {
foreach (Symbol *s, b->symbols()) {
if (s->isNamespace())
return;
@@ -768,14 +768,14 @@ bool CheckSymbols::hasVirtualDestructor(Class *klass) const
return false;
}
-bool CheckSymbols::hasVirtualDestructor(LookupScope *binding) const
+bool CheckSymbols::hasVirtualDestructor(ClassOrNamespace *binding) const
{
- QSet<LookupScope *> processed;
- QList<LookupScope *> todo;
+ QSet<ClassOrNamespace *> processed;
+ QList<ClassOrNamespace *> todo;
todo.append(binding);
while (!todo.isEmpty()) {
- LookupScope *b = todo.takeFirst();
+ ClassOrNamespace *b = todo.takeFirst();
if (b && !processed.contains(b)) {
processed.insert(b);
foreach (Symbol *s, b->symbols()) {
@@ -857,7 +857,7 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
{
if (ast->name) {
- LookupScope *binding = checkNestedName(ast);
+ ClassOrNamespace *binding = checkNestedName(ast);
if (binding && ast->unqualified_name) {
if (ast->unqualified_name->asDestructorName() != 0) {
@@ -886,9 +886,9 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
return false;
}
-LookupScope *CheckSymbols::checkNestedName(QualifiedNameAST *ast)
+ClassOrNamespace *CheckSymbols::checkNestedName(QualifiedNameAST *ast)
{
- LookupScope *binding = 0;
+ ClassOrNamespace *binding = 0;
if (ast->name) {
if (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list) {
@@ -954,7 +954,7 @@ bool CheckSymbols::visit(MemInitializerAST *ast)
{
if (FunctionDefinitionAST *enclosingFunction = enclosingFunctionDefinition()) {
if (ast->name && enclosingFunction->symbol) {
- if (LookupScope *binding = _context.lookupType(enclosingFunction->symbol)) {
+ if (ClassOrNamespace *binding = _context.lookupType(enclosingFunction->symbol)) {
foreach (Symbol *s, binding->symbols()) {
if (Class *klass = s->asClass()) {
NameAST *nameAST = ast->name;
@@ -1157,7 +1157,7 @@ void CheckSymbols::addUse(const Result &use)
_usages.append(use);
}
-void CheckSymbols::addType(LookupScope *b, NameAST *ast)
+void CheckSymbols::addType(ClassOrNamespace *b, NameAST *ast)
{
unsigned startToken;
if (!b || !acceptName(ast, &startToken))
@@ -1296,8 +1296,12 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
isConstructor = isConstructorDeclaration(c);
Function *funTy = c->type()->asFunctionType();
- if (!funTy) // Template function has an overridden type
- funTy = r.type()->asFunctionType();
+ if (!funTy) {
+ //Try to find a template function
+ if (Template * t = r.type()->asTemplateType())
+ if ((c = t->declaration()))
+ funTy = c->type()->asFunctionType();
+ }
if (!funTy || funTy->isAmbiguous())
continue; // TODO: add diagnostic messages and color call-operators calls too?
diff --git a/src/plugins/cpptools/cppchecksymbols.h b/src/plugins/cpptools/cppchecksymbols.h
index 11cde211460..f874c163231 100644
--- a/src/plugins/cpptools/cppchecksymbols.h
+++ b/src/plugins/cpptools/cppchecksymbols.h
@@ -105,7 +105,7 @@ protected:
const QList<Result> &otherUses);
bool hasVirtualDestructor(CPlusPlus::Class *klass) const;
- bool hasVirtualDestructor(CPlusPlus::LookupScope *binding) const;
+ bool hasVirtualDestructor(CPlusPlus::ClassOrNamespace *binding) const;
bool warning(unsigned line, unsigned column, const QString &text, unsigned length = 0);
bool warning(CPlusPlus::AST *ast, const QString &text);
@@ -119,13 +119,13 @@ protected:
void checkNamespace(CPlusPlus::NameAST *name);
void checkName(CPlusPlus::NameAST *ast, CPlusPlus::Scope *scope = 0);
- CPlusPlus::LookupScope *checkNestedName(CPlusPlus::QualifiedNameAST *ast);
+ CPlusPlus::ClassOrNamespace *checkNestedName(CPlusPlus::QualifiedNameAST *ast);
void addUse(const Result &use);
void addUse(unsigned tokenIndex, Kind kind);
void addUse(CPlusPlus::NameAST *name, Kind kind);
- void addType(CPlusPlus::LookupScope *b, CPlusPlus::NameAST *ast);
+ void addType(CPlusPlus::ClassOrNamespace *b, CPlusPlus::NameAST *ast);
bool maybeAddTypeOrStatic(const QList<CPlusPlus::LookupItem> &candidates,
CPlusPlus::NameAST *ast);
diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp
index 02cc06848f6..7deb309f587 100644
--- a/src/plugins/cpptools/cppcompletion_test.cpp
+++ b/src/plugins/cpptools/cppcompletion_test.cpp
@@ -328,17 +328,16 @@ void CppToolsPlugin::test_completion()
actualCompletions.sort();
expectedCompletions.sort();
- QEXPECT_FAIL("template_as_base: typedef not available in derived",
- "We can live with that...", Abort);
- QEXPECT_FAIL("template_specialization_with_reference", "test of reverted change", Abort);
- QEXPECT_FAIL("specialization_multiple_arguments", "test of reverted change", Abort);
- QEXPECT_FAIL("specialization_with_default_value", "test of reverted change", Abort);
+ QEXPECT_FAIL("template_as_base: explicit typedef from base", "QTCREATORBUG-14218", Abort);
QEXPECT_FAIL("enum_in_function_in_struct_in_function", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_function_in_struct_in_function_cxx11", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_function_in_struct_in_function_anon", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_class_accessed_in_member_func_cxx11", "QTCREATORBUG-13757", Abort);
QEXPECT_FAIL("enum_in_class_accessed_in_member_func_inline_cxx11", "QTCREATORBUG-13757", Abort);
- QEXPECT_FAIL("recursive_instantiation_of_template_type", "QTCREATORBUG-14237", Abort);
+ QEXPECT_FAIL("pointer_indirect_specialization", "QTCREATORBUG-14141", Abort);
+ QEXPECT_FAIL("pointer_indirect_specialization_typedef", "QTCREATORBUG-14141", Abort);
+ QEXPECT_FAIL("pointer_indirect_specialization_double_indirection", "QTCREATORBUG-14141", Abort);
+ QEXPECT_FAIL("pointer_indirect_specialization_double_indirection_with_base", "QTCREATORBUG-14141", Abort);
QCOMPARE(actualCompletions, expectedCompletions);
}
@@ -802,21 +801,6 @@ void CppToolsPlugin::test_completion_data()
<< QLatin1String("Data")
<< QLatin1String("dataMember"));
- QTest::newRow("explicit_instantiation") << _(
- "template<class T>\n"
- "struct Foo { T bar; };\n"
- "\n"
- "template class Foo<int>;\n"
- "\n"
- "void func()\n"
- "{\n"
- " Foo<int> foo;\n"
- " @\n"
- "}\n"
- ) << _("foo.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
QTest::newRow("use_global_identifier_as_base_class: derived as global and base as global") << _(
"struct Global\n"
"{\n"
@@ -1327,28 +1311,21 @@ void CppToolsPlugin::test_completion_data()
<< QLatin1String("Template1"));
QTest::newRow("template_specialization_with_pointer") << _(
- "template <typename T> struct Temp { T variable; };\n"
- "template <typename T> struct Temp<T *> { T *pointer; };\n"
- "void func()\n"
+ "template <typename T>\n"
+ "struct Template\n"
"{\n"
- " Temp<int*> templ;\n"
- " @\n"
- "}"
- ) << _("templ.") << (QStringList()
- << QLatin1String("Temp")
- << QLatin1String("pointer"));
-
- QTest::newRow("template_specialization_with_reference") << _(
- "template <typename T> struct Temp { T variable; };\n"
- "template <typename T> struct Temp<T &> { T reference; };\n"
- "void func()\n"
+ " T variable;\n"
+ "};\n"
+ "template <typename T>\n"
+ "struct Template<T *>\n"
"{\n"
- " Temp<int&> templ;\n"
- " @\n"
- "}"
+ " T *pointer;\n"
+ "};\n"
+ "Template<int*> templ;\n"
+ "@\n"
) << _("templ.") << (QStringList()
- << QLatin1String("Temp")
- << QLatin1String("reference"));
+ << QLatin1String("Template")
+ << QLatin1String("pointer"));
QTest::newRow("typedef_using_templates1") << _(
"namespace NS1\n"
@@ -1572,29 +1549,6 @@ void CppToolsPlugin::test_completion_data()
<< QLatin1String("C")
<< QLatin1String("m"));
- QTest::newRow("type_and_using_declaration: type in nested namespace and using in global") << _(
- "namespace Ns {\n"
- "namespace Nested {\n"
- "struct Foo\n"
- "{\n"
- " void func();\n"
- " int m_bar;\n"
- "};\n"
- "}\n"
- "}\n"
- "\n"
- "using namespace Ns::Nested;\n"
- "\n"
- "namespace Ns\n"
- "{\n"
- "void Foo::func()\n"
- "{\n"
- " @\n"
- "}\n"
- "}\n"
- ) << _("m_") << (QStringList()
- << QLatin1String("m_bar"));
-
QTest::newRow("instantiate_template_with_anonymous_class") << _(
"template <typename T>\n"
"struct S\n"
@@ -2568,21 +2522,6 @@ void CppToolsPlugin::test_completion_data()
) << _("ar") << (QStringList()
<< QLatin1String("arg1"));
- QTest::newRow("local_typedef_access_in_lambda") << _(
- "struct Foo { int bar; };\n"
- "\n"
- "void func()\n"
- "{\n"
- " typedef Foo F;\n"
- " []() {\n"
- " F f;\n"
- " @\n"
- " };\n"
- "}\n"
- ) << _("f.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
QTest::newRow("default_arguments_for_class_templates_and_base_class_QTCREATORBUG-12605") << _(
"struct Foo { int foo; };\n"
"template <typename T = Foo>\n"
@@ -2689,78 +2628,6 @@ void CppToolsPlugin::test_completion_data()
) << _("s.") << (QStringList()
<< QLatin1String("S"));
- QTest::newRow("partial_specialization") << _(
- "struct b {};\n"
- "template<class X, class Y> struct s { float f; };\n"
- "template<class X> struct s<X, b> { int i; };\n"
- "\n"
- "void f()\n"
- "{\n"
- " s<int, b> var;\n"
- " @\n"
- "}\n"
- ) << _("var.") << (QStringList()
- << QLatin1String("i")
- << QLatin1String("s"));
-
-// QTest::newRow("partial_specialization_with_pointer") << _(
-// "struct b {};\n"
-// "struct a : b {};\n"
-// "template<class X, class Y> struct s { float f; };\n"
-// "template<class X> struct s<X, b*> { int i; };\n"
-// "template<class X> struct s<X, a*> { char j; };\n"
-// "\n"
-// "void f()\n"
-// "{\n"
-// " s<int, a*> var;\n"
-// " @\n"
-// "}\n"
-// ) << _("var.") << (QStringList()
-// << QLatin1String("j")
-// << QLatin1String("s"));
-
- QTest::newRow("partial_specialization_templated_argument") << _(
- "template<class T> struct t {};\n"
- "\n"
- "template<class> struct s { float f; };\n"
- "template<class X> struct s<t<X>> { int i; };\n"
- "\n"
- "void f()\n"
- "{\n"
- " s<t<char>> var;\n"
- " @\n"
- "}\n"
- ) << _("var.") << (QStringList()
- << QLatin1String("i")
- << QLatin1String("s"));
-
- QTest::newRow("specialization_multiple_arguments") << _(
- "class false_type {};\n"
- "class true_type {};\n"
- "template<class T1, class T2> class and_type { false_type f; };\n"
- "template<> class and_type<true_type, true_type> { true_type t; };\n"
- "void func()\n"
- "{\n"
- " and_type<true_type, false_type> a;\n"
- " @;\n"
- "}\n"
- ) << _("a.") << (QStringList()
- << QLatin1String("f")
- << QLatin1String("and_type"));
-
- QTest::newRow("specialization_with_default_value") << _(
- "class Foo {};\n"
- "template<class T1 = Foo> class Temp;\n"
- "template<> class Temp<Foo> { int var; };\n"
- "void func()\n"
- "{\n"
- " Temp<> t;\n"
- " @\n"
- "}\n"
- ) << _("t.") << (QStringList()
- << QLatin1String("var")
- << QLatin1String("Temp"));
-
QTest::newRow("auto_declaration_in_if_condition") << _(
"struct Foo { int bar; };\n"
"void fun() {\n"
@@ -2966,28 +2833,6 @@ void CppToolsPlugin::test_completion_data()
<< QLatin1String("Foo")
<< QLatin1String("bar"));
- QTest::newRow("instantiation_of_indirect_typedef") << _(
- "template<typename _Tp>\n"
- "struct Indirect { _Tp t; };\n"
- "\n"
- "template<typename T>\n"
- "struct Temp\n"
- "{\n"
- " typedef T MyT;\n"
- " typedef Indirect<MyT> indirect;\n"
- "};\n"
- "\n"
- "struct Foo { int bar; };\n"
- "\n"
- "void func()\n"
- "{\n"
- " Temp<Foo>::indirect i;\n"
- " @\n"
- "}\n"
- ) << _("i.t.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));;
-
QTest::newRow("pointer_indirect_specialization_double_indirection_with_base") << _(
"template<typename _Tp>\n"
"struct Traits { };\n"
@@ -3024,337 +2869,6 @@ void CppToolsPlugin::test_completion_data()
) << _("t.p->") << (QStringList()
<< QLatin1String("Foo")
<< QLatin1String("bar"));
-
- QTest::newRow("recursive_instantiation_of_template_type") << _(
- "template<typename _Tp>\n"
- "struct Temp { typedef _Tp value_type; };\n"
- "\n"
- "struct Foo { int bar; };\n"
- "\n"
- "void func()\n"
- "{\n"
- " Temp<Temp<Foo> >::value_type::value_type *p;\n"
- " @\n"
- "}\n"
- ) << _("p->") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
- QTest::newRow("recursive_instantiation_of_template_type_2") << _(
- "template<typename _Tp>\n"
- "struct Temp { typedef _Tp value_type; };\n"
- "\n"
- "struct Foo { int bar; };\n"
- "\n"
- "void func()\n"
- "{\n"
- " Temp<Temp<Foo>::value_type>::value_type *p;\n"
- " @\n"
- "}\n"
- ) << _("p->") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
- QTest::newRow("template_using_instantiation") << _(
- "template<typename _Tp>\n"
- "using T = _Tp;\n"
- "\n"
- "struct Foo { int bar; };\n"
- "\n"
- "void func()\n"
- "{\n"
- " T<Foo> p;\n"
- " @\n"
- "}\n"
- ) << _("p.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
- QTest::newRow("nested_template_using_instantiation") << _(
- "struct Parent {\n"
- " template<typename _Tp>\n"
- " using T = _Tp;\n"
- "};\n"
- "\n"
- "struct Foo { int bar; };\n"
- "\n"
- "void func()\n"
- "{\n"
- " Parent::T<Foo> p;\n"
- " @;\n"
- "}\n"
- ) << _("p.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
- QTest::newRow("nested_template_using_instantiation_in_template_class") << _(
- "template<typename ParentT>\n"
- "struct Parent {\n"
- " template<typename _Tp>\n"
- " using T = _Tp;\n"
- "};\n"
- "\n"
- "struct Foo { int bar; };\n"
- "\n"
- "void func()\n"
- "{\n"
- " Parent<Foo>::T<Foo> p;\n"
- " @;\n"
- "}\n"
- ) << _("p.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
- QTest::newRow("recursive_nested_template_using_instantiation") << _(
- "struct Foo { int bar; };\n"
- "\n"
- "struct A { typedef Foo value_type; };\n"
- "\n"
- "template<typename T>\n"
- "struct Traits\n"
- "{\n"
- " typedef Foo value_type;\n"
- "\n"
- " template<typename _Tp>\n"
- " using U = T;\n"
- "};\n"
- "\n"
- "template<typename T>\n"
- "struct Temp\n"
- "{\n"
- " typedef Traits<T> TraitsT;\n"
- " typedef typename T::value_type value_type;\n"
- " typedef typename TraitsT::template U<Foo> rebind;\n"
- "};\n"
- "\n"
- "void func()\n"
- "{\n"
- " typename Temp<typename Temp<A>::rebind>::value_type p;\n"
- " @\n"
- "}\n"
- ) << _("p.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
- QTest::newRow("qualified_name_in_nested_type") << _(
- "template<typename _Tp>\n"
- "struct Temp {\n"
- " struct Nested {\n"
- " typedef typename _Tp::Nested2 N;\n"
- " };\n"
- "};\n"
- "\n"
- "struct Foo {\n"
- " struct Nested2 {\n"
- " int bar;\n"
- " };\n"
- "};\n"
- "\n"
- "void func()\n"
- "{\n"
- " Temp<Foo>::Nested::N p;\n"
- " @;\n"
- "}\n"
- ) << _("p.") << (QStringList()
- << QLatin1String("Nested2")
- << QLatin1String("bar"));
-
- QTest::newRow("simple_decltype_declaration") << _(
- "struct Foo { int bar; };\n"
- "Foo foo;\n"
- "void fun() {\n"
- " decltype(foo) s;\n"
- " @\n"
- "}\n"
- ) << _("s.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
- QTest::newRow("typedefed_decltype_declaration") << _(
- "struct Foo { int bar; };\n"
- "Foo foo;\n"
- "typedef decltype(foo) TypedefedFooWithDecltype;\n"
- "void fun() {\n"
- " TypedefedFooWithDecltype s;\n"
- " @\n"
- "}\n"
- ) << _("s.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
- QTest::newRow("nested_instantiation_typedefed_decltype_declaration") << _(
- "template <typename T>\n"
- "struct Temp\n"
- "{\n"
- " struct Nested\n"
- " {\n"
- " static T f();\n"
- " typedef decltype(f()) type;\n"
- " };\n"
- "};\n"
- "\n"
- "struct Foo { int bar; };\n"
- "\n"
- "void fun()\n"
- "{\n"
- " Temp<Foo>::Nested::type s;\n"
- " @\n"
- "}\n"
- ) << _("s.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
- QTest::newRow("typedefed_decltype_of_template_function") << _(
- "template<typename T>\n"
- "static T f();\n"
- "\n"
- "struct Foo { int bar; };\n"
- "\n"
- "void fun()\n"
- "{\n"
- " decltype(f<Foo>()) s;\n"
- " @\n"
- "}\n"
- ) << _("s.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
- QTest::newRow("nested_instantiation_typedefed_decltype_declaration_of_template_function") << _(
- "template <typename T, typename D = T>\n"
- "struct Temp\n"
- "{\n"
- " struct Nested\n"
- " {\n"
- " template<typename U> static T* __test(...);\n"
- " typedef decltype(__test<D>(0)) type;\n"
- " };\n"
- "};\n"
- "\n"
- "struct Foo { int bar; };\n"
- "\n"
- "void func()\n"
- "{\n"
- " Temp<Foo>::Nested::type s;\n"
- " @\n"
- "}\n"
- ) << _("s.") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
-
- QTest::newRow("typedef for templates in namespace") << _(
- "namespace N {\n"
- "\n"
- "struct Data { int x; };\n"
- "template <typename T> struct Foo { T member; };\n"
- "typedef Foo<Data> Bar;\n"
- "\n"
- "} // N\n"
- "\n"
- "\n"
- "void f()\n"
- "{\n"
- " N::Bar o;\n"
- " @\n"
- "}\n"
- ) << _("o.member.") << (QStringList()
- << QLatin1String("Data")
- << QLatin1String("x"));
-
- QTest::newRow("std vector") << _(
- "namespace std\n"
- "{\n"
- "template<typename _Tp>\n"
- "struct allocator\n"
- "{\n"
- " typedef _Tp value_type;\n"
- "\n"
- " template<typename _Tp1>\n"
- " struct rebind\n"
- " { typedef allocator<_Tp1> other; };\n"
- "};\n"
- "\n"
- "template<typename _Alloc, typename _Tp>\n"
- "struct __alloctr_rebind\n"
- "{\n"
- " typedef typename _Alloc::template rebind<_Tp>::other __type;\n"
- "};\n"
- "\n"
- "template<typename _Alloc>\n"
- "struct allocator_traits\n"
- "{\n"
- " typedef typename _Alloc::value_type value_type;\n"
- "\n"
- " template<typename _Tp>\n"
- " using rebind_alloc = typename __alloctr_rebind<_Alloc, _Tp>::__type;\n"
- "};\n"
- "\n"
- "template<typename _Iterator>\n"
- "struct iterator_traits { };\n"
- "\n"
- "template<typename _Tp>\n"
- "struct iterator_traits<_Tp*>\n"
- "{\n"
- " typedef _Tp* pointer;\n"
- "};\n"
- "} // namespace std\n"
- "\n"
- "namespace __gnu_cxx\n"
- "{\n"
- "template<typename _Alloc>\n"
- "struct __alloc_traits\n"
- "{\n"
- " typedef _Alloc allocator_type;\n"
- " typedef std::allocator_traits<_Alloc> _Base_type;\n"
- " typedef typename _Alloc::value_type value_type;\n"
- "\n"
- " static value_type *_S_pointer_helper(...);\n"
- " typedef decltype(_S_pointer_helper((_Alloc*)0)) __pointer;\n"
- " typedef __pointer pointer;\n"
- "\n"
- " template<typename _Tp>\n"
- " struct rebind\n"
- " { typedef typename _Base_type::template rebind_alloc<_Tp> other; };\n"
- "};\n"
- "\n"
- "template<typename _Iterator, typename _Container>\n"
- "struct __normal_iterator\n"
- "{\n"
- " typedef std::iterator_traits<_Iterator> __traits_type;\n"
- " typedef typename __traits_type::pointer pointer;\n"
- "\n"
- " pointer p;\n"
- "};\n"
- "} // namespace __gnu_cxx\n"
- "\n"
- "namespace std {\n"
- "template<typename _Tp, typename _Alloc>\n"
- "struct _Vector_Base\n"
- "{\n"
- " typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template\n"
- " rebind<_Tp>::other _Tp_alloc_type;\n"
- " typedef typename __gnu_cxx::__alloc_traits<_Tp_alloc_type>::pointer\n"
- " pointer;\n"
- "};\n"
- "\n"
- "template<typename _Tp, typename _Alloc = std::allocator<_Tp> >\n"
- "struct vector : protected _Vector_Base<_Tp, _Alloc>\n"
- "{\n"
- " typedef _Vector_Base<_Tp, _Alloc> _Base;\n"
- " typedef typename _Base::pointer pointer;\n"
- " typedef __gnu_cxx::__normal_iterator<pointer, vector> iterator;\n"
- "};\n"
- "} // namespace std\n"
- "\n"
- "struct Foo { int bar; };\n"
- "\n"
- "void func()\n"
- "{\n"
- " std::vector<Foo>::iterator it;\n"
- " @;\n"
- "}\n"
- ) << _("it.p->") << (QStringList()
- << QLatin1String("Foo")
- << QLatin1String("bar"));
}
void CppToolsPlugin::test_completion_member_access_operator()
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index fa7790a9153..eec2f2e5fe0 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -753,8 +753,8 @@ bool canCompleteClassNameAt2ndOr4thConnectArgument(
|| eater.eatConnectOpenParenthesisExpressionCommaAmpersandExpressionComma();
}
-LookupScope *lookupScopeFromLookupItem(const LookupItem &lookupItem,
- const LookupContext &context)
+ClassOrNamespace *classOrNamespaceFromLookupItem(const LookupItem &lookupItem,
+ const LookupContext &context)
{
const Name *name = 0;
@@ -783,7 +783,7 @@ LookupScope *lookupScopeFromLookupItem(const LookupItem &lookupItem,
Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &context)
{
- LookupScope *b = lookupScopeFromLookupItem(lookupItem, context);
+ ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context);
if (!b)
return 0;
@@ -796,7 +796,7 @@ Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &co
const Name *minimalName(Symbol *symbol, Scope *targetScope, const LookupContext &context)
{
- LookupScope *target = context.lookupType(targetScope);
+ ClassOrNamespace *target = context.lookupType(targetScope);
if (!target)
target = context.globalNamespace();
return context.minimalName(symbol, target, context.bindings()->control().data());
@@ -1219,12 +1219,12 @@ bool InternalCppCompletionAssistProcessor::tryObjCCompletion()
ty = ty->asPointerType()->elementType().simplified();
if (NamedType *namedTy = ty->asNamedType()) {
- LookupScope *binding = lookupContext.lookupType(namedTy->name(), item.scope());
+ ClassOrNamespace *binding = lookupContext.lookupType(namedTy->name(), item.scope());
completeObjCMsgSend(binding, false);
}
} else {
if (ObjCClass *clazz = ty->asObjCClassType()) {
- LookupScope *binding = lookupContext.lookupType(clazz->name(), item.scope());
+ ClassOrNamespace *binding = lookupContext.lookupType(clazz->name(), item.scope());
completeObjCMsgSend(binding, true);
}
}
@@ -1273,7 +1273,7 @@ void InternalCppCompletionAssistProcessor::addCompletionItem(Symbol *symbol, int
}
}
-void InternalCppCompletionAssistProcessor::completeObjCMsgSend(LookupScope *binding,
+void InternalCppCompletionAssistProcessor::completeObjCMsgSend(ClassOrNamespace *binding,
bool staticClassAccess)
{
QList<Scope*> memberScopes;
@@ -1542,26 +1542,26 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
return !m_completions.isEmpty();
}
- QList<LookupScope *> usingBindings;
- LookupScope *currentBinding = 0;
+ QList<ClassOrNamespace *> usingBindings;
+ ClassOrNamespace *currentBinding = 0;
for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) {
if (Block *block = scope->asBlock()) {
- if (LookupScope *binding = context.lookupType(scope)) {
+ if (ClassOrNamespace *binding = context.lookupType(scope)) {
for (unsigned i = 0; i < scope->memberCount(); ++i) {
Symbol *member = scope->memberAt(i);
if (member->isEnum()) {
- if (LookupScope *b = binding->findBlock(block))
+ if (ClassOrNamespace *b = binding->findBlock(block))
completeNamespace(b);
}
if (!member->name())
continue;
if (UsingNamespaceDirective *u = member->asUsingNamespaceDirective()) {
- if (LookupScope *b = binding->lookupType(u->name()))
+ if (ClassOrNamespace *b = binding->lookupType(u->name()))
usingBindings.append(b);
} else if (Class *c = member->asClass()) {
if (c->name()->isAnonymousNameId()) {
- if (LookupScope *b = binding->findBlock(block))
+ if (ClassOrNamespace *b = binding->findBlock(block))
completeClass(b);
}
}
@@ -1588,7 +1588,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
}
for (; currentBinding; currentBinding = currentBinding->parent()) {
- foreach (LookupScope* u, currentBinding->usings())
+ foreach (ClassOrNamespace* u, currentBinding->usings())
usingBindings.append(u);
const QList<Symbol *> symbols = currentBinding->symbols();
@@ -1601,7 +1601,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
}
}
- foreach (LookupScope *b, usingBindings)
+ foreach (ClassOrNamespace *b, usingBindings)
completeNamespace(b);
addKeywords();
@@ -1624,7 +1624,7 @@ bool InternalCppCompletionAssistProcessor::completeMember(const QList<LookupItem
if (!m_interface->languageFeatures().objCEnabled)
replaceDotForArrow = &m_model->m_replaceDotForArrow;
- if (LookupScope *binding =
+ if (ClassOrNamespace *binding =
resolveExpression.baseExpression(baseResults,
m_model->m_completionOperator,
replaceDotForArrow)) {
@@ -1648,27 +1648,27 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
Scope *scope = result.scope();
if (NamedType *namedTy = ty->asNamedType()) {
- if (LookupScope *b = context.lookupType(namedTy->name(), scope)) {
+ if (ClassOrNamespace *b = context.lookupType(namedTy->name(), scope)) {
completeClass(b);
break;
}
} else if (Class *classTy = ty->asClassType()) {
- if (LookupScope *b = context.lookupType(classTy)) {
+ if (ClassOrNamespace *b = context.lookupType(classTy)) {
completeClass(b);
break;
}
// it can be class defined inside a block
if (classTy->enclosingScope()->isBlock()) {
- if (LookupScope *b = context.lookupType(classTy->name(), classTy->enclosingScope())) {
+ if (ClassOrNamespace *b = context.lookupType(classTy->name(), classTy->enclosingScope())) {
completeClass(b);
break;
}
}
} else if (Namespace *nsTy = ty->asNamespaceType()) {
- if (LookupScope *b = context.lookupType(nsTy)) {
+ if (ClassOrNamespace *b = context.lookupType(nsTy)) {
completeNamespace(b);
break;
}
@@ -1676,7 +1676,7 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
} else if (Template *templ = ty->asTemplateType()) {
if (!result.binding())
continue;
- if (LookupScope *b = result.binding()->lookupType(templ->name())) {
+ if (ClassOrNamespace *b = result.binding()->lookupType(templ->name())) {
completeClass(b);
break;
}
@@ -1684,16 +1684,16 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
} else if (Enum *e = ty->asEnumType()) {
// it can be class defined inside a block
if (e->enclosingScope()->isBlock()) {
- if (LookupScope *b = context.lookupType(e)) {
+ if (ClassOrNamespace *b = context.lookupType(e)) {
Block *block = e->enclosingScope()->asBlock();
- if (LookupScope *bb = b->findBlock(block)) {
+ if (ClassOrNamespace *bb = b->findBlock(block)) {
completeNamespace(bb);
break;
}
}
}
- if (LookupScope *b = context.lookupType(e)) {
+ if (ClassOrNamespace *b = context.lookupType(e)) {
completeNamespace(b);
break;
}
@@ -1704,14 +1704,14 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
return !m_completions.isEmpty();
}
-void InternalCppCompletionAssistProcessor::completeNamespace(LookupScope *b)
+void InternalCppCompletionAssistProcessor::completeNamespace(ClassOrNamespace *b)
{
- QSet<LookupScope *> bindingsVisited;
- QList<LookupScope *> bindingsToVisit;
+ QSet<ClassOrNamespace *> bindingsVisited;
+ QList<ClassOrNamespace *> bindingsToVisit;
bindingsToVisit.append(b);
while (!bindingsToVisit.isEmpty()) {
- LookupScope *binding = bindingsToVisit.takeFirst();
+ ClassOrNamespace *binding = bindingsToVisit.takeFirst();
if (!binding || bindingsVisited.contains(binding))
continue;
@@ -1744,14 +1744,14 @@ void InternalCppCompletionAssistProcessor::completeNamespace(LookupScope *b)
}
}
-void InternalCppCompletionAssistProcessor::completeClass(LookupScope *b, bool staticLookup)
+void InternalCppCompletionAssistProcessor::completeClass(ClassOrNamespace *b, bool staticLookup)
{
- QSet<LookupScope *> bindingsVisited;
- QList<LookupScope *> bindingsToVisit;
+ QSet<ClassOrNamespace *> bindingsVisited;
+ QList<ClassOrNamespace *> bindingsToVisit;
bindingsToVisit.append(b);
while (!bindingsToVisit.isEmpty()) {
- LookupScope *binding = bindingsToVisit.takeFirst();
+ ClassOrNamespace *binding = bindingsToVisit.takeFirst();
if (!binding || bindingsVisited.contains(binding))
continue;
@@ -1838,16 +1838,16 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt
QSet<QString> signatures;
foreach (const LookupItem &lookupItem, results) {
- LookupScope *b = lookupScopeFromLookupItem(lookupItem, context);
+ ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context);
if (!b)
continue;
- QList<LookupScope *>todo;
- QSet<LookupScope *> processed;
+ QList<ClassOrNamespace *>todo;
+ QSet<ClassOrNamespace *> processed;
QList<Scope *> scopes;
todo.append(b);
while (!todo.isEmpty()) {
- LookupScope *binding = todo.takeLast();
+ ClassOrNamespace *binding = todo.takeLast();
if (!processed.contains(binding)) {
processed.insert(binding);
@@ -2063,7 +2063,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
Scope *scope = result.scope();
if (NamedType *namedTy = ty->asNamedType()) {
- if (LookupScope *b = context.lookupType(namedTy->name(), scope)) {
+ if (ClassOrNamespace *b = context.lookupType(namedTy->name(), scope)) {
foreach (const LookupItem &r, b->lookup(functionCallOp)) {
Symbol *overload = r.declaration();
FullySpecifiedType overloadTy = overload->type().simplified();
@@ -2145,7 +2145,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
SubstitutionEnvironment env;
env.setContext(context);
env.switchScope(sc);
- LookupScope *targetCoN = context.lookupType(sc);
+ ClassOrNamespace *targetCoN = context.lookupType(sc);
if (!targetCoN)
targetCoN = context.globalNamespace();
UseMinimalNames q(targetCoN);
diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h
index 01fd44e5b86..30f88090817 100644
--- a/src/plugins/cpptools/cppcompletionassist.h
+++ b/src/plugins/cpptools/cppcompletionassist.h
@@ -53,7 +53,7 @@
namespace CPlusPlus {
class LookupItem;
-class LookupScope;
+class ClassOrNamespace;
class Function;
class LookupContext;
} // namespace CPlusPlus
@@ -121,7 +121,7 @@ private:
const QString &expression,
int endOfExpression);
- void completeObjCMsgSend(CPlusPlus::LookupScope *binding, bool staticClassAccess);
+ void completeObjCMsgSend(CPlusPlus::ClassOrNamespace *binding, bool staticClassAccess);
bool completeInclude(const QTextCursor &cursor);
void completeInclude(const QString &realPath, const QStringList &suffixes);
void completePreprocessor();
@@ -130,8 +130,8 @@ private:
bool toolTipOnly);
bool completeMember(const QList<CPlusPlus::LookupItem> &results);
bool completeScope(const QList<CPlusPlus::LookupItem> &results);
- void completeNamespace(CPlusPlus::LookupScope *binding);
- void completeClass(CPlusPlus::LookupScope *b, bool staticLookup = true);
+ void completeNamespace(CPlusPlus::ClassOrNamespace *binding);
+ void completeClass(CPlusPlus::ClassOrNamespace *b, bool staticLookup = true);
void addClassMembersToCompletion(CPlusPlus::Scope *scope, bool staticLookup);
enum CompleteQtMethodMode {
CompleteQt4Signals,
diff --git a/src/plugins/cpptools/cpptoolsreuse.cpp b/src/plugins/cpptools/cpptoolsreuse.cpp
index f3a79429541..c70bdb14e5c 100644
--- a/src/plugins/cpptools/cpptoolsreuse.cpp
+++ b/src/plugins/cpptools/cpptoolsreuse.cpp
@@ -108,7 +108,7 @@ bool isOwnershipRAIIType(Symbol *symbol, const LookupContext &context)
Declaration *declaration = symbol->asDeclaration();
const NamedType *namedType = declaration->type()->asNamedType();
if (namedType) {
- LookupScope *clazz = context.lookupType(namedType->name(),
+ ClassOrNamespace *clazz = context.lookupType(namedType->name(),
declaration->enclosingScope());
if (clazz && !clazz->symbols().isEmpty()) {
Overview overview;
diff --git a/src/plugins/cpptools/symbolfinder.cpp b/src/plugins/cpptools/symbolfinder.cpp
index 3bc72c00b50..cc5006e63af 100644
--- a/src/plugins/cpptools/symbolfinder.cpp
+++ b/src/plugins/cpptools/symbolfinder.cpp
@@ -151,7 +151,7 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
QList<Function *> viableFunctions;
- LookupScope *enclosingType = context.lookupType(declaration);
+ ClassOrNamespace *enclosingType = context.lookupType(declaration);
if (!enclosingType)
continue; // nothing to do
@@ -214,15 +214,13 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
return 0;
}
-Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Snapshot &snapshot,
- const LookupContext *context)
+Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Snapshot &snapshot)
{
if (!declaration->identifier())
return 0;
QString declFile = QString::fromUtf8(declaration->fileName(), declaration->fileNameLength());
- const bool useLocalContext = !context;
foreach (const QString &file, fileIterationOrder(declFile, snapshot)) {
Document::Ptr doc = snapshot.document(file);
if (!doc) {
@@ -234,13 +232,9 @@ Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Sna
declaration->identifier()->size()))
continue;
- QScopedPointer<LookupContext> localContext;
- if (useLocalContext) {
- localContext.reset(new LookupContext(doc, snapshot));
- context = localContext.data();
- }
+ LookupContext context(doc, snapshot);
- LookupScope *type = context->lookupType(declaration);
+ ClassOrNamespace *type = context.lookupType(declaration);
if (!type)
continue;
@@ -289,7 +283,7 @@ void SymbolFinder::findMatchingDeclaration(const LookupContext &context,
if (!functionName)
return;
- LookupScope *binding = 0;
+ ClassOrNamespace *binding = 0;
const QualifiedNameId *qName = functionName->asQualifiedNameId();
if (qName) {
if (qName->base())
diff --git a/src/plugins/cpptools/symbolfinder.h b/src/plugins/cpptools/symbolfinder.h
index 45236eb1ad9..c1d65f7716d 100644
--- a/src/plugins/cpptools/symbolfinder.h
+++ b/src/plugins/cpptools/symbolfinder.h
@@ -61,8 +61,7 @@ public:
bool strict = false);
CPlusPlus::Class *findMatchingClassDeclaration(CPlusPlus::Symbol *declaration,
- const CPlusPlus::Snapshot &snapshot,
- const CPlusPlus::LookupContext *context = 0);
+ const CPlusPlus::Snapshot &snapshot);
void findMatchingDeclaration(const CPlusPlus::LookupContext &context,
CPlusPlus::Function *functionType,