forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -53,7 +53,9 @@ protected:
|
||||
CodeCompletionChunk semicolon{CodeCompletionChunk::SemiColon, Utf8StringLiteral(";")};
|
||||
CodeCompletionChunk colonColonText{CodeCompletionChunk::Text, Utf8StringLiteral("::")};
|
||||
CodeCompletionChunk functionArgumentX{CodeCompletionChunk::Placeholder, Utf8StringLiteral("char x")};
|
||||
CodeCompletionChunk functionArgumentXAsCurrentParameter{CodeCompletionChunk::CurrentParameter, Utf8StringLiteral("char x")};
|
||||
CodeCompletionChunk functionArgumentY{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int y")};
|
||||
CodeCompletionChunk functionArgumentYAsCurrentParamter{CodeCompletionChunk::CurrentParameter, Utf8StringLiteral("int y")};
|
||||
CodeCompletionChunk functionArgumentZ{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int z")};
|
||||
CodeCompletionChunk functionArgumentTemplate{CodeCompletionChunk::Placeholder, Utf8StringLiteral("const Foo<int> &foo")};
|
||||
CodeCompletionChunk switchName{CodeCompletionChunk::TypedText, Utf8StringLiteral("switch")};
|
||||
@@ -78,6 +80,7 @@ protected:
|
||||
CodeCompletionChunk optionalEnableIfTType{CodeCompletionChunk::Placeholder, Utf8StringLiteral("_Tp"), true};
|
||||
CodeCompletionChunk optionalComma{CodeCompletionChunk::Comma, Utf8StringLiteral(", "), true};
|
||||
CodeCompletionChunk optionalFunctionArgumentY{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int y"), true};
|
||||
CodeCompletionChunk optionalFunctionArgumentYAsCurrentParameter{CodeCompletionChunk::CurrentParameter, Utf8StringLiteral("int y"), true};
|
||||
CodeCompletionChunk optionalFunctionArgumentZ{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int z"), true};
|
||||
};
|
||||
|
||||
@@ -117,7 +120,7 @@ TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithOneArgumen
|
||||
CodeCompletionChunks completionChunks({integerResultType,
|
||||
functionName,
|
||||
leftParen,
|
||||
functionArgumentX,
|
||||
functionArgumentXAsCurrentParameter,
|
||||
rightParen});
|
||||
|
||||
ASSERT_THAT(converter.convertToFunctionSignatureWithHtml(completionChunks),
|
||||
@@ -129,7 +132,7 @@ TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithOneParamet
|
||||
CodeCompletionChunks completionChunks({integerResultType,
|
||||
functionName,
|
||||
leftParen,
|
||||
functionArgumentX,
|
||||
functionArgumentXAsCurrentParameter,
|
||||
rightParen});
|
||||
|
||||
ASSERT_THAT(converter.convertToFunctionSignatureWithHtml(completionChunks, 1),
|
||||
@@ -143,7 +146,7 @@ TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithTwoParamet
|
||||
leftParen,
|
||||
functionArgumentX,
|
||||
comma,
|
||||
functionArgumentY,
|
||||
functionArgumentYAsCurrentParamter,
|
||||
rightParen});
|
||||
|
||||
ASSERT_THAT(converter.convertToFunctionSignatureWithHtml(completionChunks, 2),
|
||||
@@ -157,7 +160,7 @@ TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithTwoParamet
|
||||
leftParen,
|
||||
functionArgumentX,
|
||||
optionalComma,
|
||||
optionalFunctionArgumentY,
|
||||
optionalFunctionArgumentYAsCurrentParameter,
|
||||
rightParen});
|
||||
|
||||
ASSERT_THAT(converter.convertToFunctionSignatureWithHtml(completionChunks, 2),
|
||||
|
||||
Reference in New Issue
Block a user