Coverage Report

Created: 2026-02-26 07:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/syntax-highlighting/src/lib/context_p.h
Line
Count
Source
1
/*
2
    SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org>
3
4
    SPDX-License-Identifier: MIT
5
*/
6
7
#ifndef KSYNTAXHIGHLIGHTING_CONTEXT_P_H
8
#define KSYNTAXHIGHLIGHTING_CONTEXT_P_H
9
10
#include "contextswitch_p.h"
11
#include "format.h"
12
#include "highlightingdata_p.hpp"
13
#include "rule_p.h"
14
15
#include <QString>
16
17
#include <vector>
18
19
namespace KSyntaxHighlighting
20
{
21
class DefinitionData;
22
23
class Context
24
{
25
public:
26
    Q_DISABLE_COPY(Context)
27
28
0
    Context(Context &&) = default;
29
    Context &operator=(Context &&) = default;
30
31
    Context(const DefinitionData &def, const HighlightingContextData &data);
32
96
    ~Context() = default;
33
34
    const QString &name() const
35
620
    {
36
620
        return m_name;
37
620
    }
38
39
    const ContextSwitch &lineEndContext() const
40
8
    {
41
8
        return m_lineEndContext;
42
8
    }
43
44
    const ContextSwitch &lineEmptyContext() const
45
0
    {
46
0
        return m_lineEmptyContext;
47
0
    }
48
49
    bool fallthrough() const
50
304
    {
51
304
        return !m_fallthroughContext.isStay();
52
304
    }
53
54
    bool hasDynamicRule() const
55
8
    {
56
8
        return m_hasDynamicRule;
57
8
    }
58
59
    bool stopEmptyLineContextSwitchLoop() const
60
0
    {
61
0
        return m_stopEmptyLineContextSwitchLoop;
62
0
    }
63
64
    const ContextSwitch &fallthroughContext() const
65
0
    {
66
0
        return m_fallthroughContext;
67
0
    }
68
69
    const Format &attributeFormat() const
70
312
    {
71
312
        return m_attributeFormat;
72
312
    }
73
74
    const std::vector<Rule::Ptr> &rules() const
75
436
    {
76
436
        return m_rules;
77
436
    }
78
79
    /**
80
     * Returns @c true, when indentationBasedFolding is enabled for the
81
     * associated Definition and when "noIndentationBasedFolding" is NOT set.
82
     */
83
    bool indentationBasedFoldingEnabled() const;
84
85
    void resolveContexts(DefinitionData &def, const HighlightingContextData &data);
86
    void resolveIncludes(DefinitionData &def);
87
88
private:
89
    enum ResolveState : quint8 { Unresolved, Resolving, Resolved };
90
91
    std::vector<Rule::Ptr> m_rules;
92
93
    QString m_name;
94
95
    ContextSwitch m_lineEndContext;
96
    ContextSwitch m_lineEmptyContext;
97
    ContextSwitch m_fallthroughContext;
98
99
    /**
100
     * resolved format for our attribute, done in constructor and resolveIncludes
101
     */
102
    Format m_attributeFormat;
103
104
    ResolveState m_resolveState = Unresolved;
105
    bool m_hasDynamicRule = false;
106
    bool m_stopEmptyLineContextSwitchLoop = true;
107
    bool m_indentationBasedFolding;
108
};
109
}
110
111
#endif // KSYNTAXHIGHLIGHTING_CONTEXT_P_H