forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/2.7'
Conflicts: src/plugins/cpptools/cppchecksymbols.h src/plugins/qmldesigner/components/formeditor/resizecontroller.cpp Change-Id: I887ba071fa637ad44e39bcae581738fa078a6612
This commit is contained in:
@@ -1227,6 +1227,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
|
||||
{
|
||||
unsigned startToken = ast->firstToken();
|
||||
bool isDestructor = false;
|
||||
bool isConstructor = false;
|
||||
if (DestructorNameAST *dtor = ast->asDestructorName()) {
|
||||
isDestructor = true;
|
||||
if (dtor->unqualified_name)
|
||||
@@ -1251,6 +1252,8 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
|
||||
if (isDestructor != c->name()->isDestructorNameId())
|
||||
continue;
|
||||
|
||||
isConstructor = isConstructorDeclaration(c);
|
||||
|
||||
Function *funTy = c->type()->asFunctionType();
|
||||
if (! funTy) {
|
||||
//Try to find a template function
|
||||
@@ -1283,7 +1286,9 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
|
||||
}
|
||||
|
||||
if (matchType != Match_None) {
|
||||
// decide how constructor and destructor should be highlighted
|
||||
if (highlightCtorDtorAsType
|
||||
&& (isConstructor || isDestructor)
|
||||
&& maybeType(ast->name)
|
||||
&& kind == SemanticInfo::FunctionUse) {
|
||||
return false;
|
||||
@@ -1386,3 +1391,12 @@ void CheckSymbols::flush()
|
||||
_usages.clear();
|
||||
_usages.reserve(cap);
|
||||
}
|
||||
|
||||
bool CheckSymbols::isConstructorDeclaration(Symbol *declaration)
|
||||
{
|
||||
Class *clazz = declaration->enclosingClass();
|
||||
if (clazz && clazz->name())
|
||||
return declaration->name()->isEqualTo(clazz->name());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -166,6 +166,8 @@ protected:
|
||||
void flush();
|
||||
|
||||
private:
|
||||
bool isConstructorDeclaration(CPlusPlus::Symbol *declaration);
|
||||
|
||||
CPlusPlus::Document::Ptr _doc;
|
||||
CPlusPlus::LookupContext _context;
|
||||
CPlusPlus::TypeOfExpression typeOfExpression;
|
||||
|
||||
@@ -1796,3 +1796,50 @@ void CppToolsPlugin::test_completion_typedef_using_templates2()
|
||||
QVERIFY(completions.contains(QLatin1String("Foo")));
|
||||
QVERIFY(completions.contains(QLatin1String("bar")));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_namespace_alias_with_many_namespace_declarations()
|
||||
{
|
||||
TestData data;
|
||||
data.srcText =
|
||||
"namespace NS1\n"
|
||||
"{\n"
|
||||
"namespace NS2\n"
|
||||
"{\n"
|
||||
"struct Foo1\n"
|
||||
"{\n"
|
||||
" int bar1;\n"
|
||||
"};\n"
|
||||
"}\n"
|
||||
"}\n"
|
||||
"namespace NS1\n"
|
||||
"{\n"
|
||||
"namespace NS2\n"
|
||||
"{\n"
|
||||
"struct Foo2\n"
|
||||
"{\n"
|
||||
" int bar2;\n"
|
||||
"};\n"
|
||||
"}\n"
|
||||
"}\n"
|
||||
"namespace NS = NS1::NS2;\n"
|
||||
"int main()\n"
|
||||
"{\n"
|
||||
" @\n"
|
||||
" // padding so we get the scope right\n"
|
||||
"}\n"
|
||||
;
|
||||
setup(&data);
|
||||
|
||||
Utils::ChangeSet change;
|
||||
QString txt = QLatin1String("NS::");
|
||||
change.insert(data.pos, txt);
|
||||
QTextCursor cursor(data.doc);
|
||||
change.apply(&cursor);
|
||||
data.pos += txt.length();
|
||||
|
||||
QStringList completions = getCompletions(data);
|
||||
|
||||
QCOMPARE(completions.size(), 2);
|
||||
QVERIFY(completions.contains(QLatin1String("Foo1")));
|
||||
QVERIFY(completions.contains(QLatin1String("Foo2")));
|
||||
}
|
||||
|
||||
@@ -502,7 +502,9 @@ public:
|
||||
|
||||
BasicProposalItem *operator()(Symbol *symbol)
|
||||
{
|
||||
if (! symbol || ! symbol->name() || symbol->name()->isQualifiedNameId())
|
||||
//using declaration can be qualified
|
||||
if (! symbol || ! symbol->name() || (symbol->name()->isQualifiedNameId()
|
||||
&& ! symbol->asUsingDeclaration()))
|
||||
return 0;
|
||||
|
||||
BasicProposalItem *previousItem = switchCompletionItem(0);
|
||||
|
||||
@@ -122,6 +122,7 @@ private slots:
|
||||
void test_completion_template_specialization_with_pointer();
|
||||
void test_completion_typedef_using_templates1();
|
||||
void test_completion_typedef_using_templates2();
|
||||
void test_completion_namespace_alias_with_many_namespace_declarations();
|
||||
|
||||
void test_format_pointerdeclaration_in_simpledeclarations();
|
||||
void test_format_pointerdeclaration_in_simpledeclarations_data();
|
||||
|
||||
Reference in New Issue
Block a user