ClangSupport: Use simpler structures in some cases

The patch is mostly mechanical, but contains also a few spurious changes
from values references for some local variables, foreach -> ranged for
etc that I coulnd't resist.

Change-Id: I58f0bd972546895eb318607cbfbd7ac35caf3f23
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
hjk
2018-04-04 18:25:23 +02:00
parent 4a0bbed560
commit cf4dbb4bb6
150 changed files with 1814 additions and 2598 deletions

View File

@@ -174,8 +174,8 @@ void CompletionChunksToTextConverter::parse(
{
using ClangBackEnd::CodeCompletionChunk;
switch (codeCompletionChunk.kind()) {
case CodeCompletionChunk::ResultType: parseResultType(codeCompletionChunk.text()); break;
switch (codeCompletionChunk.kind) {
case CodeCompletionChunk::ResultType: parseResultType(codeCompletionChunk.text); break;
// Do not rely on CurrentParameter because it might be wrong for
// invalid code. Instead, handle it as PlaceHolder.
case CodeCompletionChunk::CurrentParameter:
@@ -183,7 +183,7 @@ void CompletionChunksToTextConverter::parse(
parsePlaceHolder(codeCompletionChunk); break;
case CodeCompletionChunk::LeftParen: parseLeftParen(codeCompletionChunk); break;
case CodeCompletionChunk::LeftBrace: parseLeftBrace(codeCompletionChunk); break;
default: parseText(codeCompletionChunk.text()); break;
default: parseText(codeCompletionChunk.text); break;
}
}
@@ -205,7 +205,7 @@ void CompletionChunksToTextConverter::parseResultType(const Utf8String &resultTy
void CompletionChunksToTextConverter::parseText(const Utf8String &text)
{
if (canAddSpace()
&& m_previousCodeCompletionChunk.kind() == ClangBackEnd::CodeCompletionChunk::RightBrace) {
&& m_previousCodeCompletionChunk.kind == ClangBackEnd::CodeCompletionChunk::RightBrace) {
m_text += QChar(QChar::Space);
}
@@ -217,9 +217,9 @@ void CompletionChunksToTextConverter::wrapInCursiveTagIfOptional(
{
if (m_addOptional) {
if (m_emphasizeOptional && m_textFormat == TextFormat::Html) {
if (!m_previousCodeCompletionChunk.isOptional() && codeCompletionChunk.isOptional())
if (!m_previousCodeCompletionChunk.isOptional && codeCompletionChunk.isOptional)
m_text += QStringLiteral("<i>");
else if (m_previousCodeCompletionChunk.isOptional() && !codeCompletionChunk.isOptional())
else if (m_previousCodeCompletionChunk.isOptional && !codeCompletionChunk.isOptional)
m_text += QStringLiteral("</i>");
}
}
@@ -229,7 +229,7 @@ void CompletionChunksToTextConverter::parsePlaceHolder(
const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk)
{
if (m_addPlaceHolderText) {
appendText(inDesiredTextFormat(codeCompletionChunk.text()),
appendText(inDesiredTextFormat(codeCompletionChunk.text),
emphasizeCurrentPlaceHolder());
}
@@ -242,7 +242,7 @@ void CompletionChunksToTextConverter::parseLeftParen(
{
if (canAddSpace())
m_text += QChar(QChar::Space);
m_text += codeCompletionChunk.text().toString();
m_text += codeCompletionChunk.text.toString();
}
void CompletionChunksToTextConverter::parseLeftBrace(
@@ -251,7 +251,7 @@ void CompletionChunksToTextConverter::parseLeftBrace(
if (canAddSpace())
m_text += QChar(QChar::Space);
m_text += codeCompletionChunk.text().toString();
m_text += codeCompletionChunk.text.toString();
}
void CompletionChunksToTextConverter::addExtraVerticalSpaceBetweenBraces()
@@ -266,15 +266,15 @@ void CompletionChunksToTextConverter::addExtraVerticalSpaceBetweenBraces(
using ClangBackEnd::CodeCompletionChunk;
const auto leftBraceCompare = [] (const CodeCompletionChunk &chunk) {
return chunk.kind() == CodeCompletionChunk::LeftBrace;
return chunk.kind == CodeCompletionChunk::LeftBrace;
};
const auto rightBraceCompare = [] (const CodeCompletionChunk &chunk) {
return chunk.kind() == CodeCompletionChunk::RightBrace;
return chunk.kind == CodeCompletionChunk::RightBrace;
};
const auto verticalSpaceCompare = [] (const CodeCompletionChunk &chunk) {
return chunk.kind() == CodeCompletionChunk::VerticalSpace;
return chunk.kind == CodeCompletionChunk::VerticalSpace;
};
auto leftBrace = std::find_if(begin, m_codeCompletionChunks.end(), leftBraceCompare);
@@ -337,15 +337,15 @@ void CompletionChunksToTextConverter::appendText(const QString &text, bool boldF
bool CompletionChunksToTextConverter::canAddSpace() const
{
return m_addSpaces
&& m_previousCodeCompletionChunk.kind() != ClangBackEnd::CodeCompletionChunk::HorizontalSpace
&& m_previousCodeCompletionChunk.kind() != ClangBackEnd::CodeCompletionChunk::RightAngle
&& m_previousCodeCompletionChunk.kind != ClangBackEnd::CodeCompletionChunk::HorizontalSpace
&& m_previousCodeCompletionChunk.kind != ClangBackEnd::CodeCompletionChunk::RightAngle
&& m_codeCompletionKind != ClangBackEnd::CodeCompletion::FunctionCompletionKind;
}
bool CompletionChunksToTextConverter::isNotOptionalOrAddOptionals(
const ClangBackEnd::CodeCompletionChunk &codeCompletionChunk) const
{
return !codeCompletionChunk.isOptional() || m_addOptional;
return !codeCompletionChunk.isOptional || m_addOptional;
}
} // namespace Internal