Clang: Remove project tracking on clangbackend side

...as it is not needed. Just provide the compilation arguments as part
of the Document.

As a side effect, re-initializing the backend after a crash is cheaper
and will not freeze the UI anymore (referenced bug).

Task-number: QTCREATORBUG-21097
Change-Id: I866e25ef1fd5e4d318df16612a7564469e6baa11
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Nikolai Kosjar
2018-09-25 09:41:32 +02:00
parent 25ea9a4d24
commit aa290912b8
102 changed files with 394 additions and 2388 deletions

View File

@@ -143,7 +143,7 @@ void ClangEditorDocumentProcessor::semanticRehighlight()
m_semanticHighlighter.updateFormatMapFromFontSettings();
if (m_projectPart)
requestAnnotationsFromBackend(m_projectPart->id());
requestAnnotationsFromBackend();
}
CppTools::SemanticInfo ClangEditorDocumentProcessor::recalculateSemanticInfo()
@@ -588,8 +588,7 @@ private:
};
} // namespace
void ClangEditorDocumentProcessor::updateBackendDocument(
CppTools::ProjectPart &projectPart)
void ClangEditorDocumentProcessor::updateBackendDocument(CppTools::ProjectPart &projectPart)
{
// On registration we send the document content immediately as an unsaved
// file, because
@@ -605,10 +604,17 @@ void ClangEditorDocumentProcessor::updateBackendDocument(
return;
}
const QStringList projectPartOptions = ClangCodeModel::Utils::createClangOptions(
projectPart,
CppTools::ProjectFile::Unsupported); // No language option as FileOptionsBuilder adds it.
const FileOptionsBuilder fileOptions(filePath(), projectPart);
m_diagnosticConfigId = fileOptions.diagnosticConfigId();
const QStringList compilationArguments = projectPartOptions + fileOptions.options();
m_communicator.documentsOpened(
{fileContainerWithOptionsAndDocumentContent(projectPart, fileOptions.options())});
{fileContainerWithOptionsAndDocumentContent(compilationArguments)});
ClangCodeModel::Utils::setLastSentDocumentRevision(filePath(), revision());
}
@@ -621,16 +627,14 @@ void ClangEditorDocumentProcessor::closeBackendDocument()
void ClangEditorDocumentProcessor::updateBackendDocumentIfProjectPartExists()
{
if (m_projectPart) {
const ClangBackEnd::FileContainer fileContainer = fileContainerWithDocumentContent(
m_projectPart->id());
const ClangBackEnd::FileContainer fileContainer = fileContainerWithDocumentContent();
m_communicator.documentsChangedWithRevisionCheck(fileContainer);
}
}
void ClangEditorDocumentProcessor::requestAnnotationsFromBackend(const QString &projectpartId)
void ClangEditorDocumentProcessor::requestAnnotationsFromBackend()
{
const auto fileContainer = fileContainerWithDocumentContent(projectpartId);
const auto fileContainer = fileContainerWithDocumentContent();
m_communicator.requestAnnotations(fileContainer);
}
@@ -660,12 +664,7 @@ ClangEditorDocumentProcessor::creatorForHeaderErrorDiagnosticWidget(
ClangBackEnd::FileContainer ClangEditorDocumentProcessor::simpleFileContainer(
const QByteArray &codecName) const
{
Utf8String projectPartId;
if (m_projectPart)
projectPartId = m_projectPart->id();
return ClangBackEnd::FileContainer(filePath(),
projectPartId,
Utf8String(),
false,
revision(),
@@ -673,21 +672,19 @@ ClangBackEnd::FileContainer ClangEditorDocumentProcessor::simpleFileContainer(
}
ClangBackEnd::FileContainer ClangEditorDocumentProcessor::fileContainerWithOptionsAndDocumentContent(
CppTools::ProjectPart &projectPart, const QStringList &fileOptions) const
const QStringList &compilationArguments) const
{
return ClangBackEnd::FileContainer(filePath(),
projectPart.id(),
Utf8StringVector(fileOptions),
Utf8StringVector(compilationArguments),
textDocument()->toPlainText(),
true,
revision());
}
ClangBackEnd::FileContainer
ClangEditorDocumentProcessor::fileContainerWithDocumentContent(const QString &projectpartId) const
ClangEditorDocumentProcessor::fileContainerWithDocumentContent() const
{
return ClangBackEnd::FileContainer(filePath(),
projectpartId,
textDocument()->toPlainText(),
true,
revision());