Commit 87a3aac1 authored by Erik Verbruggen's avatar Erik Verbruggen

C++: add fallback project part querying

When a file is not part of any other project part, this project part can
be used to get at least some compiler flags, defines, etc. to use. This
can happen when either a file outside a project is opened, or when the
project description is incomplete.

Change-Id: I5d595fae7195e8b61dbad14368b6cae9eb15c21b
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent fbf64eae
......@@ -410,7 +410,7 @@ void CppModelManager::dumpModelManagerConfiguration()
cxxExtensions << QLatin1String("MicrosoftExtensions");
if (part->cxxExtensions & ProjectPart::BorlandExtensions)
cxxExtensions << QLatin1String("BorlandExtensions");
if (part->cxxExtensions & ProjectPart::OpenMP)
if (part->cxxExtensions & ProjectPart::OpenMPExtensions)
cxxExtensions << QLatin1String("OpenMP");
qDebug() << "cVersion:" << cVersion;
......@@ -777,6 +777,21 @@ QList<ProjectPart::Ptr> CppModelManager::projectPart(const QString &fileName) co
return parts;
}
ProjectPart::Ptr CppModelManager::fallbackProjectPart() const
{
ProjectPart::Ptr part(new ProjectPart);
part->defines = m_definedMacros;
part->includePaths = m_includePaths;
part->frameworkPaths = m_frameworkPaths;
part->cVersion = ProjectPart::C11;
part->cxxVersion = ProjectPart::CXX11;
part->cxxExtensions = ProjectPart::AllExtensions;
part->qtVersion = ProjectPart::Qt5;
return part;
}
bool CppModelManager::isCppEditor(Core::IEditor *editor) const
{
return editor->context().contains(ProjectExplorer::Constants::LANG_CXX);
......
......@@ -74,6 +74,7 @@ public:
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
virtual QFuture<void> updateProjectInfo(const ProjectInfo &newProjectInfo);
virtual QList<CppTools::ProjectPart::Ptr> projectPart(const QString &fileName) const;
virtual ProjectPart::Ptr fallbackProjectPart() const;
virtual CPlusPlus::Snapshot snapshot() const;
virtual Document::Ptr document(const QString &fileName) const;
......
......@@ -147,7 +147,7 @@ void ProjectPart::evaluateToolchain(const ToolChain *tc,
if (cxx & ToolChain::MicrosoftExtensions)
cxxExtensions |= MicrosoftExtensions;
if (cxx & ToolChain::OpenMP)
cxxExtensions |= OpenMP;
cxxExtensions |= OpenMPExtensions;
cWarningFlags = tc->warningFlags(cflags);
cxxWarningFlags = tc->warningFlags(cxxflags);
......
......@@ -85,7 +85,9 @@ public:
GnuExtensions = 0x1,
MicrosoftExtensions = 0x2,
BorlandExtensions = 0x4,
OpenMP = 0x8
OpenMPExtensions = 0x8,
AllExtensions = GnuExtensions | MicrosoftExtensions | BorlandExtensions | OpenMPExtensions
};
Q_DECLARE_FLAGS(CXXExtensions, CXXExtension)
......@@ -217,6 +219,7 @@ public:
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
virtual QFuture<void> updateProjectInfo(const ProjectInfo &pinfo) = 0;
virtual QList<ProjectPart::Ptr> projectPart(const QString &fileName) const = 0;
virtual ProjectPart::Ptr fallbackProjectPart() const = 0;
virtual QStringList includePaths() = 0;
......
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