forked from qt-creator/qt-creator
Clang: Fix inserting "::" after namespace
The extra "::" is showed in the tooltip right to the completion list item, but it was not inserted. Change-Id: I0ad2b816c56b8e3b5ccf0643f2c1a4f2a20b8818 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
@@ -111,6 +111,12 @@ void ClangAssistProposalItem::applyContextualContent(TextEditor::TextEditorWidge
|
|||||||
textToBeInserted = converter.text();
|
textToBeInserted = converter.text();
|
||||||
if (converter.hasPlaceholderPositions())
|
if (converter.hasPlaceholderPositions())
|
||||||
cursorOffset = converter.placeholderPositions().at(0) - converter.text().size();
|
cursorOffset = converter.placeholderPositions().at(0) - converter.text().size();
|
||||||
|
} else if (ccr.completionKind() == CodeCompletion::NamespaceCompletionKind) {
|
||||||
|
CompletionChunksToTextConverter converter;
|
||||||
|
|
||||||
|
converter.parseChunks(ccr.chunks()); // Appends "::" after name space name
|
||||||
|
|
||||||
|
textToBeInserted = converter.text();
|
||||||
} else if (!ccr.text().isEmpty()) {
|
} else if (!ccr.text().isEmpty()) {
|
||||||
const TextEditor::CompletionSettings &completionSettings =
|
const TextEditor::CompletionSettings &completionSettings =
|
||||||
TextEditor::TextEditorSettings::instance()->completionSettings();
|
TextEditor::TextEditorSettings::instance()->completionSettings();
|
||||||
|
@@ -53,6 +53,7 @@ protected:
|
|||||||
CodeCompletionChunk templateResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("Foo<int>")};
|
CodeCompletionChunk templateResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("Foo<int>")};
|
||||||
CodeCompletionChunk enumerationResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("Enumeration")};
|
CodeCompletionChunk enumerationResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("Enumeration")};
|
||||||
CodeCompletionChunk functionName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Function")};
|
CodeCompletionChunk functionName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Function")};
|
||||||
|
CodeCompletionChunk namespaceName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Namespace")};
|
||||||
CodeCompletionChunk variableName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Variable")};
|
CodeCompletionChunk variableName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Variable")};
|
||||||
CodeCompletionChunk enumeratorName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Enumerator")};
|
CodeCompletionChunk enumeratorName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Enumerator")};
|
||||||
CodeCompletionChunk enumerationName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Enumeration")};
|
CodeCompletionChunk enumerationName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Enumeration")};
|
||||||
@@ -61,6 +62,7 @@ protected:
|
|||||||
CodeCompletionChunk rightParen{CodeCompletionChunk::RightParen, Utf8StringLiteral(")")};
|
CodeCompletionChunk rightParen{CodeCompletionChunk::RightParen, Utf8StringLiteral(")")};
|
||||||
CodeCompletionChunk comma{CodeCompletionChunk::Comma, Utf8StringLiteral(", ")};
|
CodeCompletionChunk comma{CodeCompletionChunk::Comma, Utf8StringLiteral(", ")};
|
||||||
CodeCompletionChunk semicolon{CodeCompletionChunk::SemiColon, Utf8StringLiteral(";")};
|
CodeCompletionChunk semicolon{CodeCompletionChunk::SemiColon, Utf8StringLiteral(";")};
|
||||||
|
CodeCompletionChunk colonColonText{CodeCompletionChunk::Text, Utf8StringLiteral("::")};
|
||||||
CodeCompletionChunk functionArgumentX{CodeCompletionChunk::Placeholder, Utf8StringLiteral("char x")};
|
CodeCompletionChunk functionArgumentX{CodeCompletionChunk::Placeholder, Utf8StringLiteral("char x")};
|
||||||
CodeCompletionChunk functionArgumentY{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int y")};
|
CodeCompletionChunk functionArgumentY{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int y")};
|
||||||
CodeCompletionChunk functionArgumentZ{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int z")};
|
CodeCompletionChunk functionArgumentZ{CodeCompletionChunk::Placeholder, Utf8StringLiteral("int z")};
|
||||||
@@ -355,4 +357,13 @@ TEST_F(CompletionChunksToTextConverter, EnableIfT)
|
|||||||
ASSERT_THAT(converter.text(), QStringLiteral("enable_if_t<>"));
|
ASSERT_THAT(converter.text(), QStringLiteral("enable_if_t<>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(CompletionChunksToTextConverter, Namespace)
|
||||||
|
{
|
||||||
|
CodeCompletionChunks completionChunks({namespaceName, colonColonText});
|
||||||
|
|
||||||
|
converter.parseChunks(completionChunks);
|
||||||
|
|
||||||
|
ASSERT_THAT(converter.text(), QStringLiteral("Namespace::"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user