forked from qt-creator/qt-creator
Utils: Move C++ language details from ProjectExplorer to Utils
We want to use them in the backend processes too so it's nice to share them in Utils. A concrete size was added too because they should be serialized. Change-Id: Id5eb8f46643d5159f034fc9559f68a08d7e5847a Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -31,11 +31,11 @@
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/language.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectmacro.h>
|
||||
|
||||
#include <utils/cpplanguage_details.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -95,12 +95,12 @@ QStringList CompilerOptionsBuilder::build(ProjectFile::Kind fileKind,
|
||||
m_options.clear();
|
||||
|
||||
if (fileKind == ProjectFile::CHeader || fileKind == ProjectFile::CSource) {
|
||||
QTC_ASSERT(m_projectPart.languageVersion <= ProjectExplorer::LanguageVersion::LatestC,
|
||||
QTC_ASSERT(m_projectPart.languageVersion <= Utils::LanguageVersion::LatestC,
|
||||
return QStringList(););
|
||||
}
|
||||
|
||||
if (fileKind == ProjectFile::CXXHeader || fileKind == ProjectFile::CXXSource) {
|
||||
QTC_ASSERT(m_projectPart.languageVersion > ProjectExplorer::LanguageVersion::LatestC,
|
||||
QTC_ASSERT(m_projectPart.languageVersion > Utils::LanguageVersion::LatestC,
|
||||
return QStringList(););
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ void CompilerOptionsBuilder::addMacros(const ProjectExplorer::Macros ¯os)
|
||||
void CompilerOptionsBuilder::updateFileLanguage(ProjectFile::Kind fileKind)
|
||||
{
|
||||
const bool objcExt = m_projectPart.languageExtensions
|
||||
& ProjectExplorer::LanguageExtension::ObjectiveC;
|
||||
& Utils::LanguageExtension::ObjectiveC;
|
||||
const QStringList options = createLanguageOptionGcc(fileKind, objcExt);
|
||||
if (options.isEmpty())
|
||||
return;
|
||||
@@ -334,11 +334,11 @@ void CompilerOptionsBuilder::updateFileLanguage(ProjectFile::Kind fileKind)
|
||||
|
||||
void CompilerOptionsBuilder::addLanguageVersionAndExtensions()
|
||||
{
|
||||
using ProjectExplorer::LanguageExtension;
|
||||
using ProjectExplorer::LanguageVersion;
|
||||
using Utils::LanguageExtension;
|
||||
using Utils::LanguageVersion;
|
||||
|
||||
QStringList options;
|
||||
const ProjectExplorer::LanguageExtensions languageExtensions = m_projectPart.languageExtensions;
|
||||
const Utils::LanguageExtensions languageExtensions = m_projectPart.languageExtensions;
|
||||
const bool gnuExtensions = languageExtensions & LanguageExtension::Gnu;
|
||||
|
||||
switch (m_projectPart.languageVersion) {
|
||||
|
||||
@@ -103,9 +103,9 @@ QString Utils::toString(ProjectExplorer::HeaderPathType type)
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString Utils::toString(ProjectExplorer::LanguageVersion languageVersion)
|
||||
QString Utils::toString(::Utils::LanguageVersion languageVersion)
|
||||
{
|
||||
#define CASE_LANGUAGEVERSION(x) case ProjectExplorer::LanguageVersion::x: return QLatin1String(#x)
|
||||
#define CASE_LANGUAGEVERSION(x) case ::Utils::LanguageVersion::x: return QLatin1String(#x)
|
||||
switch (languageVersion) {
|
||||
CASE_LANGUAGEVERSION(C89);
|
||||
CASE_LANGUAGEVERSION(C99);
|
||||
@@ -123,11 +123,11 @@ QString Utils::toString(ProjectExplorer::LanguageVersion languageVersion)
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString Utils::toString(ProjectExplorer::LanguageExtensions languageExtension)
|
||||
QString Utils::toString(::Utils::LanguageExtensions languageExtension)
|
||||
{
|
||||
QString result;
|
||||
|
||||
#define CASE_LANGUAGE_EXTENSION(ext) if (languageExtension & ProjectExplorer::LanguageExtension::ext) \
|
||||
#define CASE_LANGUAGE_EXTENSION(ext) if (languageExtension & ::Utils::LanguageExtension::ext) \
|
||||
result += QLatin1String(#ext ", ");
|
||||
|
||||
CASE_LANGUAGE_EXTENSION(None);
|
||||
|
||||
@@ -47,8 +47,8 @@ struct CPPTOOLS_EXPORT Utils
|
||||
static QString toString(CPlusPlus::Document::CheckMode checkMode);
|
||||
static QString toString(CPlusPlus::Document::DiagnosticMessage::Level level);
|
||||
static QString toString(ProjectExplorer::HeaderPathType type);
|
||||
static QString toString(ProjectExplorer::LanguageVersion languageVersion);
|
||||
static QString toString(ProjectExplorer::LanguageExtensions languageExtension);
|
||||
static QString toString(::Utils::LanguageVersion languageVersion);
|
||||
static QString toString(::Utils::LanguageExtensions languageExtension);
|
||||
static QString toString(CppTools::ProjectPart::QtVersion qtVersion);
|
||||
static QString toString(CppTools::ProjectPart::BuildTargetType buildTargetType);
|
||||
static QString toString(const QVector<CppTools::ProjectFile> &projectFiles);
|
||||
|
||||
@@ -1162,9 +1162,9 @@ ProjectPart::Ptr CppModelManager::fallbackProjectPart()
|
||||
|
||||
// Do not activate ObjectiveCExtensions since this will lead to the
|
||||
// "objective-c++" language option for a project-less *.cpp file.
|
||||
part->languageExtensions = ProjectExplorer::LanguageExtension::All;
|
||||
part->languageExtensions &= ~ProjectExplorer::LanguageExtensions(
|
||||
ProjectExplorer::LanguageExtension::ObjectiveC);
|
||||
part->languageExtensions = Utils::LanguageExtension::All;
|
||||
part->languageExtensions &= ~Utils::LanguageExtensions(
|
||||
Utils::LanguageExtension::ObjectiveC);
|
||||
|
||||
part->qtVersion = ProjectPart::Qt5;
|
||||
part->updateLanguageFeatures();
|
||||
|
||||
@@ -82,7 +82,7 @@ static ProjectPart::Ptr projectPartFromRawProjectPart(const RawProjectPart &rawP
|
||||
|
||||
QVector<ProjectPart::Ptr> ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPart)
|
||||
{
|
||||
using ProjectExplorer::LanguageExtension;
|
||||
using Utils::LanguageExtension;
|
||||
|
||||
QVector<ProjectPart::Ptr> result;
|
||||
ProjectFileCategorizer cat(rawProjectPart.displayName,
|
||||
@@ -138,7 +138,7 @@ ProjectPart::Ptr ProjectInfoGenerator::createProjectPart(
|
||||
const ProjectFiles &projectFiles,
|
||||
const QString &partName,
|
||||
Language language,
|
||||
ProjectExplorer::LanguageExtensions languageExtensions)
|
||||
Utils::LanguageExtensions languageExtensions)
|
||||
{
|
||||
RawProjectPartFlags flags;
|
||||
ToolChainInfo tcInfo;
|
||||
@@ -172,9 +172,9 @@ ProjectPart::Ptr ProjectInfoGenerator::createProjectPart(
|
||||
part->languageVersion = macroInspectionReport.languageVersion;
|
||||
// No compiler set in kit.
|
||||
} else if (language == Language::C) {
|
||||
part->languageVersion = ProjectExplorer::LanguageVersion::LatestC;
|
||||
part->languageVersion = Utils::LanguageVersion::LatestC;
|
||||
} else {
|
||||
part->languageVersion = ProjectExplorer::LanguageVersion::LatestCxx;
|
||||
part->languageVersion = Utils::LanguageVersion::LatestCxx;
|
||||
}
|
||||
|
||||
// Header paths
|
||||
|
||||
@@ -48,7 +48,7 @@ private:
|
||||
const ProjectFiles &projectFiles,
|
||||
const QString &partName,
|
||||
Language language,
|
||||
ProjectExplorer::LanguageExtensions languageExtensions);
|
||||
Utils::LanguageExtensions languageExtensions);
|
||||
|
||||
private:
|
||||
const QFutureInterface<void> m_futureInterface;
|
||||
|
||||
@@ -117,7 +117,7 @@ private:
|
||||
bool isPreferredLanguage(const ProjectPart &projectPart) const
|
||||
{
|
||||
const bool isCProjectPart = projectPart.languageVersion
|
||||
<= ProjectExplorer::LanguageVersion::LatestC;
|
||||
<= Utils::LanguageVersion::LatestC;
|
||||
return (m_languagePreference == Language::C && isCProjectPart)
|
||||
|| (m_languagePreference == Language::Cxx && !isCProjectPart);
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#include "cpptools_global.h"
|
||||
#include "projectpart.h"
|
||||
|
||||
#include <projectexplorer/language.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <utils/cpplanguage_details.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
QStringList commandLineFlags;
|
||||
// The following are deduced from commandLineFlags.
|
||||
ProjectExplorer::WarningFlags warningFlags = ProjectExplorer::WarningFlags::Default;
|
||||
ProjectExplorer::LanguageExtensions languageExtensions = ProjectExplorer::LanguageExtension::None;
|
||||
Utils::LanguageExtensions languageExtensions = Utils::LanguageExtension::None;
|
||||
};
|
||||
|
||||
class CPPTOOLS_EXPORT RawProjectPart
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
enum class Language { C, Cxx };
|
||||
using Utils::Language;
|
||||
|
||||
class ProjectPartInfo {
|
||||
public:
|
||||
|
||||
@@ -35,13 +35,12 @@ namespace CppTools {
|
||||
|
||||
void ProjectPart::updateLanguageFeatures()
|
||||
{
|
||||
const bool hasCxx = languageVersion >= ProjectExplorer::LanguageVersion::CXX98;
|
||||
const bool hasCxx = languageVersion >= Utils::LanguageVersion::CXX98;
|
||||
const bool hasQt = hasCxx && qtVersion != NoQt;
|
||||
languageFeatures.cxx11Enabled = languageVersion >= ProjectExplorer::LanguageVersion::CXX11;
|
||||
languageFeatures.cxx11Enabled = languageVersion >= Utils::LanguageVersion::CXX11;
|
||||
languageFeatures.cxxEnabled = hasCxx;
|
||||
languageFeatures.c99Enabled = languageVersion >= ProjectExplorer::LanguageVersion::C99;
|
||||
languageFeatures.objCEnabled = languageExtensions.testFlag(
|
||||
ProjectExplorer::LanguageExtension::ObjectiveC);
|
||||
languageFeatures.c99Enabled = languageVersion >= Utils::LanguageVersion::C99;
|
||||
languageFeatures.objCEnabled = languageExtensions.testFlag(Utils::LanguageExtension::ObjectiveC);
|
||||
languageFeatures.qtEnabled = hasQt;
|
||||
languageFeatures.qtMocRunEnabled = hasQt;
|
||||
if (!hasQt) {
|
||||
|
||||
@@ -30,12 +30,13 @@
|
||||
#include "cppprojectfile.h"
|
||||
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/language.h>
|
||||
#include <projectexplorer/projectexplorer_global.h>
|
||||
#include <projectexplorer/projectmacro.h>
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
|
||||
#include <utils/cpplanguage_details.h>
|
||||
|
||||
#include <cplusplus/Token.h>
|
||||
|
||||
#include <QString>
|
||||
@@ -90,8 +91,8 @@ public:
|
||||
QString callGroupId;
|
||||
|
||||
// Versions, features and extensions
|
||||
ProjectExplorer::LanguageVersion languageVersion = ProjectExplorer::LanguageVersion::LatestCxx;
|
||||
ProjectExplorer::LanguageExtensions languageExtensions = ProjectExplorer::LanguageExtension::None;
|
||||
Utils::LanguageVersion languageVersion = Utils::LanguageVersion::LatestCxx;
|
||||
Utils::LanguageExtensions languageExtensions = Utils::LanguageExtension::None;
|
||||
CPlusPlus::LanguageFeatures languageFeatures;
|
||||
QtVersion qtVersion = UnknownQt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user