forked from qt-creator/qt-creator
Clang: Fix displaying template parameters II
...in the function call completion tooltip. Task-number: QTCREATORBUG-15286 Change-Id: Ie24576f98ee4ba8f954de394f3596093323a2c35 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
@@ -182,7 +182,7 @@ void CompletionChunksToTextConverter::parseDependendOnTheOptionalState(
|
||||
void CompletionChunksToTextConverter::parseResultType(const Utf8String &resultTypeText)
|
||||
{
|
||||
if (m_addResultType)
|
||||
m_text += resultTypeText.toString() + QChar(QChar::Space);
|
||||
m_text += resultTypeText.toString().toHtmlEscaped() + QChar(QChar::Space);
|
||||
}
|
||||
|
||||
void CompletionChunksToTextConverter::parseText(const Utf8String &text)
|
||||
@@ -192,7 +192,7 @@ void CompletionChunksToTextConverter::parseText(const Utf8String &text)
|
||||
m_text += QChar(QChar::Space);
|
||||
}
|
||||
|
||||
m_text += text.toString();
|
||||
m_text += text.toString().toHtmlEscaped();
|
||||
}
|
||||
|
||||
void CompletionChunksToTextConverter::wrapInCursiveTagIfOptional(
|
||||
@@ -211,8 +211,10 @@ void CompletionChunksToTextConverter::wrapInCursiveTagIfOptional(
|
||||
void CompletionChunksToTextConverter::parsePlaceHolder(
|
||||
const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
|
||||
{
|
||||
if (m_addPlaceHolderText)
|
||||
appendText(codeCompletionChunk.text().toString(), emphasizeCurrentPlaceHolder());
|
||||
if (m_addPlaceHolderText) {
|
||||
appendText(codeCompletionChunk.text().toString().toHtmlEscaped(),
|
||||
emphasizeCurrentPlaceHolder());
|
||||
}
|
||||
|
||||
if (m_addPlaceHolderPositions)
|
||||
m_placeholderPositions.push_back(m_text.size());
|
||||
|
@@ -961,11 +961,11 @@ void ClangCodeCompletionTest::testCompleteFunctions()
|
||||
|
||||
QVERIFY(hasItem(t.proposal, "void f()"));
|
||||
QVERIFY(hasItem(t.proposal, "void f(int a)"));
|
||||
QVERIFY(hasItem(t.proposal, "void f(const QString &s)"));
|
||||
QVERIFY(hasItem(t.proposal, "void f(const QString &s)"));
|
||||
QVERIFY(hasItem(t.proposal, "void f(char c<i>, int optional</i>)")); // TODO: No default argument?
|
||||
QVERIFY(hasItem(t.proposal, "void f(char c<i>, int optional1, int optional2</i>)")); // TODO: No default argument?
|
||||
QVERIFY(hasItem(t.proposal, "void f(const TType<QString> *t)"));
|
||||
QVERIFY(hasItem(t.proposal, "TType<QString> f(bool)"));
|
||||
QVERIFY(hasItem(t.proposal, "void f(const TType<QString> *t)"));
|
||||
QVERIFY(hasItem(t.proposal, "TType<QString> f(bool)"));
|
||||
}
|
||||
|
||||
void ClangCodeCompletionTest::testCompleteConstructorAndFallbackToGlobalCompletion()
|
||||
|
@@ -50,6 +50,7 @@ protected:
|
||||
protected:
|
||||
Converter converter;
|
||||
CodeCompletionChunk integerResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("int")};
|
||||
CodeCompletionChunk templateResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("Foo<int>")};
|
||||
CodeCompletionChunk enumerationResultType{CodeCompletionChunk::ResultType, Utf8StringLiteral("Enumeration")};
|
||||
CodeCompletionChunk functionName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Function")};
|
||||
CodeCompletionChunk variableName{CodeCompletionChunk::TypedText, Utf8StringLiteral("Variable")};
|
||||
@@ -63,6 +64,7 @@ protected:
|
||||
CodeCompletionChunk functionArgumentX{CodeCompletionChunk::Placeholder, Utf8StringLiteral("char x")};
|
||||
CodeCompletionChunk functionArgumentY{CodeCompletionChunk::Placeholder, 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")};
|
||||
CodeCompletionChunk condition{CodeCompletionChunk::Placeholder, Utf8StringLiteral("condition")};
|
||||
CodeCompletionChunk leftBrace{CodeCompletionChunk::LeftBrace, Utf8StringLiteral("{")};
|
||||
@@ -185,6 +187,34 @@ TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithTwoParamet
|
||||
QStringLiteral("int Function(char x<i>, <b>int y</b></i>)"));
|
||||
}
|
||||
|
||||
TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithTemplateReturnType)
|
||||
{
|
||||
CodeCompletionChunks completionChunks({templateResultType,
|
||||
functionName,
|
||||
leftParen,
|
||||
functionArgumentX,
|
||||
rightParen});
|
||||
|
||||
using ClangCodeModel::Internal::CompletionChunksToTextConverter;
|
||||
|
||||
ASSERT_THAT(CompletionChunksToTextConverter::convertToFunctionSignature(completionChunks),
|
||||
QStringLiteral("Foo<int> Function(char x)"));
|
||||
}
|
||||
|
||||
TEST_F(CompletionChunksToTextConverter, ConvertToFunctionSignatureWithTemplateArgument)
|
||||
{
|
||||
CodeCompletionChunks completionChunks({integerResultType,
|
||||
functionName,
|
||||
leftParen,
|
||||
functionArgumentTemplate,
|
||||
rightParen});
|
||||
|
||||
using ClangCodeModel::Internal::CompletionChunksToTextConverter;
|
||||
|
||||
ASSERT_THAT(CompletionChunksToTextConverter::convertToFunctionSignature(completionChunks),
|
||||
QStringLiteral("int Function(const Foo<int> &foo)"));
|
||||
}
|
||||
|
||||
TEST_F(CompletionChunksToTextConverter, ConvertFunctionWithOptionalParameter)
|
||||
{
|
||||
CodeCompletionChunks completionChunks({integerResultType,
|
||||
@@ -280,7 +310,7 @@ TEST_F(CompletionChunksToTextConverter, const_cast)
|
||||
|
||||
converter.parseChunks(completionChunks);
|
||||
|
||||
ASSERT_THAT(converter.text(), QStringLiteral("const_cast<>()"));
|
||||
ASSERT_THAT(converter.text(), QStringLiteral("const_cast<>()"));
|
||||
}
|
||||
|
||||
TEST_F(CompletionChunksToTextConverter, Throw)
|
||||
@@ -322,7 +352,7 @@ TEST_F(CompletionChunksToTextConverter, EnableIfT)
|
||||
|
||||
converter.parseChunks(completionChunks);
|
||||
|
||||
ASSERT_THAT(converter.text(), QStringLiteral("enable_if_t<>"));
|
||||
ASSERT_THAT(converter.text(), QStringLiteral("enable_if_t<>"));
|
||||
}
|
||||
|
||||
void CompletionChunksToTextConverter::setupConverterForKeywords()
|
||||
|
Reference in New Issue
Block a user