Commit 787b386e authored by Nikolai Kosjar's avatar Nikolai Kosjar

Clang: Use the fallback project part

...for project-less files.

Change-Id: I02d7e26bdd40dfce3b0663a07b591ee6beb2f6b7
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
parent 2ca473d5
......@@ -306,12 +306,44 @@ void IpcCommunicator::initializeBackend()
initializeBackendWithCurrentData();
}
static QStringList projectPartOptions(const CppTools::ProjectPart::Ptr &projectPart)
{
QStringList options = ClangCodeModel::Utils::createClangOptions(projectPart,
CppTools::ProjectFile::Unclassified); // No language option
if (PchInfo::Ptr pchInfo = PchManager::instance()->pchInfo(projectPart))
options += ClangCodeModel::Utils::createPCHInclusionOptions(pchInfo->fileName());
return options;
}
static ClangBackEnd::ProjectPartContainer toProjectPartContainer(
const CppTools::ProjectPart::Ptr &projectPart)
{
const QStringList options = projectPartOptions(projectPart);
return ClangBackEnd::ProjectPartContainer(projectPart->id(), Utf8StringVector(options));
}
static QVector<ClangBackEnd::ProjectPartContainer> toProjectPartContainers(
const QList<CppTools::ProjectPart::Ptr> projectParts)
{
QVector<ClangBackEnd::ProjectPartContainer> projectPartContainers;
projectPartContainers.reserve(projectParts.size());
foreach (const CppTools::ProjectPart::Ptr &projectPart, projectParts)
projectPartContainers << toProjectPartContainer(projectPart);
return projectPartContainers;
}
void IpcCommunicator::registerEmptyProjectForProjectLessFiles()
{
QTC_CHECK(m_connection.isConnected());
registerProjectPartsForEditor({ClangBackEnd::ProjectPartContainer(
Utf8String(),
Utf8StringVector())});
const auto projectPart = CppTools::CppModelManager::instance()->fallbackProjectPart();
const auto projectPartContainer = toProjectPartContainer(projectPart);
registerProjectPartsForEditor({projectPartContainer});
}
void IpcCommunicator::registerCurrentProjectParts()
......@@ -343,33 +375,6 @@ void IpcCommunicator::registerCurrentCodeModelUiHeaders()
updateUnsavedFile(es->fileName(), es->contents(), es->revision());
}
static QStringList projectPartOptions(const CppTools::ProjectPart::Ptr &projectPart)
{
QStringList options = ClangCodeModel::Utils::createClangOptions(projectPart,
CppTools::ProjectFile::Unclassified); // No language option
if (PchInfo::Ptr pchInfo = PchManager::instance()->pchInfo(projectPart))
options += ClangCodeModel::Utils::createPCHInclusionOptions(pchInfo->fileName());
return options;
}
static ClangBackEnd::ProjectPartContainer toProjectPartContainer(
const CppTools::ProjectPart::Ptr &projectPart)
{
const QStringList options = projectPartOptions(projectPart);
return ClangBackEnd::ProjectPartContainer(projectPart->id(), Utf8StringVector(options));
}
static QVector<ClangBackEnd::ProjectPartContainer> toProjectPartContainers(
const QList<CppTools::ProjectPart::Ptr> projectParts)
{
QVector<ClangBackEnd::ProjectPartContainer> projectPartContainers;
projectPartContainers.reserve(projectParts.size());
foreach (const CppTools::ProjectPart::Ptr &projectPart, projectParts)
projectPartContainers << toProjectPartContainer(projectPart);
return projectPartContainers;
}
void IpcCommunicator::registerProjectsParts(const QList<CppTools::ProjectPart::Ptr> projectParts)
{
const auto projectPartContainers = toProjectPartContainers(projectParts);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment