diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-04-28 17:46:40 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-05-11 11:54:09 +0000 |
commit | 64ec695566ff1479744e4467e053cfa6cf3bfb8c (patch) | |
tree | 148c7cb42afe33b47ce7be855d324e290027240c /src/plugins/clangcodemodel/test | |
parent | f127cb3c597dcb53acf40640757bc97efc8f059a (diff) | |
download | qt-creator-64ec695566ff1479744e4467e053cfa6cf3bfb8c.tar.gz |
Clang: Show function signature hint for constructors and functors
For "foo(|" [1] we requested a completion from libclang with the cursor
position just before "foo" and then filtered the function declarations
for functions matching the name "foo". This worked fine for ordinary
functions, but obviously not for constructors and functors.
Recent versions of libclang support proper function call completion with
XCursor_OverloadCandidate, so make use of that.
[1] '|' represents the cursor position
Task-number: QTCREATORBUG-14882
Task-number: QTCREATORBUG-14884
Change-Id: I9d31b3960ccff6a8b9440dbcb7ff9f5ca9f61266
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/plugins/clangcodemodel/test')
3 files changed, 10 insertions, 8 deletions
diff --git a/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp b/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp index 9d2008662f..f06753ebc6 100644 --- a/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp +++ b/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp @@ -819,13 +819,14 @@ void ClangCodeCompletionTest::testCompleteFunctions() QVERIFY(hasItem(t.proposal, "TType<QString> f(bool)")); } -void ClangCodeCompletionTest::testCompleteConstructorAndFallbackToGlobalCompletion() +void ClangCodeCompletionTest::testCompleteConstructor() { ProjectLessCompletionTest t("constructorCompletion.cpp"); - QVERIFY(hasItem(t.proposal, "globalVariable")); - QVERIFY(hasItem(t.proposal, "GlobalClassWithCustomConstructor")); - QVERIFY(!hasSnippet(t.proposal, "class")); + QVERIFY(!hasItem(t.proposal, "globalVariable")); + QVERIFY(!hasItem(t.proposal, "class")); + QVERIFY(hasItem(t.proposal, "Foo(int)")); + QVERIFY(hasItem(t.proposal, "Foo(int, double)")); } // Explicitly Inserting The Dot diff --git a/src/plugins/clangcodemodel/test/clangcodecompletion_test.h b/src/plugins/clangcodemodel/test/clangcodecompletion_test.h index 3f163c6266..24b36da4f0 100644 --- a/src/plugins/clangcodemodel/test/clangcodecompletion_test.h +++ b/src/plugins/clangcodemodel/test/clangcodecompletion_test.h @@ -45,7 +45,7 @@ private slots: void testCompleteGlobals(); void testCompleteMembers(); void testCompleteFunctions(); - void testCompleteConstructorAndFallbackToGlobalCompletion(); + void testCompleteConstructor(); void testCompleteWithDotToArrowCorrection(); void testDontCompleteWithDotToArrowCorrectionForFloats(); diff --git a/src/plugins/clangcodemodel/test/data/constructorCompletion.cpp b/src/plugins/clangcodemodel/test/data/constructorCompletion.cpp index 1b19b68a10..211fda71bd 100644 --- a/src/plugins/clangcodemodel/test/data/constructorCompletion.cpp +++ b/src/plugins/clangcodemodel/test/data/constructorCompletion.cpp @@ -1,9 +1,10 @@ int globalVariable; -struct GlobalClassWithCustomConstructor { - GlobalClassWithCustomConstructor(int) {} +struct Foo { + Foo(int) {} + Foo(int, double) {} }; void f() { - GlobalClassWithCustomConstructor foo( /* COMPLETE HERE */ + Foo foo( /* COMPLETE HERE */ } |