forked from qt-creator/qt-creator
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:
@@ -36,9 +36,12 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <cpptools/baseeditordocumentparser.h>
|
||||
#include <cpptools/cppprojects.h>
|
||||
#include <cpptools/cppworkingcopy.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QLoggingCategory>
|
||||
@@ -202,5 +205,28 @@ QStringList createPCHInclusionOptions(const QString &pchFile)
|
||||
return createPCHInclusionOptions(QStringList() << pchFile);
|
||||
}
|
||||
|
||||
ProjectPart::Ptr projectPartForFile(const QString &filePath)
|
||||
{
|
||||
if (CppTools::BaseEditorDocumentParser *parser = CppTools::BaseEditorDocumentParser::get(filePath))
|
||||
return parser->projectPart();
|
||||
return ProjectPart::Ptr();
|
||||
}
|
||||
|
||||
bool isProjectPartValid(const ProjectPart::Ptr projectPart)
|
||||
{
|
||||
if (projectPart)
|
||||
return CppModelManager::instance()->projectPartForProjectFile(projectPart->projectFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
QString projectFilePathForFile(const QString &filePath)
|
||||
{
|
||||
const ProjectPart::Ptr projectPart = projectPartForFile(filePath);
|
||||
|
||||
if (isProjectPartValid(projectPart))
|
||||
return projectPart->projectFile; // OK, Project Part is still loaded
|
||||
return QString();
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
} // namespace Clang
|
||||
|
||||
Reference in New Issue
Block a user