Commit a071e52b authored by Nikolai Kosjar's avatar Nikolai Kosjar

Clang: Extract duplicate code

Change-Id: I476916f825ab475f77f918127217dfc33eb4f388
Reviewed-by: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent 1a6b62a2
......@@ -104,9 +104,7 @@ void ClangAssistProposalItem::applyContextualContent(TextEditor::TextEditorWidge
}
} else if (ccr.completionKind() == CodeCompletion::KeywordCompletionKind) {
CompletionChunksToTextConverter converter;
converter.setAddPlaceHolderPositions(true);
converter.setAddSpaces(true);
converter.setAddExtraVerticalSpaceBetweenBraces(true);
converter.setupForKeywords();
converter.parseChunks(ccr.chunks());
......
......@@ -96,6 +96,13 @@ void CompletionChunksToTextConverter::setPlaceHolderToEmphasize(int placeHolderN
m_placeHolderPositionToEmphasize = placeHolderNumber;
}
void CompletionChunksToTextConverter::setupForKeywords()
{
setAddPlaceHolderPositions(true);
setAddSpaces(true);
setAddExtraVerticalSpaceBetweenBraces(true);
}
const QString &CompletionChunksToTextConverter::text() const
{
return m_text;
......
......@@ -56,6 +56,8 @@ public:
void setAddOptional(bool addOptional);
void setPlaceHolderToEmphasize(int placeHolderNumber);
void setupForKeywords();
const QString &text() const;
const std::vector<int> &placeholderPositions() const;
bool hasPlaceholderPositions() const;
......
......@@ -269,7 +269,7 @@ TEST_F(CompletionChunksToTextConverter, Switch)
leftBrace,
verticalSpace,
rightBrace});
setupConverterForKeywords();
converter.setupForKeywords();
converter.parseChunks(completionChunks);
......@@ -292,7 +292,7 @@ TEST_F(CompletionChunksToTextConverter, For)
statements,
verticalSpace,
rightBrace});
setupConverterForKeywords();
converter.setupForKeywords();
converter.parseChunks(completionChunks);
......@@ -306,7 +306,7 @@ TEST_F(CompletionChunksToTextConverter, const_cast)
rightAngle,
leftParen,
rightParen});
setupConverterForKeywords();
converter.setupForKeywords();
converter.parseChunks(completionChunks);
......@@ -333,7 +333,7 @@ TEST_F(CompletionChunksToTextConverter, ElseIf)
statements,
verticalSpace,
rightBrace});
setupConverterForKeywords();
converter.setupForKeywords();
converter.parseChunks(completionChunks);
......@@ -348,17 +348,11 @@ TEST_F(CompletionChunksToTextConverter, EnableIfT)
optionalComma,
optionalEnableIfTType,
rightAngle});
setupConverterForKeywords();
converter.setupForKeywords();
converter.parseChunks(completionChunks);
ASSERT_THAT(converter.text(), QStringLiteral("enable_if_t&lt;&gt;"));
}
void CompletionChunksToTextConverter::setupConverterForKeywords()
{
converter.setAddPlaceHolderPositions(true);
converter.setAddSpaces(true);
converter.setAddExtraVerticalSpaceBetweenBraces(true);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment