CPlusPlus: Make (sub-)languague selection more generic

Change-Id: I4e2df6992b446adec662ab07671acd41715e41fd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
hjk
2013-10-06 02:41:22 +02:00
parent 0a600e041a
commit 2b532c73ee
23 changed files with 272 additions and 320 deletions

View File

@@ -67,16 +67,12 @@ public:
TranslationUnit *parse(const QByteArray &source,
TranslationUnit::ParseMode mode,
bool enableObjc,
bool qtMocRun,
bool enableCxx11)
LanguageFeatures features)
{
const StringLiteral *fileId = control->stringLiteral("<stdin>");
TranslationUnit *unit = new TranslationUnit(control.data(), fileId);
unit->setSource(source.constData(), source.length());
unit->setObjCEnabled(enableObjc);
unit->setQtMocRunEnabled(qtMocRun);
unit->setCxxOxEnabled(enableCxx11);
unit->setLanguageFeatures(features);
unit->parse(mode);
return unit;
}
@@ -141,8 +137,14 @@ public:
QSharedPointer<Document> document(const QByteArray &source, bool enableObjc = false, bool qtMocRun = false, bool enableCxx11 = false)
{
LanguageFeatures features;
features.objCEnabled = enableObjc;
features.qtEnabled = qtMocRun;
features.qtMocRunEnabled = qtMocRun;
features.qtKeywordsEnabled = qtMocRun;
features.cxx11Enabled = enableCxx11;
diag.errorCount = 0; // reset the error count.
TranslationUnit *unit = parse(source, TranslationUnit::ParseTranlationUnit, enableObjc, qtMocRun, enableCxx11);
TranslationUnit *unit = parse(source, TranslationUnit::ParseTranlationUnit, features);
QSharedPointer<Document> doc(new Document(unit));
doc->check();
doc->errorCount = diag.errorCount;