-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathsemantic.jl
More file actions
125 lines (105 loc) · 3.5 KB
/
Copy pathsemantic.jl
File metadata and controls
125 lines (105 loc) · 3.5 KB
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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#textDocument_semanticTokens
const SemanticTokenKind = String
const SemanticTokenKinds = (
Struct="struct",
TypeParameter="typeParameter",
Parameter="parameter",
Variable="variable",
Property="property",
Function="function",
Macro="macro",
Keyword="keyword",
Comment="comment",
String="string",
Number="number",
Regexp="regexp",
Operator="operator",
)
const SemanticTokenModifiersKind = String
const SemanticTokenModifiersKinds = (
Declaration="declaration",
Definition="definition",
Modification="modification",
Documentation="documentation",
DefaultLibrary="defaultLibrary",
)
struct SemanticTokensLegend <: Outbound
tokenTypes::Vector{String} # The token types a server uses.
tokenModifiers::Vector{String} # The token modifiers a server uses.
end
const JuliaSemanticTokensLegend = SemanticTokensLegend(
collect(values(SemanticTokenKinds)),
collect(values(SemanticTokenModifiersKinds))
)
function semantic_token_encoding(token::String)::UInt32
for (i, type) in enumerate(JuliaSemanticTokensLegend.tokenTypes)
if token == type
return i - 1 # -1 to shift to 0-based indexing
end
end
end
@dict_readable struct SemanticTokensFullDelta <: Outbound
delta::Union{Bool,Missing}
end
@dict_readable struct SemanticTokensClientCapabilitiesRequests <: Outbound
range::Union{Bool,Missing}
full::Union{Bool,Missing,SemanticTokensFullDelta}
end
@dict_readable struct SemanticTokensClientCapabilities <: Outbound
dynamicRegistration::Union{Bool,Missing}
tokenTypes::Vector{String}
tokenModifiers::Vector{String}
formats::Vector{String}
overlappingTokenSupport::Union{Bool,Missing}
multilineTokenSupport::Union{Bool,Missing}
end
struct SemanticTokensOptions <: Outbound
legend::SemanticTokensLegend
range::Union{Bool,Missing}
full::Union{Bool,SemanticTokensFullDelta,Missing}
end
struct SemanticTokensRegistrationOptions <: Outbound
documentSelector::Union{DocumentSelector,Nothing}
# workDoneProgress::Union{Bool,Missing}
end
@dict_readable struct SemanticTokensParams <: Outbound
textDocument::TextDocumentIdentifier
# position::Position
workDoneToken::Union{Int,String,Missing} # ProgressToken
partialResultToken::Union{Int,String,Missing} # ProgressToken
end
struct SemanticTokens <: Outbound
resultId::Union{String,Missing}
data::Vector{UInt32}
end
SemanticTokens(data::Vector{UInt32}) = SemanticTokens(missing, data)
struct SemanticTokensPartialResult <: Outbound
data::Vector{UInt32}
end
struct SemanticTokensDeltaParams <: Outbound
workDoneToken::Union{Int,String,Missing}
partialResultToken::Union{Int,String,Missing} # ProgressToken
textDocument::TextDocumentIdentifier
previousResultId::String
end
struct SemanticTokensEdit <: Outbound
start::UInt32
deleteCount::Int
data::Union{Vector{Int},Missing}
end
struct SemanticTokensDelta <: Outbound
resultId::Union{String,Missing}
edits::Vector{SemanticTokensEdit}
end
struct SemanticTokensDeltaPartialResult <: Outbound
edits::Vector{SemanticTokensEdit}
end
struct SemanticTokensRangeParams <: Outbound
workDoneToken::Union{Int,String,Missing}
partialResultToken::Union{Int,String,Missing} # ProgressToken
textDocument::TextDocumentIdentifier
range::Range
end
struct SemanticTokensWorkspaceClientCapabilities <: Outbound
refreshSupport::Union{Bool,Missing}
end