1mod actions;
4mod annotations;
5mod colors;
6mod config;
7mod context;
8mod fields;
9pub(crate) mod highlighting;
10mod hints;
11mod hooks;
12mod index;
13mod queries;
14
15use crate::diagnostics::Applicability;
16use crate::pointer::PointerSet;
17use crate::project::SourceId;
18use crate::sources::Scope;
19use crate::types::Type;
20use std::collections::{HashMap, HashSet};
21use std::ops::Range;
22use std::sync::Arc;
23
24#[derive(Clone, Debug, PartialEq, Eq)]
25pub struct Location {
26 pub source: SourceId,
27 pub range: Range<usize>,
28}
29
30#[derive(Clone, Copy, Debug, PartialEq, Eq)]
31pub enum SymbolKind {
32 Procedure,
33 ClientScript,
34 Trigger,
35 Parameter,
36 Variable,
37 Constant,
38 GameVariable,
39 Command,
40 Config,
41}
42
43#[derive(Clone, Debug)]
44pub struct Symbol {
45 pub name: String,
46 pub kind: SymbolKind,
47 pub detail: String,
48 pub documentation: String,
49 pub value_type: Option<Type>,
50 pub definition: Option<Location>,
51 pub extent: Option<Location>,
52 pub parameters: Vec<(String, Type)>,
53 pub returns: Vec<Type>,
54 pub(crate) container: Option<(SourceId, usize)>,
55 pub(crate) scope: Option<Scope>,
56 pub(crate) key: String,
57}
58
59#[derive(Clone, Debug)]
60pub struct Completion {
61 pub label: String,
62 pub detail: String,
63 pub kind: SymbolKind,
64 pub replacement: Range<usize>,
65}
66
67#[derive(Clone, Debug)]
68pub struct Hover {
69 pub range: Range<usize>,
70 pub kind: SymbolKind,
71 pub detail: String,
72 pub documentation: String,
73}
74
75#[derive(Clone, Debug)]
76pub struct SignatureHelp {
77 pub label: String,
78 pub parameters: Vec<(String, Type)>,
79 pub active_parameter: usize,
80 pub documentation: String,
81}
82
83#[derive(Clone, Debug, PartialEq, Eq)]
84pub struct TextEdit {
85 pub location: Location,
86 pub replacement: String,
87}
88
89#[derive(Clone, Debug)]
90pub struct CodeAction {
91 pub title: String,
92 pub kind: &'static str,
93 pub edits: Vec<TextEdit>,
94 pub applicability: Applicability,
95}
96
97#[derive(Clone, Debug)]
98pub struct InlayHint {
99 pub offset: usize,
100 pub label: String,
101 pub parameter: bool,
102}
103
104#[derive(Clone, Debug)]
105pub struct ScriptPointers {
106 pub range: Range<usize>,
107 pub required: PointerSet,
108}
109
110#[derive(Clone, Copy, Debug, PartialEq)]
111pub struct Color {
112 pub red: f64,
113 pub green: f64,
114 pub blue: f64,
115 pub alpha: f64,
116}
117
118#[derive(Clone, Debug, PartialEq)]
119pub struct DocumentColor {
120 pub range: Range<usize>,
121 pub color: Color,
122}
123
124#[derive(Clone, Copy, Debug, PartialEq, Eq)]
125pub enum TokenKind {
126 Keyword,
127 Function,
128 Parameter,
129 Variable,
130 Property,
131 Type,
132 Number,
133 String,
134 Comment,
135 Operator,
136 EnumMember,
137 Namespace,
138 Decorator,
139 Macro,
140}
141
142#[derive(Clone, Debug)]
143pub struct SemanticToken {
144 pub range: Range<usize>,
145 pub kind: TokenKind,
146 pub declaration: bool,
147 pub readonly: bool,
148 pub static_: bool,
149 pub default_library: bool,
150}
151
152impl SemanticToken {
153 fn new(range: Range<usize>, kind: TokenKind) -> Self {
154 Self {
155 range,
156 kind,
157 declaration: false,
158 readonly: false,
159 static_: false,
160 default_library: false,
161 }
162 }
163}
164
165pub(crate) struct Reference {
166 location: Location,
167 symbol: usize,
168 declaration: bool,
169}
170
171pub(crate) struct Configs {
173 key: u64,
174 symbols: Vec<Symbol>,
175 keys: HashMap<String, usize>,
176 references: Vec<Reference>,
177 links: Vec<index::Link>,
178 compounds: HashSet<String>,
179 config_types: fields::ConfigTypes,
180 config_problems: HashMap<SourceId, Vec<(usize, String)>>,
181}
182
183pub(crate) struct Index {
184 configs: Arc<Configs>,
185 symbols: Vec<Symbol>,
186 entities: Vec<Symbol>,
187 references: Vec<Reference>,
188 compounds: HashSet<String>,
189 hooks: HashMap<SourceId, Vec<hooks::Hook>>,
190}