Clang: Fallback to global completion if function call completion fails

We can not offer proper constructor completion with libclang <= 3.6, so
fall back to normal/global completion.

Change-Id: I90bb8d981ae20ed4c228f829ad4267221b92f8a1
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-07-22 13:09:44 +02:00
parent 889237f962
commit 5643a45a83
7 changed files with 40 additions and 9 deletions

View File

@@ -20,5 +20,6 @@
<file>exampleIncludeDir/otherFile.h</file>
<file>exampleIncludeDir/mylib/mylib.h</file>
<file>globalCompletion.cpp</file>
<file>constructorCompletion.cpp</file>
</qresource>
</RCC>

View File

@@ -874,6 +874,15 @@ void ClangCodeCompletionTest::testCompleteFunctions()
QVERIFY(hasItem(t.proposal, "TType<QString> f(bool)"));
}
void ClangCodeCompletionTest::testCompleteConstructorAndFallbackToGlobalCompletion()
{
ProjectLessCompletionTest t("constructorCompletion.cpp");
QVERIFY(hasItem(t.proposal, "globalVariable"));
QVERIFY(hasItem(t.proposal, "GlobalClassWithCustomConstructor"));
QVERIFY(!hasSnippet(t.proposal, "class"));
}
void ClangCodeCompletionTest::testProjectDependentCompletion()
{
const TestDocument testDocument("completionWithProject.cpp");

View File

@@ -57,6 +57,7 @@ private slots:
void testCompleteGlobals();
void testCompleteMembers();
void testCompleteFunctions();
void testCompleteConstructorAndFallbackToGlobalCompletion();
void testProjectDependentCompletion();
void testChangingProjectDependentCompletion();

View File

@@ -0,0 +1,9 @@
int globalVariable;
struct GlobalClassWithCustomConstructor {
GlobalClassWithCustomConstructor(int) {}
};
void f() {
GlobalClassWithCustomConstructor foo( /* COMPLETE HERE */
}