diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index f0bbb4ffca806afc579076cfc8028c6540cfd5de..a736b3dd7af609ccfdeb017c176f2b8018553d88 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -276,7 +276,12 @@ QList<Scope *> LookupContext::buildVisibleScopes() QList<Scope *> scopes; if (_symbol) { - for (Scope *scope = _symbol->scope(); scope; scope = scope->enclosingScope()) { + Scope *scope = _symbol->scope(); + + if (Function *fun = _symbol->asFunction()) + scope = fun->members(); // handle ctor initializers. + + for (; scope; scope = scope->enclosingScope()) { if (scope == _thisDocument->globalSymbols()) break; diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 63a4d4c6cc179317898dce87ef4191a983b1e90d..bc1d1d4ad724dda56c979ba264e018c19044c4ec 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -817,11 +817,10 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) const Snapshot snapshot = m_manager->snapshot(); if (Document::Ptr thisDocument = snapshot.value(fileName)) { - Symbol *symbol = thisDocument->findSymbolAt(line, column); - + Symbol *lastVisibleSymbol = thisDocument->findSymbolAt(line, column); typeOfExpression.setSnapshot(m_manager->snapshot()); - QList<TypeOfExpression::Result> resolvedTypes = typeOfExpression(expression, thisDocument, symbol, + QList<TypeOfExpression::Result> resolvedTypes = typeOfExpression(expression, thisDocument, lastVisibleSymbol, TypeOfExpression::Preprocess); LookupContext context = typeOfExpression.lookupContext(); @@ -847,7 +846,7 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) m_completionOperator == T_SLOT)) { // Apply signal/slot completion on 'this' expression = QLatin1String("this"); - resolvedTypes = typeOfExpression(expression, thisDocument, symbol); + resolvedTypes = typeOfExpression(expression, thisDocument, lastVisibleSymbol); context = typeOfExpression.lookupContext(); } @@ -883,7 +882,7 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor) // Resolve the type of this expression QList<TypeOfExpression::Result> results = - typeOfExpression(baseExpression, thisDocument, symbol, TypeOfExpression::Preprocess); + typeOfExpression(baseExpression, thisDocument, lastVisibleSymbol, TypeOfExpression::Preprocess); // If it's a class, add completions for the constructors foreach (const TypeOfExpression::Result &result, results) {