Clang: Use completion through backend process

This makes us independent of libclang crashes for completion.
Re-parsing for highlighting still happens in the Qt Creator process.

Run in verbose mode:
    qtc.clangcodemodel.ipc=true

Run tests:
    -test "ClangCodeModel"

Task-number: QTCREATORBUG-14108
Task-number: QTCREATORBUG-12819
Change-Id: Id3e95bd2afdb6508bbd1d35fddc69534a909b905
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-05-08 15:48:17 +02:00
parent 264132da27
commit 23b8a3b2e8
59 changed files with 3820 additions and 634 deletions

View File

@@ -30,6 +30,8 @@
#include "clangeditordocumentprocessor.h"
#include "clangmodelmanagersupport.h"
#include "clangutils.h"
#include "cppcreatemarkers.h"
#include "diagnostic.h"
#include "pchinfo.h"
@@ -91,9 +93,13 @@ QList<TextEditor::BlockRange> toTextEditorBlocks(
} // anonymous namespace
namespace ClangCodeModel {
namespace Internal {
ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(TextEditor::TextDocument *document)
ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(
ModelManagerSupportClang *modelManagerSupport,
TextEditor::TextDocument *document)
: BaseEditorDocumentProcessor(document)
, m_modelManagerSupport(modelManagerSupport)
, m_parser(document->filePath().toString())
, m_parserRevision(0)
, m_semanticHighlighter(document)
@@ -122,6 +128,17 @@ ClangEditorDocumentProcessor::~ClangEditorDocumentProcessor()
{
m_parserWatcher.cancel();
m_parserWatcher.waitForFinished();
const CppTools::ProjectPart::Ptr projectPart = m_parser.projectPart();
QTC_ASSERT(projectPart, return);
QString projectFilePath;
if (Utils::isProjectPartValid(projectPart))
projectFilePath = projectPart->projectFile; // OK, Project Part is still loaded
QTC_ASSERT(m_modelManagerSupport, return);
m_modelManagerSupport->ipcCommunicator()->unregisterFilesForCodeCompletion(
{CodeModelBackEnd::FileContainer(filePath(), projectFilePath)});
}
void ClangEditorDocumentProcessor::run()
@@ -188,4 +205,5 @@ void ClangEditorDocumentProcessor::onParserFinished()
m_semanticHighlighter.run();
}
} // namespace Internal
} // namespace ClangCodeModel