summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2018-10-05 14:34:50 +0200
committerIvan Donchevskii <ivan.donchevskii@qt.io>2018-10-05 13:57:00 +0000
commit66e5d2f492c44d912349c2b695389a2d1f9c0c81 (patch)
tree507b8234ead1ffc20ae5341965836eb5fa1bf461
parentc29e4836071a7bcd123b43cc113352dc6a7543be (diff)
downloadqt-creator-66e5d2f492c44d912349c2b695389a2d1f9c0c81.tar.gz
Clang: Fix C++ method code completion
Clang returns no result type when the virtual method from the base class is called in the same method override in the derived class. This is not a problem for us because it's not a method definition and therefore it does not require special handling. Change-Id: I736989165c1f031dc1937c7935e26da8236d9e9e Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--src/plugins/clangcodemodel/clangassistproposalitem.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/plugins/clangcodemodel/clangassistproposalitem.cpp b/src/plugins/clangcodemodel/clangassistproposalitem.cpp
index 6b4d0b8162..ed15a006f6 100644
--- a/src/plugins/clangcodemodel/clangassistproposalitem.cpp
+++ b/src/plugins/clangcodemodel/clangassistproposalitem.cpp
@@ -210,11 +210,19 @@ void ClangAssistProposalItem::apply(TextDocumentManipulatorInterface &manipulato
if (!abandonParen && ccr.completionKind == CodeCompletion::FunctionDefinitionCompletionKind) {
const CodeCompletionChunk resultType = ccr.chunks.first();
- QTC_ASSERT(resultType.kind == CodeCompletionChunk::ResultType, return;);
- if (::Utils::Text::matchPreviousWord(manipulator, cursor, resultType.text.toString())) {
- extraCharacters += methodDefinitionParameters(ccr.chunks);
- // To skip the next block.
- abandonParen = true;
+ if (resultType.kind == CodeCompletionChunk::ResultType) {
+ if (::Utils::Text::matchPreviousWord(manipulator, cursor, resultType.text.toString())) {
+ extraCharacters += methodDefinitionParameters(ccr.chunks);
+ // To skip the next block.
+ abandonParen = true;
+ }
+ } else {
+ // Do nothing becasue it's not a function definition.
+
+ // It's a clang bug that the function might miss a ResultType chunk
+ // when the base class method is called from the overriding method
+ // of the derived class. For example:
+ // void Derived::foo() override { Base::<complete here> }
}
}
if (!abandonParen) {