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

@@ -182,56 +182,56 @@ void BackendReceiver::echo(const EchoMessage &message)
void BackendReceiver::codeCompleted(const CodeCompletedMessage &message)
{
qCDebugIpc() << "CodeCompletedMessage with" << message.codeCompletions().size()
qCDebugIpc() << "CodeCompletedMessage with" << message.codeCompletions.size()
<< "items";
const quint64 ticket = message.ticketNumber();
const quint64 ticket = message.ticketNumber;
QScopedPointer<ClangCompletionAssistProcessor> processor(m_assistProcessorsTable.take(ticket));
if (processor) {
processor->handleAvailableCompletions(message.codeCompletions(),
message.neededCorrection());
processor->handleAvailableCompletions(message.codeCompletions,
message.neededCorrection);
}
}
void BackendReceiver::documentAnnotationsChanged(const DocumentAnnotationsChangedMessage &message)
{
qCDebugIpc() << "DocumentAnnotationsChangedMessage with"
<< message.diagnostics().size() << "diagnostics"
<< message.tokenInfos().size() << "highlighting marks"
<< message.skippedPreprocessorRanges().size() << "skipped preprocessor ranges";
<< message.diagnostics.size() << "diagnostics"
<< message.tokenInfos.size() << "highlighting marks"
<< message.skippedPreprocessorRanges.size() << "skipped preprocessor ranges";
auto processor = ClangEditorDocumentProcessor::get(message.fileContainer().filePath());
auto processor = ClangEditorDocumentProcessor::get(message.fileContainer.filePath);
if (!processor)
return;
const QString projectPartId = message.fileContainer().projectPartId();
const QString filePath = message.fileContainer().filePath();
const QString projectPartId = message.fileContainer.projectPartId;
const QString filePath = message.fileContainer.filePath;
const QString documentProjectPartId = CppTools::CppToolsBridge::projectPartIdForFile(filePath);
if (projectPartId != documentProjectPartId)
return;
const quint32 documentRevision = message.fileContainer().documentRevision();
if (message.onlyTokenInfos()) {
processor->updateTokenInfos(message.tokenInfos(), documentRevision);
const quint32 documentRevision = message.fileContainer.documentRevision;
if (message.onlyTokenInfos) {
processor->updateTokenInfos(message.tokenInfos, documentRevision);
return;
}
processor->updateCodeWarnings(message.diagnostics(),
message.firstHeaderErrorDiagnostic(),
processor->updateCodeWarnings(message.diagnostics,
message.firstHeaderErrorDiagnostic,
documentRevision);
processor->updateHighlighting(message.tokenInfos(),
message.skippedPreprocessorRanges(),
processor->updateHighlighting(message.tokenInfos,
message.skippedPreprocessorRanges,
documentRevision);
}
static
CppTools::CursorInfo::Range toCursorInfoRange(const SourceRangeContainer &sourceRange)
{
const SourceLocationContainer start = sourceRange.start();
const SourceLocationContainer end = sourceRange.end();
const unsigned length = end.column() - start.column();
const SourceLocationContainer &start = sourceRange.start;
const SourceLocationContainer &end = sourceRange.end;
const unsigned length = end.column - start.column;
return CppTools::CursorInfo::Range(start.line(), start.column(), length);
return CppTools::CursorInfo::Range(start.line, start.column, length);
}
static
@@ -239,9 +239,9 @@ CppTools::CursorInfo toCursorInfo(const CppTools::SemanticInfo::LocalUseMap &loc
const ReferencesMessage &message)
{
CppTools::CursorInfo result;
const QVector<SourceRangeContainer> references = message.references();
const QVector<SourceRangeContainer> &references = message.references;
result.areUseRangesForLocalVariable = message.isLocalVariable();
result.areUseRangesForLocalVariable = message.isLocalVariable;
for (const SourceRangeContainer &reference : references)
result.useRanges.append(toCursorInfoRange(reference));
@@ -255,15 +255,15 @@ static
CppTools::SymbolInfo toSymbolInfo(const FollowSymbolMessage &message)
{
CppTools::SymbolInfo result;
const SourceRangeContainer &range = message.sourceRange();
const SourceRangeContainer &range = message.sourceRange;
const SourceLocationContainer start = range.start();
const SourceLocationContainer end = range.end();
result.startLine = static_cast<int>(start.line());
result.startColumn = static_cast<int>(start.column());
result.endLine = static_cast<int>(end.line());
result.endColumn = static_cast<int>(end.column());
result.fileName = start.filePath();
const SourceLocationContainer &start = range.start;
const SourceLocationContainer &end = range.end;
result.startLine = static_cast<int>(start.line);
result.startColumn = static_cast<int>(start.column);
result.endLine = static_cast<int>(end.line);
result.endColumn = static_cast<int>(end.column);
result.fileName = start.filePath;
return result;
}
@@ -271,9 +271,9 @@ CppTools::SymbolInfo toSymbolInfo(const FollowSymbolMessage &message)
void BackendReceiver::references(const ReferencesMessage &message)
{
qCDebugIpc() << "ReferencesMessage with"
<< message.references().size() << "references";
<< message.references.size() << "references";
const quint64 ticket = message.ticketNumber();
const quint64 ticket = message.ticketNumber;
const ReferencesEntry entry = m_referencesTable.take(ticket);
QFutureInterface<CppTools::CursorInfo> futureInterface = entry.futureInterface;
QTC_CHECK(futureInterface != QFutureInterface<CppTools::CursorInfo>());
@@ -322,25 +322,25 @@ static CppTools::ToolTipInfo toToolTipInfo(const ToolTipMessage &message)
{
CppTools::ToolTipInfo info;
const ToolTipInfo backendInfo = message.toolTipInfo();
const ToolTipInfo &backendInfo = message.toolTipInfo;
info.text = backendInfo.text();
info.briefComment = backendInfo.briefComment();
info.text = backendInfo.text;
info.briefComment = backendInfo.briefComment;
info.qDocIdCandidates = toStringList(backendInfo.qdocIdCandidates());
info.qDocMark = backendInfo.qdocMark();
info.qDocCategory = toHelpItemCategory(backendInfo.qdocCategory());
info.qDocIdCandidates = toStringList(backendInfo.qdocIdCandidates);
info.qDocMark = backendInfo.qdocMark;
info.qDocCategory = toHelpItemCategory(backendInfo.qdocCategory);
info.sizeInBytes = backendInfo.sizeInBytes();
info.sizeInBytes = backendInfo.sizeInBytes;
return info;
}
void BackendReceiver::tooltip(const ToolTipMessage &message)
{
qCDebugIpc() << "ToolTipMessage" << message.toolTipInfo().text();
qCDebugIpc() << "ToolTipMessage" << message.toolTipInfo.text;
const quint64 ticket = message.ticketNumber();
const quint64 ticket = message.ticketNumber;
QFutureInterface<CppTools::ToolTipInfo> futureInterface = m_toolTipsTable.take(ticket);
QTC_CHECK(futureInterface != QFutureInterface<CppTools::ToolTipInfo>());
@@ -354,9 +354,9 @@ void BackendReceiver::tooltip(const ToolTipMessage &message)
void BackendReceiver::followSymbol(const ClangBackEnd::FollowSymbolMessage &message)
{
qCDebugIpc() << "FollowSymbolMessage with"
<< message.sourceRange() << "range";
<< message.sourceRange << "range";
const quint64 ticket = message.ticketNumber();
const quint64 ticket = message.ticketNumber;
QFutureInterface<CppTools::SymbolInfo> futureInterface = m_followTable.take(ticket);
QTC_CHECK(futureInterface != QFutureInterface<CppTools::SymbolInfo>());