Commit 6b4db9e6 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Handle ctor-initializers in the LookupContext.

parent 0ed9043c
......@@ -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;
......
......@@ -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) {
......
Markdown is supported
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