aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/syntax-highlighting/src/lib/context_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/3rdparty/syntax-highlighting/src/lib/context_p.h')
-rw-r--r--src/libs/3rdparty/syntax-highlighting/src/lib/context_p.h102
1 files changed, 37 insertions, 65 deletions
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/context_p.h b/src/libs/3rdparty/syntax-highlighting/src/lib/context_p.h
index a034d0e27d..8cf0f1bfab 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/context_p.h
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/context_p.h
@@ -1,53 +1,35 @@
/*
- Copyright (C) 2016 Volker Krause <vkrause@kde.org>
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
+
+ SPDX-License-Identifier: MIT
*/
#ifndef KSYNTAXHIGHLIGHTING_CONTEXT_P_H
#define KSYNTAXHIGHLIGHTING_CONTEXT_P_H
-#include "rule_p.h"
#include "contextswitch_p.h"
-#include "definition.h"
-#include "definitionref_p.h"
#include "format.h"
+#include "highlightingdata_p.hpp"
+#include "rule_p.h"
#include <QString>
#include <vector>
-QT_BEGIN_NAMESPACE
-class QXmlStreamReader;
-QT_END_NAMESPACE
-
-namespace KSyntaxHighlighting {
+namespace KSyntaxHighlighting
+{
+class DefinitionData;
class Context
{
public:
- Context() = default;
- ~Context() = default;
+ Q_DISABLE_COPY(Context)
+
+ Context(Context &&) = default;
+ Context &operator=(Context &&) = default;
- Definition definition() const;
- void setDefinition(const DefinitionRef &def);
+ Context(const DefinitionData &def, const HighlightingContextData &data);
+ ~Context() = default;
const QString &name() const
{
@@ -66,7 +48,17 @@ public:
bool fallthrough() const
{
- return m_fallthrough;
+ return !m_fallthroughContext.isStay();
+ }
+
+ bool hasDynamicRule() const
+ {
+ return m_hasDynamicRule;
+ }
+
+ bool stopEmptyLineContextSwitchLoop() const
+ {
+ return m_stopEmptyLineContextSwitchLoop;
}
const ContextSwitch &fallthroughContext() const
@@ -90,49 +82,29 @@ public:
*/
bool indentationBasedFoldingEnabled() const;
- void load(QXmlStreamReader &reader);
- void resolveContexts();
- void resolveIncludes();
- void resolveAttributeFormat();
+ void resolveContexts(DefinitionData &def, const HighlightingContextData &data);
+ void resolveIncludes(DefinitionData &def);
private:
- Q_DISABLE_COPY(Context)
+ enum ResolveState : quint8 { Unresolved, Resolving, Resolved };
- enum ResolveState {
- Unknown,
- Unresolved,
- Resolving,
- Resolved
- };
- ResolveState resolveState();
+ std::vector<Rule::Ptr> m_rules;
- DefinitionRef m_def;
QString m_name;
- /**
- * attribute name, to lookup our format
- */
- QString m_attribute;
-
- /**
- * context to use for lookup, if != this context
- */
- const Context *m_attributeContext = nullptr;
-
- /**
- * resolved format for our attribute, done in resolveAttributeFormat
- */
- Format m_attributeFormat;
-
ContextSwitch m_lineEndContext;
ContextSwitch m_lineEmptyContext;
ContextSwitch m_fallthroughContext;
- std::vector<Rule::Ptr> m_rules;
+ /**
+ * resolved format for our attribute, done in constructor and resolveIncludes
+ */
+ Format m_attributeFormat;
- ResolveState m_resolveState = Unknown;
- bool m_fallthrough = false;
- bool m_noIndentationBasedFolding = false;
+ ResolveState m_resolveState = Unresolved;
+ bool m_hasDynamicRule = false;
+ bool m_stopEmptyLineContextSwitchLoop = true;
+ bool m_indentationBasedFolding;
};
}