summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-language-server-semantic-tokens.h
blob: 8c6b916a12f7cf1625a65ac1667e5d9bbc38f108 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
#pragma once

#include "../core/slang-basic.h"
#include "slang-ast-all.h"
#include "slang-compiler.h"
#include "slang-syntax.h"
#include "slang-workspace-version.h"
#include "slang.h"

namespace Slang
{
enum class SemanticTokenType
{
    Type,
    EnumMember,
    Variable,
    Parameter,
    Function,
    Property,
    Namespace,
    Keyword,
    Macro,
    String,
    NormalText
};
extern const char* kSemanticTokenTypes[(int)SemanticTokenType::NormalText];

struct SemanticToken
{
    int line;
    int col;
    int length;
    SemanticTokenType type;
    bool operator<(const SemanticToken& other) const
    {
        if (line < other.line)
            return true;
        if (line == other.line)
            return col < other.col;
        return false;
    }
};
List<SemanticToken> getSemanticTokens(
    Linkage* linkage,
    Module* module,
    UnownedStringSlice fileName,
    DocumentVersion* doc);
List<uint32_t> getEncodedTokens(List<SemanticToken>& tokens);

} // namespace Slang