Changeset View
Changeset View
Standalone View
Standalone View
src/lib/context_p.h
Show All 22 Lines | |||||
23 | 23 | | |||
24 | #ifndef KSYNTAXHIGHLIGHTING_CONTEXT_P_H | 24 | #ifndef KSYNTAXHIGHLIGHTING_CONTEXT_P_H | ||
25 | #define KSYNTAXHIGHLIGHTING_CONTEXT_P_H | 25 | #define KSYNTAXHIGHLIGHTING_CONTEXT_P_H | ||
26 | 26 | | |||
27 | #include "rule_p.h" | 27 | #include "rule_p.h" | ||
28 | #include "contextswitch_p.h" | 28 | #include "contextswitch_p.h" | ||
29 | #include "definition.h" | 29 | #include "definition.h" | ||
30 | #include "definitionref_p.h" | 30 | #include "definitionref_p.h" | ||
31 | #include "format.h" | ||||
31 | 32 | | |||
32 | #include <QString> | 33 | #include <QString> | ||
33 | #include <QVector> | 34 | #include <QVector> | ||
34 | 35 | | |||
35 | class QXmlStreamReader; | 36 | class QXmlStreamReader; | ||
36 | 37 | | |||
37 | namespace KSyntaxHighlighting { | 38 | namespace KSyntaxHighlighting { | ||
38 | 39 | | |||
39 | class Context | 40 | class Context | ||
40 | { | 41 | { | ||
41 | public: | 42 | public: | ||
42 | Context() = default; | 43 | Context() = default; | ||
43 | ~Context() = default; | 44 | ~Context() = default; | ||
44 | 45 | | |||
45 | Definition definition() const; | 46 | Definition definition() const; | ||
46 | void setDefinition(const DefinitionRef &def); | 47 | void setDefinition(const DefinitionRef &def); | ||
47 | 48 | | |||
48 | QString name() const; | 49 | QString name() const; | ||
49 | QString attribute() const; | 50 | | ||
51 | const Format &attributeFormat() const | ||||
52 | { | ||||
53 | return m_attributeFormat; | ||||
54 | } | ||||
55 | | ||||
50 | ContextSwitch lineEndContext() const; | 56 | ContextSwitch lineEndContext() const; | ||
51 | ContextSwitch lineEmptyContext() const; | 57 | ContextSwitch lineEmptyContext() const; | ||
52 | 58 | | |||
53 | bool fallthrough() const; | 59 | bool fallthrough() const; | ||
54 | ContextSwitch fallthroughContext() const; | 60 | ContextSwitch fallthroughContext() const; | ||
55 | 61 | | |||
56 | /** | 62 | /** | ||
57 | * Returns @c true, when indentationBasedFolding is enabled for the | 63 | * Returns @c true, when indentationBasedFolding is enabled for the | ||
58 | * associated Definition and when "noIndentationBasedFolding" is NOT set. | 64 | * associated Definition and when "noIndentationBasedFolding" is NOT set. | ||
59 | */ | 65 | */ | ||
60 | bool indentationBasedFoldingEnabled() const; | 66 | bool indentationBasedFoldingEnabled() const; | ||
61 | 67 | | |||
62 | QVector<Rule::Ptr> rules() const; | 68 | QVector<Rule::Ptr> rules() const; | ||
63 | 69 | | |||
64 | /** Attempts to find the format named @p name in the | 70 | /** Attempts to find the format named @p name in the | ||
65 | * enclosing definition, or the source definition of any | 71 | * enclosing definition, or the source definition of any | ||
66 | * included rule. | 72 | * included rule. | ||
67 | */ | 73 | */ | ||
68 | Format formatByName(const QString &name) const; | 74 | Format formatByName(const QString &name) const; | ||
69 | 75 | | |||
70 | void load(QXmlStreamReader &reader); | 76 | void load(QXmlStreamReader &reader); | ||
71 | void resolveContexts(); | 77 | void resolveContexts(); | ||
72 | void resolveIncludes(); | 78 | void resolveIncludes(); | ||
79 | void resolveAttributeFormat(); | ||||
73 | 80 | | |||
74 | private: | 81 | private: | ||
75 | Q_DISABLE_COPY(Context) | 82 | Q_DISABLE_COPY(Context) | ||
76 | 83 | | |||
77 | enum ResolveState { | 84 | enum ResolveState { | ||
78 | Unknown, | 85 | Unknown, | ||
79 | Unresolved, | 86 | Unresolved, | ||
80 | Resolving, | 87 | Resolving, | ||
81 | Resolved | 88 | Resolved | ||
82 | }; | 89 | }; | ||
83 | ResolveState resolveState(); | 90 | ResolveState resolveState(); | ||
84 | 91 | | |||
85 | DefinitionRef m_def; | 92 | DefinitionRef m_def; | ||
86 | QString m_name; | 93 | QString m_name; | ||
87 | QString m_attribute; | 94 | QString m_attribute; | ||
95 | Format m_attributeFormat; | ||||
88 | ContextSwitch m_lineEndContext; | 96 | ContextSwitch m_lineEndContext; | ||
89 | ContextSwitch m_lineEmptyContext; | 97 | ContextSwitch m_lineEmptyContext; | ||
90 | ContextSwitch m_fallthroughContext; | 98 | ContextSwitch m_fallthroughContext; | ||
91 | 99 | | |||
92 | QVector<Rule::Ptr> m_rules; | 100 | QVector<Rule::Ptr> m_rules; | ||
93 | 101 | | |||
94 | ResolveState m_resolveState = Unknown; | 102 | ResolveState m_resolveState = Unknown; | ||
95 | bool m_fallthrough = false; | 103 | bool m_fallthrough = false; | ||
96 | bool m_noIndentationBasedFolding = false; | 104 | bool m_noIndentationBasedFolding = false; | ||
97 | }; | 105 | }; | ||
98 | } | 106 | } | ||
99 | 107 | | |||
100 | #endif // KSYNTAXHIGHLIGHTING_CONTEXT_P_H | 108 | #endif // KSYNTAXHIGHLIGHTING_CONTEXT_P_H |