diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-05-12 12:53:16 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-05-14 13:55:21 +0200 |
commit | 60f76c96e8cf9b751e6250a9f80d2517adaf7a5b (patch) | |
tree | 098e360e59bf66ca8688582da8896a576554a531 /src/plugins/cpptools/cppcodecompletion.cpp | |
parent | 140756eef42f4b580c9aecac33c2284d3937bf9f (diff) | |
download | qt-creator-60f76c96e8cf9b751e6250a9f80d2517adaf7a5b.tar.gz |
Improved LookupItem and get rid of some deprecated code.
Diffstat (limited to 'src/plugins/cpptools/cppcodecompletion.cpp')
-rw-r--r-- | src/plugins/cpptools/cppcodecompletion.cpp | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 977fb4001a..bd2c4f87a1 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -754,15 +754,17 @@ int CppCodeCompletion::startCompletionInternal(TextEditor::BaseTextEditor *edit, } } + Scope *scope = thisDocument->scopeAt(line, column); + Q_ASSERT(scope != 0); - QList<LookupItem> results = typeOfExpression(expression, lastVisibleSymbol, TypeOfExpression::Preprocess); + QList<LookupItem> results = typeOfExpression(expression, scope, TypeOfExpression::Preprocess); LookupContext context = typeOfExpression.lookupContext(); if (results.isEmpty()) { if (m_completionOperator == T_SIGNAL || m_completionOperator == T_SLOT) { if (! (expression.isEmpty() || expression == QLatin1String("this"))) { expression = QLatin1String("this"); - results = typeOfExpression(expression, lastVisibleSymbol); + results = typeOfExpression(expression, scope); } if (results.isEmpty()) @@ -785,7 +787,7 @@ int CppCodeCompletion::startCompletionInternal(TextEditor::BaseTextEditor *edit, // Resolve the type of this expression const QList<LookupItem> results = - typeOfExpression(baseExpression, lastVisibleSymbol, + typeOfExpression(baseExpression, scope, TypeOfExpression::Preprocess); // If it's a class, add completions for the constructors @@ -930,10 +932,10 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<LookupItem> &r foreach (const LookupItem &result, results) { FullySpecifiedType ty = result.type().simplified(); - Symbol *lastVisibleSymbol = result.lastVisibleSymbol(); + Scope *scope = result.scope(); if (NamedType *namedTy = ty->asNamedType()) { - if (ClassOrNamespace *b = context.classOrNamespace(namedTy->name(), lastVisibleSymbol)) { + if (ClassOrNamespace *b = context.classOrNamespace(namedTy->name(), scope)) { foreach (Symbol *overload, b->lookup(functionCallOp)) { FullySpecifiedType overloadTy = overload->type().simplified(); @@ -966,8 +968,8 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<LookupItem> &r // find a scope that encloses the current location, starting from the lastVisibileSymbol // and moving outwards Scope *sc = 0; - if (typeOfExpression.lastVisibleSymbol()) - sc = typeOfExpression.lastVisibleSymbol()->scope(); + if (typeOfExpression.scope()) + sc = typeOfExpression.scope(); else if (context.thisDocument()) sc = context.thisDocument()->globalSymbols(); @@ -1054,7 +1056,7 @@ bool CppCodeCompletion::completeMember(const QList<LookupItem> &baseResults, if (baseResults.isEmpty()) return false; - ResolveExpression resolveExpression(typeOfExpression.lastVisibleSymbol(), context); + ResolveExpression resolveExpression(context); bool replacedDotOperator = false; const QList<LookupItem> classObjectResults = @@ -1064,21 +1066,22 @@ bool CppCodeCompletion::completeMember(const QList<LookupItem> &baseResults, ClassOrNamespace *classOrNamespace = 0; - QList<Symbol *> classObjectCandidates; foreach (const LookupItem &r, classObjectResults) { FullySpecifiedType ty = r.type().simplified(); - if (Class *klass = ty->asClassType()) - classObjectCandidates.append(klass); + if (Class *klass = ty->asClassType()) { + if (ClassOrNamespace *b = context.classOrNamespace(klass)) { + classOrNamespace = b; + break; + } + } else if (NamedType *namedTy = ty->asNamedType()) { - if (ClassOrNamespace *b = context.classOrNamespace(namedTy->name(), r.lastVisibleSymbol())) { + if (ClassOrNamespace *b = context.classOrNamespace(namedTy->name(), r.scope())) { classOrNamespace = b; break; - } else { Overview oo; - qDebug() << "*** no class for" << oo(namedTy->name()); } } @@ -1109,10 +1112,10 @@ bool CppCodeCompletion::completeScope(const QList<LookupItem> &results, foreach (const LookupItem &result, results) { FullySpecifiedType ty = result.type(); - Symbol *lastVisibleSymbol = result.lastVisibleSymbol(); + Scope *scope = result.scope(); if (NamedType *namedTy = ty->asNamedType()) { - if (ClassOrNamespace *b = context.classOrNamespace(namedTy->name(), lastVisibleSymbol)) { + if (ClassOrNamespace *b = context.classOrNamespace(namedTy->name(), scope)) { completeClass(b, context); break; } @@ -1353,7 +1356,7 @@ bool CppCodeCompletion::completeQtMethod(const QList<LookupItem> &results, if (results.isEmpty()) return false; - DeprecatedLookupContext context(typeOfExpression.lastVisibleSymbol(), + DeprecatedLookupContext context(typeOfExpression.scope()->owner(), newContext.expressionDocument(), newContext.thisDocument(), newContext.snapshot()); @@ -1377,7 +1380,7 @@ bool CppCodeCompletion::completeQtMethod(const QList<LookupItem> &results, if (! namedTy) // not a class name. continue; - ClassOrNamespace *b = newContext.classOrNamespace(namedTy->name(), p.lastVisibleSymbol()); + ClassOrNamespace *b = newContext.classOrNamespace(namedTy->name(), p.scope()); if (! b) continue; |