Changeset View
Changeset View
Standalone View
Standalone View
src/lib/definition.cpp
Show All 28 Lines | |||||
29 | #include "ksyntaxhighlighting_version.h" | 29 | #include "ksyntaxhighlighting_version.h" | ||
30 | #include "xml_p.h" | 30 | #include "xml_p.h" | ||
31 | 31 | | |||
32 | #include <QCoreApplication> | 32 | #include <QCoreApplication> | ||
33 | #include <QDebug> | 33 | #include <QDebug> | ||
34 | #include <QFile> | 34 | #include <QFile> | ||
35 | #include <QHash> | 35 | #include <QHash> | ||
36 | #include <QJsonObject> | 36 | #include <QJsonObject> | ||
37 | #include <QQueue> | ||||
37 | #include <QStringList> | 38 | #include <QStringList> | ||
38 | #include <QVector> | 39 | #include <QVector> | ||
39 | #include <QXmlStreamReader> | 40 | #include <QXmlStreamReader> | ||
40 | 41 | | |||
41 | #include <algorithm> | 42 | #include <algorithm> | ||
42 | 43 | | |||
43 | using namespace KSyntaxHighlighting; | 44 | using namespace KSyntaxHighlighting; | ||
44 | 45 | | |||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Line(s) | |||||
181 | } | 182 | } | ||
182 | 183 | | |||
183 | QStringList Definition::foldingIgnoreList() const | 184 | QStringList Definition::foldingIgnoreList() const | ||
184 | { | 185 | { | ||
185 | d->load(); | 186 | d->load(); | ||
186 | return d->foldingIgnoreList; | 187 | return d->foldingIgnoreList; | ||
187 | } | 188 | } | ||
188 | 189 | | |||
190 | QVector<Definition> Definition::includedDefinitions() const | ||||
191 | { | ||||
192 | d->load(); | ||||
193 | | ||||
194 | QVector<Definition> definitions; | ||||
195 | | ||||
196 | QQueue<Definition> queue; | ||||
197 | queue.enqueue(*this); | ||||
198 | while (!queue.isEmpty()) { | ||||
199 | const auto definition = queue.dequeue(); | ||||
200 | definitions.push_back(definition); | ||||
201 | | ||||
202 | // Iterate all context rules to find associated Definitions. This will | ||||
203 | // automatically catch other Definitions referenced with IncludeRuldes. | ||||
204 | foreach (const auto & context, definition.d->contexts) { | ||||
205 | foreach (const auto &rule, context->rules()) { | ||||
206 | if ((!definitions.contains(rule->definition())) && | ||||
207 | (!queue.contains(rule->definition()))) | ||||
208 | { | ||||
209 | queue.enqueue(rule->definition()); | ||||
210 | } | ||||
211 | } | ||||
212 | } | ||||
213 | } | ||||
214 | return definitions; | ||||
215 | } | ||||
216 | | ||||
189 | Context* DefinitionData::initialContext() const | 217 | Context* DefinitionData::initialContext() const | ||
190 | { | 218 | { | ||
191 | Q_ASSERT(!contexts.isEmpty()); | 219 | Q_ASSERT(!contexts.isEmpty()); | ||
192 | return contexts.first(); | 220 | return contexts.first(); | ||
193 | } | 221 | } | ||
194 | 222 | | |||
195 | Context* DefinitionData::contextByName(const QString& name) const | 223 | Context* DefinitionData::contextByName(const QString& name) const | ||
196 | { | 224 | { | ||
▲ Show 20 Lines • Show All 366 Lines • Show Last 20 Lines |