Commit 50a07695 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Report also C language back to project

...for Project::setProjectLanguage().

Change-Id: I77347c4597061fb48782c629d5ad6898028fee13
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent 62441682
......@@ -129,10 +129,8 @@ QList<Core::Id> BaseProjectPartBuilder::createProjectPartsForFiles(const QString
ProjectFileCategorizer cat(m_templatePart->displayName, filePaths, fileClassifier);
if (cat.hasParts()) {
// The ProjextExplorer does not distinguish between other versions than C++ and QML.
languages += ProjectExplorer::Constants::CXX_LANGUAGE_ID;
if (cat.hasCxxSources()) {
languages += ProjectExplorer::Constants::CXX_LANGUAGE_ID;
createProjectPart(cat.cxxSources(),
cat.partName("C++"),
ProjectPart::LatestCxxVersion,
......@@ -140,6 +138,7 @@ QList<Core::Id> BaseProjectPartBuilder::createProjectPartsForFiles(const QString
}
if (cat.hasObjcxxSources()) {
languages += ProjectExplorer::Constants::CXX_LANGUAGE_ID;
createProjectPart(cat.objcxxSources(),
cat.partName("Obj-C++"),
ProjectPart::LatestCxxVersion,
......@@ -147,6 +146,7 @@ QList<Core::Id> BaseProjectPartBuilder::createProjectPartsForFiles(const QString
}
if (cat.hasCSources()) {
languages += ProjectExplorer::Constants::C_LANGUAGE_ID;
createProjectPart(cat.cSources(),
cat.partName("C"),
ProjectPart::LatestCVersion,
......@@ -154,6 +154,7 @@ QList<Core::Id> BaseProjectPartBuilder::createProjectPartsForFiles(const QString
}
if (cat.hasObjcSources()) {
languages += ProjectExplorer::Constants::C_LANGUAGE_ID;
createProjectPart(cat.objcSources(),
cat.partName("Obj-C"),
ProjectPart::LatestCVersion,
......
......@@ -34,6 +34,7 @@
#include <projectexplorer/headerpath.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/mimetypes/mimedatabase.h>
......@@ -48,6 +49,7 @@ using CppTools::ProjectPart;
using CppTools::ToolChainInterface;
using CppTools::ToolChainInterfacePtr;
using testing::Contains;
using testing::Eq;
using testing::UnorderedElementsAre;
using testing::PrintToString;
......@@ -215,6 +217,24 @@ TEST_F(BaseProjectPartBuilder, ProjectFileKindsMatchProjectPartVersion)
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()
{
ASSERT_TRUE(MimeDataBaseUtilities::addCppToolsMimeTypes());
......
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