Changeset View
Changeset View
Standalone View
Standalone View
src/lib/rule.cpp
Show All 11 Lines | 1 | /* | |||
---|---|---|---|---|---|
12 | License for more details. | 12 | License for more details. | ||
13 | 13 | | |||
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #include "rule_p.h" | 18 | #include "rule_p.h" | ||
19 | #include "definition_p.h" | 19 | #include "definition_p.h" | ||
20 | #include "repository.h" | ||||
20 | #include "ksyntaxhighlighting_logging.h" | 21 | #include "ksyntaxhighlighting_logging.h" | ||
21 | #include "xml_p.h" | 22 | #include "xml_p.h" | ||
22 | 23 | | |||
23 | #include <QString> | 24 | #include <QString> | ||
24 | #include <QXmlStreamReader> | 25 | #include <QXmlStreamReader> | ||
25 | 26 | | |||
26 | using namespace KSyntaxHighlighting; | 27 | using namespace KSyntaxHighlighting; | ||
27 | 28 | | |||
▲ Show 20 Lines • Show All 511 Lines • ▼ Show 20 Line(s) | |||||
539 | } | 540 | } | ||
540 | 541 | | |||
541 | MatchResult KeywordListRule::doMatch(const QString& text, int offset, const QStringList&) | 542 | MatchResult KeywordListRule::doMatch(const QString& text, int offset, const QStringList&) | ||
542 | { | 543 | { | ||
543 | if (offset > 0 && !isDelimiter(text.at(offset - 1))) | 544 | if (offset > 0 && !isDelimiter(text.at(offset - 1))) | ||
544 | return offset; | 545 | return offset; | ||
545 | 546 | | |||
546 | if (m_keywordList.isEmpty()) { | 547 | if (m_keywordList.isEmpty()) { | ||
547 | const auto def = definition(); | 548 | auto def = definition(); | ||
548 | Q_ASSERT(def.isValid()); | 549 | Q_ASSERT(def.isValid()); | ||
550 | const auto idx = m_listName.indexOf(QLatin1String("##")); | ||||
551 | if (idx >= 0) { | ||||
552 | auto listName = m_listName.left(idx); | ||||
553 | auto defName = m_listName.mid(idx + 2); | ||||
554 | def = DefinitionData::get(def)->repo->definitionForName(defName); | ||||
555 | auto defData = DefinitionData::get(def); | ||||
556 | if (!defData->load()) | ||||
557 | qCWarning(Log) << "Unresolved include rule for" << m_listName; | ||||
558 | m_keywordList = defData->keywordList(listName); | ||||
559 | } else { | ||||
549 | auto defData = DefinitionData::get(def); | 560 | auto defData = DefinitionData::get(def); | ||
550 | m_keywordList = defData->keywordList(m_listName); | 561 | m_keywordList = defData->keywordList(m_listName); | ||
551 | } | 562 | } | ||
563 | } | ||||
552 | 564 | | |||
553 | auto newOffset = offset; | 565 | auto newOffset = offset; | ||
554 | while (text.size() > newOffset && !isDelimiter(text.at(newOffset))) | 566 | while (text.size() > newOffset && !isDelimiter(text.at(newOffset))) | ||
555 | ++newOffset; | 567 | ++newOffset; | ||
556 | if (newOffset == offset) | 568 | if (newOffset == offset) | ||
557 | return offset; | 569 | return offset; | ||
558 | 570 | | |||
559 | if (m_hasCaseSensitivityOverride) { | 571 | if (m_hasCaseSensitivityOverride) { | ||
▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines |