forked from qt-creator/qt-creator
CppTools: Report also C language back to project
...for Project::setProjectLanguage(). Change-Id: I77347c4597061fb48782c629d5ad6898028fee13 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -129,10 +129,8 @@ QList<Core::Id> BaseProjectPartBuilder::createProjectPartsForFiles(const QString
|
|||||||
ProjectFileCategorizer cat(m_templatePart->displayName, filePaths, fileClassifier);
|
ProjectFileCategorizer cat(m_templatePart->displayName, filePaths, fileClassifier);
|
||||||
|
|
||||||
if (cat.hasParts()) {
|
if (cat.hasParts()) {
|
||||||
// The ProjextExplorer does not distinguish between other versions than C++ and QML.
|
|
||||||
languages += ProjectExplorer::Constants::CXX_LANGUAGE_ID;
|
|
||||||
|
|
||||||
if (cat.hasCxxSources()) {
|
if (cat.hasCxxSources()) {
|
||||||
|
languages += ProjectExplorer::Constants::CXX_LANGUAGE_ID;
|
||||||
createProjectPart(cat.cxxSources(),
|
createProjectPart(cat.cxxSources(),
|
||||||
cat.partName("C++"),
|
cat.partName("C++"),
|
||||||
ProjectPart::LatestCxxVersion,
|
ProjectPart::LatestCxxVersion,
|
||||||
@@ -140,6 +138,7 @@ QList<Core::Id> BaseProjectPartBuilder::createProjectPartsForFiles(const QString
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cat.hasObjcxxSources()) {
|
if (cat.hasObjcxxSources()) {
|
||||||
|
languages += ProjectExplorer::Constants::CXX_LANGUAGE_ID;
|
||||||
createProjectPart(cat.objcxxSources(),
|
createProjectPart(cat.objcxxSources(),
|
||||||
cat.partName("Obj-C++"),
|
cat.partName("Obj-C++"),
|
||||||
ProjectPart::LatestCxxVersion,
|
ProjectPart::LatestCxxVersion,
|
||||||
@@ -147,6 +146,7 @@ QList<Core::Id> BaseProjectPartBuilder::createProjectPartsForFiles(const QString
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cat.hasCSources()) {
|
if (cat.hasCSources()) {
|
||||||
|
languages += ProjectExplorer::Constants::C_LANGUAGE_ID;
|
||||||
createProjectPart(cat.cSources(),
|
createProjectPart(cat.cSources(),
|
||||||
cat.partName("C"),
|
cat.partName("C"),
|
||||||
ProjectPart::LatestCVersion,
|
ProjectPart::LatestCVersion,
|
||||||
@@ -154,6 +154,7 @@ QList<Core::Id> BaseProjectPartBuilder::createProjectPartsForFiles(const QString
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cat.hasObjcSources()) {
|
if (cat.hasObjcSources()) {
|
||||||
|
languages += ProjectExplorer::Constants::C_LANGUAGE_ID;
|
||||||
createProjectPart(cat.objcSources(),
|
createProjectPart(cat.objcSources(),
|
||||||
cat.partName("Obj-C"),
|
cat.partName("Obj-C"),
|
||||||
ProjectPart::LatestCVersion,
|
ProjectPart::LatestCVersion,
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <projectexplorer/headerpath.h>
|
#include <projectexplorer/headerpath.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
|
||||||
#include <utils/mimetypes/mimedatabase.h>
|
#include <utils/mimetypes/mimedatabase.h>
|
||||||
|
|
||||||
@@ -48,6 +49,7 @@ using CppTools::ProjectPart;
|
|||||||
using CppTools::ToolChainInterface;
|
using CppTools::ToolChainInterface;
|
||||||
using CppTools::ToolChainInterfacePtr;
|
using CppTools::ToolChainInterfacePtr;
|
||||||
|
|
||||||
|
using testing::Contains;
|
||||||
using testing::Eq;
|
using testing::Eq;
|
||||||
using testing::UnorderedElementsAre;
|
using testing::UnorderedElementsAre;
|
||||||
using testing::PrintToString;
|
using testing::PrintToString;
|
||||||
@@ -215,6 +217,24 @@ TEST_F(BaseProjectPartBuilder, ProjectFileKindsMatchProjectPartVersion)
|
|||||||
IsProjectPart(ProjectPart::LatestCxxVersion, ProjectFile::ObjCXXHeader)));
|
IsProjectPart(ProjectPart::LatestCxxVersion, ProjectFile::ObjCXXHeader)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(BaseProjectPartBuilder, ReportsCxxLanguage)
|
||||||
|
{
|
||||||
|
::BaseProjectPartBuilder builder(new EditableProject, projectInfo);
|
||||||
|
|
||||||
|
const QList<Core::Id> languages = builder.createProjectPartsForFiles(QStringList() << "foo.cpp");
|
||||||
|
|
||||||
|
ASSERT_THAT(languages, Eq(QList<Core::Id>() << ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(BaseProjectPartBuilder, ReportsCLanguage)
|
||||||
|
{
|
||||||
|
::BaseProjectPartBuilder builder(new EditableProject, projectInfo);
|
||||||
|
|
||||||
|
const QList<Core::Id> languages = builder.createProjectPartsForFiles(QStringList() << "foo.c");
|
||||||
|
|
||||||
|
ASSERT_THAT(languages, Eq(QList<Core::Id>() << ProjectExplorer::Constants::C_LANGUAGE_ID));
|
||||||
|
}
|
||||||
|
|
||||||
void BaseProjectPartBuilder::SetUp()
|
void BaseProjectPartBuilder::SetUp()
|
||||||
{
|
{
|
||||||
ASSERT_TRUE(MimeDataBaseUtilities::addCppToolsMimeTypes());
|
ASSERT_TRUE(MimeDataBaseUtilities::addCppToolsMimeTypes());
|
||||||
|
|||||||
Reference in New Issue
Block a user