forked from qt-creator/qt-creator
Clang: Clean up clangbackendipcintegration.cpp
Change-Id: I60d7d2969d55499bc2ac5ddaf0127c60e8c76a7a Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -83,16 +83,19 @@ using namespace ClangCodeModel::Internal;
|
|||||||
using namespace ClangBackEnd;
|
using namespace ClangBackEnd;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
|
|
||||||
namespace {
|
static QString backendProcessPath()
|
||||||
|
|
||||||
QString backendProcessPath()
|
|
||||||
{
|
{
|
||||||
return Core::ICore::libexecPath()
|
return Core::ICore::libexecPath()
|
||||||
+ QStringLiteral("/clangbackend")
|
+ QStringLiteral("/clangbackend")
|
||||||
+ QStringLiteral(QTC_HOST_EXE_SUFFIX);
|
+ QStringLiteral(QTC_HOST_EXE_SUFFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool printAliveMessageHelper()
|
static CppTools::CppEditorDocumentHandle *cppDocument(const QString &filePath)
|
||||||
|
{
|
||||||
|
return CppTools::CppModelManager::instance()->cppEditorDocument(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool printAliveMessageHelper()
|
||||||
{
|
{
|
||||||
const bool print = qEnvironmentVariableIntValue("QTC_CLANG_FORCE_VERBOSE_ALIVE");
|
const bool print = qEnvironmentVariableIntValue("QTC_CLANG_FORCE_VERBOSE_ALIVE");
|
||||||
if (!print) {
|
if (!print) {
|
||||||
@@ -103,14 +106,12 @@ bool printAliveMessageHelper()
|
|||||||
return print;
|
return print;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool printAliveMessage()
|
static bool printAliveMessage()
|
||||||
{
|
{
|
||||||
static bool print = log().isDebugEnabled() ? printAliveMessageHelper() : false;
|
static bool print = log().isDebugEnabled() ? printAliveMessageHelper() : false;
|
||||||
return print;
|
return print;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
IpcReceiver::IpcReceiver()
|
IpcReceiver::IpcReceiver()
|
||||||
: m_printAliveMessage(printAliveMessage())
|
: m_printAliveMessage(printAliveMessage())
|
||||||
{
|
{
|
||||||
@@ -539,43 +540,21 @@ void IpcCommunicator::registerProjectsParts(const QList<CppTools::ProjectPart::P
|
|||||||
|
|
||||||
void IpcCommunicator::updateTranslationUnitFromCppEditorDocument(const QString &filePath)
|
void IpcCommunicator::updateTranslationUnitFromCppEditorDocument(const QString &filePath)
|
||||||
{
|
{
|
||||||
const auto document = CppTools::CppModelManager::instance()->cppEditorDocument(filePath);
|
const CppTools::CppEditorDocumentHandle *document = cppDocument(filePath);
|
||||||
|
|
||||||
updateTranslationUnit(filePath, document->contents(), document->revision());
|
updateTranslationUnit(filePath, document->contents(), document->revision());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcCommunicator::updateUnsavedFileFromCppEditorDocument(const QString &filePath)
|
void IpcCommunicator::updateUnsavedFileFromCppEditorDocument(const QString &filePath)
|
||||||
{
|
{
|
||||||
const auto document = CppTools::CppModelManager::instance()->cppEditorDocument(filePath);
|
const CppTools::CppEditorDocumentHandle *document = cppDocument(filePath);
|
||||||
|
|
||||||
updateUnsavedFile(filePath, document->contents(), document->revision());
|
updateUnsavedFile(filePath, document->contents(), document->revision());
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
CppTools::CppEditorDocumentHandle *cppDocument(const QString &filePath)
|
|
||||||
{
|
|
||||||
return CppTools::CppModelManager::instance()->cppEditorDocument(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool documentHasChanged(const QString &filePath,
|
|
||||||
uint revision)
|
|
||||||
{
|
|
||||||
auto *document = cppDocument(filePath);
|
|
||||||
|
|
||||||
if (document)
|
|
||||||
return document->sendTracker().shouldSendRevision(revision);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLastSentDocumentRevision(const QString &filePath,
|
|
||||||
uint revision)
|
|
||||||
{
|
|
||||||
auto *document = cppDocument(filePath);
|
|
||||||
|
|
||||||
if (document)
|
|
||||||
document->sendTracker().setLastSentRevision(int(revision));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IpcCommunicator::updateTranslationUnit(const QString &filePath,
|
void IpcCommunicator::updateTranslationUnit(const QString &filePath,
|
||||||
@@ -603,6 +582,20 @@ void IpcCommunicator::updateUnsavedFile(const QString &filePath, const QByteArra
|
|||||||
documentRevision}});
|
documentRevision}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool documentHasChanged(const QString &filePath, uint revision)
|
||||||
|
{
|
||||||
|
if (CppTools::CppEditorDocumentHandle *document = cppDocument(filePath))
|
||||||
|
return document->sendTracker().shouldSendRevision(revision);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setLastSentDocumentRevision(const QString &filePath, uint revision)
|
||||||
|
{
|
||||||
|
if (CppTools::CppEditorDocumentHandle *document = cppDocument(filePath))
|
||||||
|
document->sendTracker().setLastSentRevision(int(revision));
|
||||||
|
}
|
||||||
|
|
||||||
void IpcCommunicator::updateTranslationUnitWithRevisionCheck(const FileContainer &fileContainer)
|
void IpcCommunicator::updateTranslationUnitWithRevisionCheck(const FileContainer &fileContainer)
|
||||||
{
|
{
|
||||||
if (documentHasChanged(fileContainer.filePath(), fileContainer.documentRevision())) {
|
if (documentHasChanged(fileContainer.filePath(), fileContainer.documentRevision())) {
|
||||||
@@ -632,9 +625,7 @@ void IpcCommunicator::updateTranslationUnitWithRevisionCheck(Core::IDocument *do
|
|||||||
|
|
||||||
void IpcCommunicator::updateChangeContentStartPosition(const QString &filePath, int position)
|
void IpcCommunicator::updateChangeContentStartPosition(const QString &filePath, int position)
|
||||||
{
|
{
|
||||||
auto *document = cppDocument(filePath);
|
if (CppTools::CppEditorDocumentHandle *document = cppDocument(filePath))
|
||||||
|
|
||||||
if (document)
|
|
||||||
document->sendTracker().applyContentChange(position);
|
document->sendTracker().applyContentChange(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user