lspsemantichighlighting.h 1.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
/*  SPDX-License-Identifier: MIT

    SPDX-FileCopyrightText: 2021 Waqar Ahmed <waqar.17a@gmail.com>

    SPDX-License-Identifier: MIT
*/
#ifndef SEMANTICTOKENMAP_H
#define SEMANTICTOKENMAP_H

10
#include <QObject>
11
12
13
14
#include <ktexteditor_version.h>

#if KTEXTEDITOR_VERSION >= QT_VERSION_CHECK(5, 79, 0)

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <vector>

#include <KTextEditor/Attribute>

namespace KTextEditor {
class Editor;
}

class SemanticHighlighting : public QObject
{
    Q_OBJECT

public:
    explicit SemanticHighlighting(QObject* parent = nullptr);

    enum TokenType : quint16
    {
        variableOtherCpp = 0,
        variableOtherLocalCpp,
        variableParameterCpp,
        entityNameFunctionCpp,
        entityNameFunctionMethodCpp,
        entityNameFunctionMethodStaticCpp,
        variableOtherFieldCpp,
        variableOtherFieldStaticCpp,
        entityNameTypeClassCpp,
        entityNameTypeEnumCpp,
        variableOtherEnummemberCpp,
        entityNameTypeTypedefCpp,
        entityNameTypeDependentCpp,
        entityNameOtherDependentCpp,
        entityNameNamespaceCpp,
        entityNameTypeTemplateCpp,
        entityNameTypeConceptCpp,
        storageTypePrimitiveCpp,
        entityNameFunctionPreprocessorCpp,
        metaDisabled
    };

    Q_SLOT void themeChange(KTextEditor::Editor* e);

    KTextEditor::Attribute::Ptr attrForScope(quint16 scopeidx) const
    {
        if (scopeidx > m_scopes.size())
            return {};
        return sharedAttrs.at(scopeidx);
    }

    void scopesToAttrVector(const QVector<QString>& scopes);

    void refresh();

    void clear()
    {
        m_scopes.clear();
        sharedAttrs.clear();
    }

private:
    std::vector<TokenType> m_scopes;
    std::vector<KTextEditor::Attribute::Ptr> sharedAttrs;
    KTextEditor::Attribute::Ptr fixedAttrs[6];
};

79
80
#endif

81
#endif // SEMANTICTOKENMAP_H