forked from qt-creator/qt-creator
Clang: Reparse only if files are changed
Includes are now watched by a file watcher. Unsaved file changes are watched too. If they are changed the translation units which depend on them are set to a state which require a reparse. Later the diagnostics of this units are collected and send back to creator. Change-Id: I2fb5c7dd6644687f22399edd8d18edd6215c9505 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -167,7 +167,7 @@ void IpcReceiver::diagnosticsChanged(const DiagnosticsChangedMessage &message)
|
||||
const QString diagnosticsProjectPartId = message.file().projectPartId();
|
||||
const QString documentProjectPartId = processor->projectPart()->id();
|
||||
if (diagnosticsProjectPartId == documentProjectPartId)
|
||||
processor->updateCodeWarnings(message.diagnostics(), message.documentRevision());
|
||||
processor->updateCodeWarnings(message.diagnostics(), message.file().documentRevision());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ void IpcCommunicator::registerCurrrentCodeModelUiHeaders()
|
||||
|
||||
const auto editorSupports = CppModelManager::instance()->abstractEditorSupports();
|
||||
foreach (const AbstractEditorSupport *es, editorSupports)
|
||||
updateUnsavedFile(es->fileName(), es->contents());
|
||||
updateUnsavedFile(es->fileName(), es->contents(), es->revision());
|
||||
}
|
||||
|
||||
static QStringList projectPartMessageLine(const CppTools::ProjectPart::Ptr &projectPart)
|
||||
@@ -355,12 +355,14 @@ void IpcCommunicator::registerProjectsParts(const QList<CppTools::ProjectPart::P
|
||||
|
||||
void IpcCommunicator::updateUnsavedFileFromCppEditorDocument(const QString &filePath)
|
||||
{
|
||||
const QByteArray unsavedContent = CppTools::CppModelManager::instance()
|
||||
->cppEditorDocument(filePath)->contents();
|
||||
updateUnsavedFile(filePath, unsavedContent);
|
||||
const auto document = CppTools::CppModelManager::instance()->cppEditorDocument(filePath);
|
||||
|
||||
updateUnsavedFile(filePath, document->contents(), document->revision());
|
||||
}
|
||||
|
||||
void IpcCommunicator::updateUnsavedFile(const QString &filePath, const QByteArray &contents)
|
||||
void IpcCommunicator::updateUnsavedFile(const QString &filePath,
|
||||
const QByteArray &contents,
|
||||
uint documentRevision)
|
||||
{
|
||||
const QString projectPartId = Utils::projectPartIdForFile(filePath);
|
||||
const bool hasUnsavedContent = true;
|
||||
@@ -369,13 +371,14 @@ void IpcCommunicator::updateUnsavedFile(const QString &filePath, const QByteArra
|
||||
registerFilesForCodeCompletion({{filePath,
|
||||
projectPartId,
|
||||
Utf8String::fromByteArray(contents),
|
||||
hasUnsavedContent}});
|
||||
hasUnsavedContent,
|
||||
documentRevision}});
|
||||
}
|
||||
|
||||
void IpcCommunicator::requestDiagnostics(const FileContainer &fileContainer, uint documentRevision)
|
||||
void IpcCommunicator::requestDiagnostics(const FileContainer &fileContainer)
|
||||
{
|
||||
registerFilesForCodeCompletion({fileContainer});
|
||||
m_ipcSender->requestDiagnostics({fileContainer, documentRevision});
|
||||
m_ipcSender->requestDiagnostics({fileContainer});
|
||||
}
|
||||
|
||||
void IpcCommunicator::updateUnsavedFileIfNotCurrentDocument(Core::IDocument *document)
|
||||
|
||||
@@ -128,8 +128,8 @@ public:
|
||||
|
||||
void updateUnsavedFileIfNotCurrentDocument(Core::IDocument *document);
|
||||
void updateUnsavedFileFromCppEditorDocument(const QString &filePath);
|
||||
void updateUnsavedFile(const QString &filePath, const QByteArray &contents);
|
||||
void requestDiagnostics(const ClangBackEnd::FileContainer &fileContainer, uint documentRevision);
|
||||
void updateUnsavedFile(const QString &filePath, const QByteArray &contents, uint documentRevision);
|
||||
void requestDiagnostics(const ClangBackEnd::FileContainer &fileContainer);
|
||||
|
||||
public: // for tests
|
||||
IpcSenderInterface *setIpcSender(IpcSenderInterface *ipcSender);
|
||||
|
||||
@@ -225,14 +225,20 @@ void ClangEditorDocumentProcessor::updateTranslationUnitForCompletion(CppTools::
|
||||
|
||||
if (m_projectPart) {
|
||||
if (projectPart.id() != m_projectPart->id()) {
|
||||
auto container1 = ClangBackEnd::FileContainer(filePath(), m_projectPart->id());
|
||||
auto container1 = ClangBackEnd::FileContainer(filePath(),
|
||||
m_projectPart->id(),
|
||||
revision());
|
||||
ipcCommunicator.unregisterFilesForCodeCompletion({container1});
|
||||
|
||||
auto container2 = ClangBackEnd::FileContainer(filePath(), projectPart.id());
|
||||
auto container2 = ClangBackEnd::FileContainer(filePath(),
|
||||
projectPart.id(),
|
||||
revision());
|
||||
ipcCommunicator.registerFilesForCodeCompletion({container2});
|
||||
}
|
||||
} else {
|
||||
auto container = ClangBackEnd::FileContainer(filePath(), projectPart.id());
|
||||
auto container = ClangBackEnd::FileContainer(filePath(),
|
||||
projectPart.id(),
|
||||
revision());
|
||||
ipcCommunicator.registerFilesForCodeCompletion({container});
|
||||
}
|
||||
}
|
||||
@@ -458,8 +464,11 @@ void ClangEditorDocumentProcessor::requestDiagnostics(CppTools::ProjectPart &pro
|
||||
if (!m_projectPart || projectPart.id() != m_projectPart->id()) {
|
||||
IpcCommunicator &ipcCommunicator = m_modelManagerSupport->ipcCommunicator();
|
||||
|
||||
ipcCommunicator.requestDiagnostics({filePath(), projectPart.id()},
|
||||
revision());
|
||||
ipcCommunicator.requestDiagnostics({filePath(),
|
||||
projectPart.id(),
|
||||
Utf8String(),
|
||||
false,
|
||||
revision()});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,10 +478,10 @@ void ClangEditorDocumentProcessor::requestDiagnostics()
|
||||
if (m_projectPart) {
|
||||
auto &ipcCommunicator = m_modelManagerSupport->ipcCommunicator();
|
||||
ipcCommunicator.requestDiagnostics({filePath(),
|
||||
m_projectPart->id(),
|
||||
baseTextDocument()->plainText(),
|
||||
true},
|
||||
revision());
|
||||
m_projectPart->id(),
|
||||
baseTextDocument()->plainText(),
|
||||
true,
|
||||
revision()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ void ModelManagerSupportClang::onAbstractEditorSupportContentsUpdated(const QStr
|
||||
const QByteArray &content)
|
||||
{
|
||||
QTC_ASSERT(!filePath.isEmpty(), return);
|
||||
m_ipcCommunicator.updateUnsavedFile(filePath, content);
|
||||
m_ipcCommunicator.updateUnsavedFile(filePath, content, 0);
|
||||
}
|
||||
|
||||
void ModelManagerSupportClang::onAbstractEditorSupportRemoved(const QString &filePath)
|
||||
|
||||
Reference in New Issue
Block a user