forked from qt-creator/qt-creator
Clang: Add clang query pane
We now support highlighting for an example text and for the query. Change-Id: I88c415ff871cf3e4c2d4fc83d60a8555bf0ce08a Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -29,10 +29,7 @@
|
||||
#include "clangquery.h"
|
||||
|
||||
#include <refactoringclientinterface.h>
|
||||
#include <requestsourcelocationforrenamingmessage.h>
|
||||
#include <requestsourcerangesanddiagnosticsforquerymessage.h>
|
||||
#include <sourcelocationsforrenamingmessage.h>
|
||||
#include <sourcerangesanddiagnosticsforquerymessage.h>
|
||||
#include <clangrefactoringmessages.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
@@ -47,7 +44,7 @@ RefactoringServer::RefactoringServer()
|
||||
|
||||
QObject::connect(&m_pollTimer,
|
||||
&QTimer::timeout,
|
||||
std::bind(&RefactoringServer::pollSourceRangesAndDiagnosticsForQueryMessages, this));
|
||||
std::bind(&RefactoringServer::pollSourceRangesForQueryMessages, this));
|
||||
}
|
||||
|
||||
void RefactoringServer::end()
|
||||
@@ -74,7 +71,22 @@ void RefactoringServer::requestSourceLocationsForRenamingMessage(RequestSourceLo
|
||||
void RefactoringServer::requestSourceRangesAndDiagnosticsForQueryMessage(
|
||||
RequestSourceRangesAndDiagnosticsForQueryMessage &&message)
|
||||
{
|
||||
gatherSourceRangesAndDiagnosticsForQueryMessages(message.takeSources(),
|
||||
ClangQuery clangQuery(m_filePathCache, message.takeQuery());
|
||||
|
||||
clangQuery.addFile(message.source().filePath().directory(),
|
||||
message.source().filePath().name(),
|
||||
message.source().unsavedFileContent(),
|
||||
message.source().commandLineArguments());
|
||||
|
||||
clangQuery.findLocations();
|
||||
|
||||
client()->sourceRangesAndDiagnosticsForQueryMessage({clangQuery.takeSourceRanges(),
|
||||
clangQuery.takeDiagnosticContainers()});
|
||||
}
|
||||
|
||||
void RefactoringServer::requestSourceRangesForQueryMessage(RequestSourceRangesForQueryMessage &&message)
|
||||
{
|
||||
gatherSourceRangesForQueryMessages(message.takeSources(),
|
||||
message.takeUnsavedContent(),
|
||||
message.takeQuery());
|
||||
}
|
||||
@@ -91,22 +103,22 @@ bool RefactoringServer::isCancelingJobs() const
|
||||
return m_gatherer.isFinished();
|
||||
}
|
||||
|
||||
void RefactoringServer::pollSourceRangesAndDiagnosticsForQueryMessages()
|
||||
void RefactoringServer::pollSourceRangesForQueryMessages()
|
||||
{
|
||||
for (auto &&message : m_gatherer.finishedMessages())
|
||||
client()->sourceRangesAndDiagnosticsForQueryMessage(std::move(message));
|
||||
client()->sourceRangesForQueryMessage(std::move(message));
|
||||
|
||||
if (!m_gatherer.isFinished())
|
||||
m_gatherer.startCreateNextSourceRangesAndDiagnosticsMessages();
|
||||
m_gatherer.startCreateNextSourceRangesMessages();
|
||||
else
|
||||
m_pollTimer.stop();
|
||||
}
|
||||
|
||||
void RefactoringServer::waitThatSourceRangesAndDiagnosticsForQueryMessagesAreFinished()
|
||||
void RefactoringServer::waitThatSourceRangesForQueryMessagesAreFinished()
|
||||
{
|
||||
while (!m_gatherer.isFinished()) {
|
||||
m_gatherer.waitForFinished();
|
||||
pollSourceRangesAndDiagnosticsForQueryMessages();
|
||||
pollSourceRangesForQueryMessages();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +132,7 @@ void RefactoringServer::setGathererProcessingSlotCount(uint count)
|
||||
m_gatherer.setProcessingSlotCount(count);
|
||||
}
|
||||
|
||||
void RefactoringServer::gatherSourceRangesAndDiagnosticsForQueryMessages(
|
||||
void RefactoringServer::gatherSourceRangesForQueryMessages(
|
||||
std::vector<V2::FileContainer> &&sources,
|
||||
std::vector<V2::FileContainer> &&unsaved,
|
||||
Utils::SmallString &&query)
|
||||
|
||||
Reference in New Issue
Block a user