Commit 815d9cb1 authored by Christian Kamm's avatar Christian Kamm

C++ completion: Minimize qualified names in function signatures.

Change-Id: I8e2c38e279952372b3e12f6ea8da18b75b39a5d4
Reviewed-on: http://codereview.qt.nokia.com/2733Reviewed-by: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
parent 6fe8d74a
......@@ -47,6 +47,7 @@
#include <SymbolVisitor.h>
#include <Scope.h>
#include <TranslationUnit.h>
#include <CppRewriter.h>
#include <cplusplus/ResolveExpression.h>
#include <cplusplus/MatchingText.h>
......@@ -1857,14 +1858,29 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPl
}
if (autocompleteSignature && !isDestructor) {
// set up for rewriting function types with minimally qualified names
// to do it correctly we'd need the declaration's context and scope, but
// that'd be too expensive to get here. instead, we just minimize locally
SubstitutionEnvironment env;
env.setContext(context);
env.switchScope(sc);
ClassOrNamespace *targetCoN = context.lookupType(sc);
if (!targetCoN)
targetCoN = context.globalNamespace();
UseMinimalNames q(targetCoN);
env.enter(&q);
Control *control = context.control().data();
// set up signature autocompletion
foreach (Function *f, functions) {
Overview overview;
overview.setShowArgumentNames(true);
overview.setShowDefaultArguments(false);
const FullySpecifiedType localTy = rewriteType(f->type(), &env, control);
// gets: "parameter list) cv-spec",
QString completion = overview(f->type()).mid(1);
QString completion = overview(localTy).mid(1);
addCompletionItem(completion, QIcon(), 0,
QVariant::fromValue(CompleteFunctionDeclaration(f)));
......
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