Commit 1478e661 authored by Erik Verbruggen's avatar Erik Verbruggen Committed by Nikolai Kosjar
Browse files

Introduced mime-type for ObjC++.



Updated/fixed the code to treat treat text/x-objcsrc and
text/x-objc++src correctly.

Change-Id: I1ab97577c786a28381398e4e0fac177325d00d7b
Reviewed-by: default avatarSergey Shambir <sergey.shambir.auto@gmail.com>
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 732f8a06
......@@ -92,6 +92,7 @@ Protocol::ContentType Protocol::contentType(const QString &mt)
return C;
if (mt == QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE)
|| mt == QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE)
|| mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)
|| mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE))
return Cpp;
if (mt == QLatin1String(QmlJSTools::Constants::QML_MIMETYPE)
......
......@@ -63,10 +63,13 @@
<mime-type type="text/x-objcsrc">
<comment>Objective-C source code</comment>
<sub-class-of type="text/x-csrc"/>
<magic priority="30">
<match value="#import" type="string" offset="0"/>
</magic>
<glob pattern="*.m"/>
</mime-type>
<mime-type type="text/x-objc++src">
<comment>Objective-C++ source code</comment>
<sub-class-of type="text/x-c++src"/>
<sub-class-of type="text/x-objcsrc"/>
<glob pattern="*.mm"/>
</mime-type>
......
......@@ -701,7 +701,8 @@ CppModelManagerInterface *CPPEditorWidget::modelManager() const
void CPPEditorWidget::setMimeType(const QString &mt)
{
BaseTextEditorWidget::setMimeType(mt);
setObjCEnabled(mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
setObjCEnabled(mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)
|| mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
}
void CPPEditorWidget::setObjCEnabled(bool onoff)
......
......@@ -1193,7 +1193,8 @@ bool CppCompletionAssistProcessor::objcKeywordsWanted() const
const Core::MimeDatabase *mdb = Core::ICore::mimeDatabase();
const QString mt = mdb->findByFile(fileName).type();
return mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE);
return mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)
|| mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE);
}
int CppCompletionAssistProcessor::startCompletionInternal(const QString fileName,
......
......@@ -64,6 +64,8 @@ ProjectFile::Kind ProjectFile::classify(const QString &file)
return CXXSource;
if (mt == QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE))
return CXXHeader;
if (mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE))
return ObjCSource;
if (mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE))
return ObjCXXSource;
return Unclassified;
......@@ -107,6 +109,7 @@ ProjectFileAdder::ProjectFileAdder(QList<ProjectFile> &files)
addMapping(CppTools::Constants::C_HEADER_MIMETYPE, ProjectFile::CHeader);
addMapping(CppTools::Constants::CPP_SOURCE_MIMETYPE, ProjectFile::CXXSource);
addMapping(CppTools::Constants::CPP_HEADER_MIMETYPE, ProjectFile::CXXHeader);
addMapping(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE, ProjectFile::ObjCSource);
addMapping(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE, ProjectFile::ObjCXXSource);
}
......
......@@ -43,7 +43,8 @@ const char TASK_SEARCH[] = "CppTools.Task.Search";
const char C_SOURCE_MIMETYPE[] = "text/x-csrc";
const char C_HEADER_MIMETYPE[] = "text/x-chdr";
const char CPP_SOURCE_MIMETYPE[] = "text/x-c++src";
const char OBJECTIVE_CPP_SOURCE_MIMETYPE[] = "text/x-objcsrc";
const char OBJECTIVE_C_SOURCE_MIMETYPE[] = "text/x-objcsrc";
const char OBJECTIVE_CPP_SOURCE_MIMETYPE[] = "text/x-objc++src";
const char CPP_HEADER_MIMETYPE[] = "text/x-c++hdr";
// QSettings keys for use by the "New Class" wizards.
......
......@@ -201,6 +201,7 @@ static QStringList matchingCandidateSuffixes(ProjectFile::Kind kind)
case ProjectFile::ObjCXXHeader:
return md->findByType(QLatin1String(Constants::C_SOURCE_MIMETYPE)).suffixes()
+ md->findByType(QLatin1String(Constants::CPP_SOURCE_MIMETYPE)).suffixes()
+ md->findByType(QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE)).suffixes()
+ md->findByType(QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE)).suffixes();
case ProjectFile::CSource:
case ProjectFile::ObjCSource:
......
......@@ -588,7 +588,9 @@ void Qt4Project::updateCppCodeModel()
ProjectFile::CXXSource));
foreach (const QString &file, pro->variableValue(ObjCSourceVar)) {
allFiles << file;
part->files << ProjectFile(file, ProjectFile::ObjCSource);
// Although the enum constant is called ObjCSourceVar, it actually is ObjC++ source
// code, as qmake does not handle C (and ObjC).
part->files << ProjectFile(file, ProjectFile::ObjCXXSource);
}
foreach (const QString &file, pro->variableValue(ObjCHeaderVar)) {
allFiles << file;
......
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