Changeset View
Changeset View
Standalone View
Standalone View
src/lib/rule.cpp
Show All 16 Lines | 1 | /* | |||
---|---|---|---|---|---|
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
23 | */ | 23 | */ | ||
24 | 24 | | |||
25 | #include "context_p.h" | ||||
25 | #include "rule_p.h" | 26 | #include "rule_p.h" | ||
26 | #include "definition_p.h" | 27 | #include "definition_p.h" | ||
27 | #include "ksyntaxhighlighting_logging.h" | 28 | #include "ksyntaxhighlighting_logging.h" | ||
28 | #include "xml_p.h" | 29 | #include "xml_p.h" | ||
29 | 30 | | |||
30 | #include <QString> | 31 | #include <QString> | ||
31 | #include <QXmlStreamReader> | 32 | #include <QXmlStreamReader> | ||
32 | 33 | | |||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
100 | void Rule::setDefinition(const Definition &def) | 101 | void Rule::setDefinition(const Definition &def) | ||
101 | { | 102 | { | ||
102 | m_def = def; | 103 | m_def = def; | ||
103 | 104 | | |||
104 | // cache for DefinitionData::wordDelimiters, is accessed VERY often | 105 | // cache for DefinitionData::wordDelimiters, is accessed VERY often | ||
105 | m_wordDelimiter = &DefinitionData::get(m_def.definition())->wordDelimiters; | 106 | m_wordDelimiter = &DefinitionData::get(m_def.definition())->wordDelimiters; | ||
106 | } | 107 | } | ||
107 | 108 | | |||
108 | QString Rule::attribute() const | | |||
109 | { | | |||
110 | return m_attribute; | | |||
111 | } | | |||
112 | | ||||
113 | ContextSwitch Rule::context() const | 109 | ContextSwitch Rule::context() const | ||
114 | { | 110 | { | ||
115 | return m_context; | 111 | return m_context; | ||
116 | } | 112 | } | ||
117 | 113 | | |||
118 | bool Rule::isLookAhead() const | 114 | bool Rule::isLookAhead() const | ||
119 | { | 115 | { | ||
120 | return m_lookAhead; | 116 | return m_lookAhead; | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | |||||
202 | 198 | | |||
203 | void Rule::resolveContext() | 199 | void Rule::resolveContext() | ||
204 | { | 200 | { | ||
205 | m_context.resolve(m_def.definition()); | 201 | m_context.resolve(m_def.definition()); | ||
206 | foreach (const auto &rule, m_subRules) | 202 | foreach (const auto &rule, m_subRules) | ||
207 | rule->resolveContext(); | 203 | rule->resolveContext(); | ||
208 | } | 204 | } | ||
209 | 205 | | |||
206 | void Rule::resolveAttributeFormat(Context *lookupContext) | ||||
207 | { | ||||
208 | if (!m_attribute.isEmpty()) { | ||||
209 | m_attributeFormat = lookupContext->formatByName(m_attribute); | ||||
210 | } | ||||
211 | | ||||
212 | foreach (const auto &rule, m_subRules) { | ||||
213 | rule->resolveAttributeFormat(lookupContext); | ||||
214 | } | ||||
215 | } | ||||
216 | | ||||
210 | bool Rule::doLoad(QXmlStreamReader& reader) | 217 | bool Rule::doLoad(QXmlStreamReader& reader) | ||
211 | { | 218 | { | ||
212 | Q_UNUSED(reader); | 219 | Q_UNUSED(reader); | ||
213 | return true; | 220 | return true; | ||
214 | } | 221 | } | ||
215 | 222 | | |||
216 | MatchResult Rule::match(const QString &text, int offset, const QStringList &captures) | 223 | MatchResult Rule::match(const QString &text, int offset, const QStringList &captures) | ||
217 | { | 224 | { | ||
▲ Show 20 Lines • Show All 474 Lines • Show Last 20 Lines |