CppTools: Distinguish between ProjectFile::{unclassified,unsupported}

There was no way to determine whether ProjectFile::classify() was run or
not. Now, ProjectFile::classify() returns ProjectFile::Unsupported
instead of ProjectFile::Unclassified.

Change-Id: I660d0e42044bdefcac38058c6f4a3425983a6d93
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2017-02-01 09:48:58 +01:00
committed by David Schulz
parent 6bf8f85b33
commit e2e78c6a5d
9 changed files with 12 additions and 7 deletions

View File

@@ -373,7 +373,7 @@ void IpcCommunicator::initializeBackend()
static QStringList projectPartOptions(const CppTools::ProjectPart::Ptr &projectPart) static QStringList projectPartOptions(const CppTools::ProjectPart::Ptr &projectPart)
{ {
const QStringList options = ClangCodeModel::Utils::createClangOptions(projectPart, const QStringList options = ClangCodeModel::Utils::createClangOptions(projectPart,
CppTools::ProjectFile::Unclassified); // No language option CppTools::ProjectFile::Unsupported); // No language option
return options; return options;
} }

View File

@@ -383,6 +383,7 @@ static AnalyzeUnits unitsToAnalyzeFromProjectParts(const QVector<ProjectPart::Pt
foreach (const ProjectFile &file, projectPart->files) { foreach (const ProjectFile &file, projectPart->files) {
QTC_CHECK(file.kind != ProjectFile::Unclassified); QTC_CHECK(file.kind != ProjectFile::Unclassified);
QTC_CHECK(file.kind != ProjectFile::Unsupported);
if (ProjectFile::isSource(file.kind)) { if (ProjectFile::isSource(file.kind)) {
const CompilerOptionsBuilder::PchUsage pchUsage = CppTools::getPchUsage(); const CompilerOptionsBuilder::PchUsage pchUsage = CppTools::getPchUsage();
const QStringList arguments const QStringList arguments

View File

@@ -187,6 +187,7 @@ static QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objc
switch (fileKind) { switch (fileKind) {
case ProjectFile::Unclassified: case ProjectFile::Unclassified:
case ProjectFile::Unsupported:
break; break;
case ProjectFile::CHeader: case ProjectFile::CHeader:
if (objcExt) if (objcExt)

View File

@@ -53,7 +53,7 @@ ProjectFile::Kind ProjectFile::classify(const QString &filePath)
Utils::MimeDatabase mdb; Utils::MimeDatabase mdb;
const Utils::MimeType mimeType = mdb.mimeTypeForFile(filePath); const Utils::MimeType mimeType = mdb.mimeTypeForFile(filePath);
if (!mimeType.isValid()) if (!mimeType.isValid())
return Unclassified; return Unsupported;
const QString mt = mimeType.name(); const QString mt = mimeType.name();
if (mt == QLatin1String(CppTools::Constants::C_SOURCE_MIMETYPE)) if (mt == QLatin1String(CppTools::Constants::C_SOURCE_MIMETYPE))
return CSource; return CSource;
@@ -71,7 +71,7 @@ ProjectFile::Kind ProjectFile::classify(const QString &filePath)
return CXXSource; return CXXSource;
if (mt == QLatin1String(CppTools::Constants::MOC_MIMETYPE)) if (mt == QLatin1String(CppTools::Constants::MOC_MIMETYPE))
return CXXSource; return CXXSource;
return Unclassified; return Unsupported;
} }
bool ProjectFile::isAmbiguousHeader(const QString &filePath) bool ProjectFile::isAmbiguousHeader(const QString &filePath)
@@ -86,7 +86,7 @@ bool ProjectFile::isHeader(ProjectFile::Kind kind)
case ProjectFile::CXXHeader: case ProjectFile::CXXHeader:
case ProjectFile::ObjCHeader: case ProjectFile::ObjCHeader:
case ProjectFile::ObjCXXHeader: case ProjectFile::ObjCXXHeader:
case ProjectFile::Unclassified: // no file extension, e.g. stl headers case ProjectFile::Unsupported: // no file extension, e.g. stl headers
case ProjectFile::AmbiguousHeader: case ProjectFile::AmbiguousHeader:
return true; return true;
default: default:
@@ -124,6 +124,7 @@ const char *projectFileKindToText(ProjectFile::Kind kind)
{ {
switch (kind) { switch (kind) {
RETURN_TEXT_FOR_CASE(Unclassified); RETURN_TEXT_FOR_CASE(Unclassified);
RETURN_TEXT_FOR_CASE(Unsupported);
RETURN_TEXT_FOR_CASE(AmbiguousHeader); RETURN_TEXT_FOR_CASE(AmbiguousHeader);
RETURN_TEXT_FOR_CASE(CHeader); RETURN_TEXT_FOR_CASE(CHeader);
RETURN_TEXT_FOR_CASE(CSource); RETURN_TEXT_FOR_CASE(CSource);

View File

@@ -36,6 +36,7 @@ class CPPTOOLS_EXPORT ProjectFile
public: public:
enum Kind { enum Kind {
Unclassified, Unclassified,
Unsupported,
AmbiguousHeader, AmbiguousHeader,
CHeader, CHeader,
CSource, CSource,

View File

@@ -404,7 +404,7 @@ QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader)
if (debug) if (debug)
qDebug() << Q_FUNC_INFO << fileName << kind; qDebug() << Q_FUNC_INFO << fileName << kind;
if (kind == ProjectFile::Unclassified) if (kind == ProjectFile::Unsupported)
return QString(); return QString();
const QString baseName = fi.completeBaseName(); const QString baseName = fi.completeBaseName();

View File

@@ -1151,7 +1151,7 @@ static void slotTooltipOverrideRequested
&context.function, &context.scopeFromLine, &context.scopeToLine); &context.function, &context.scopeFromLine, &context.scopeToLine);
context.expression = fixCppExpression(raw); context.expression = fixCppExpression(raw);
context.isCppEditor = CppTools::ProjectFile::classify(document->filePath().toString()) context.isCppEditor = CppTools::ProjectFile::classify(document->filePath().toString())
!= CppTools::ProjectFile::Unclassified; != CppTools::ProjectFile::Unsupported;
if (context.expression.isEmpty()) { if (context.expression.isEmpty()) {
ToolTip::show(point, DebuggerToolTipManager::tr("No valid expression"), ToolTip::show(point, DebuggerToolTipManager::tr("No valid expression"),

View File

@@ -399,6 +399,7 @@ void ComponentViewController::createComponentModel(const ProjectExplorer::Folder
isSource = true; isSource = true;
break; break;
case CppTools::ProjectFile::Unclassified: case CppTools::ProjectFile::Unclassified:
case CppTools::ProjectFile::Unsupported:
isSource = false; isSource = false;
break; break;
} }

View File

@@ -795,7 +795,7 @@ static CppTools::ProjectFile::Kind cppFileType(const qbs::ArtifactData &sourceFi
return CppTools::ProjectFile::ObjCSource; return CppTools::ProjectFile::ObjCSource;
if (sourceFile.fileTags().contains(QLatin1String("objcpp"))) if (sourceFile.fileTags().contains(QLatin1String("objcpp")))
return CppTools::ProjectFile::ObjCXXSource; return CppTools::ProjectFile::ObjCXXSource;
return CppTools::ProjectFile::Unclassified; return CppTools::ProjectFile::Unsupported;
} }
static QString groupLocationToProjectFile(const qbs::CodeLocation &location) static QString groupLocationToProjectFile(const qbs::CodeLocation &location)