summaryrefslogtreecommitdiff
path: root/src/plugins/clangcodemodel/clangcompletionchunkstotextconverter.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2017-04-28 17:46:40 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2017-05-11 11:54:09 +0000
commit64ec695566ff1479744e4467e053cfa6cf3bfb8c (patch)
tree148c7cb42afe33b47ce7be855d324e290027240c /src/plugins/clangcodemodel/clangcompletionchunkstotextconverter.cpp
parentf127cb3c597dcb53acf40640757bc97efc8f059a (diff)
downloadqt-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/clangcompletionchunkstotextconverter.cpp')
-rw-r--r--src/plugins/clangcodemodel/clangcompletionchunkstotextconverter.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/plugins/clangcodemodel/clangcompletionchunkstotextconverter.cpp b/src/plugins/clangcodemodel/clangcompletionchunkstotextconverter.cpp
index 77eccac70d..2852be4697 100644
--- a/src/plugins/clangcodemodel/clangcompletionchunkstotextconverter.cpp
+++ b/src/plugins/clangcodemodel/clangcompletionchunkstotextconverter.cpp
@@ -167,7 +167,11 @@ void CompletionChunksToTextConverter::parse(
switch (codeCompletionChunk.kind()) {
case CodeCompletionChunk::ResultType: parseResultType(codeCompletionChunk.text()); break;
- case CodeCompletionChunk::Placeholder: parsePlaceHolder(codeCompletionChunk); break;
+ // Do not rely on CurrentParameter because it might be wrong for
+ // invalid code. Instead, handle it as PlaceHolder.
+ case CodeCompletionChunk::CurrentParameter:
+ case CodeCompletionChunk::Placeholder:
+ parsePlaceHolder(codeCompletionChunk); break;
case CodeCompletionChunk::LeftParen: parseLeftParen(codeCompletionChunk); break;
case CodeCompletionChunk::LeftBrace: parseLeftBrace(codeCompletionChunk); break;
default: parseText(codeCompletionChunk.text()); break;