diff --git a/autotests/syntaxrepository_test.cpp b/autotests/syntaxrepository_test.cpp --- a/autotests/syntaxrepository_test.cpp +++ b/autotests/syntaxrepository_test.cpp @@ -192,16 +192,21 @@ void testIncludedDefinitions() { - auto def = m_repo.definitionForName(QLatin1String("C++")); + auto def = m_repo.definitionForName(QLatin1String("PHP (HTML)")); QVERIFY(def.isValid()); auto defs = def.includedDefinitions(); const QStringList expectedDefinitionNames = { - QStringLiteral("ISO C++"), - QStringLiteral("GCCExtensions"), - QStringLiteral("Doxygen"), + QStringLiteral("PHP/PHP"), QStringLiteral("Alerts"), - QStringLiteral("Modelines") + QStringLiteral("CSS/PHP"), + QStringLiteral("JavaScript/PHP"), + QStringLiteral("Doxygen"), + QStringLiteral("Modelines"), + QStringLiteral("HTML"), + QStringLiteral("CSS"), + QStringLiteral("SQL (MySQL)"), + QStringLiteral("JavaScript") }; QStringList definitionNames; for (auto d : defs) { diff --git a/src/lib/definition.cpp b/src/lib/definition.cpp --- a/src/lib/definition.cpp +++ b/src/lib/definition.cpp @@ -256,6 +256,17 @@ // automatically catch other Definitions referenced with IncludeRuldes or ContextSwitch. const auto definition = queue.takeLast(); for (const auto & context : definition.d->contexts) { + // handle context switch attributes of this context itself + for (const auto switchContext : {context->lineEndContext().context(), context->lineEmptyContext().context(), context->fallthroughContext().context()}) { + if (switchContext) { + if (!definitions.contains(switchContext->definition())) { + queue.push_back(switchContext->definition()); + definitions.push_back(switchContext->definition()); + } + } + } + + // handle the embedded rules for (const auto &rule : context->rules()) { // handle include rules like inclusion if (!definitions.contains(rule->definition())) {