Debian Codegraph @

runtime/queries/c-sharp/highlights.scm

raw symbols SCIP
1 (identifier) @variable
2
3 ;; Methods
4
5 (method_declaration name: (identifier) @function)
6 (local_function_statement name: (identifier) @function)
7
8 ;; Types
9
10 (interface_declaration name: (identifier) @type)
11 (class_declaration name: (identifier) @type)
12 (enum_declaration name: (identifier) @type)
13 (struct_declaration (identifier) @type)
14 (record_declaration (identifier) @type)
15 (namespace_declaration name: (identifier) @namespace)
16
17 (generic_name (identifier) @type)
18 (type_parameter (identifier) @type.parameter)
19 (parameter type: (identifier) @type)
20 (type_argument_list (identifier) @type)
21 (as_expression right: (identifier) @type)
22 (is_expression right: (identifier) @type)
23
24 (constructor_declaration name: (identifier) @constructor)
25 (destructor_declaration name: (identifier) @constructor)
26
27 (_ type: (identifier) @type)
28
29 (base_list (identifier) @type)
30
31 (predefined_type) @type.builtin
32
33 ;; Enum
34 (enum_member_declaration (identifier) @type.enum.variant)
35
36 ;; Literals
37
38 (real_literal) @constant.numeric.float
39 (integer_literal) @constant.numeric.integer
40 (character_literal) @constant.character
41
42 [
43 (string_literal)
44 (raw_string_literal)
45 (verbatim_string_literal)
46 (interpolated_string_expression)
47 (interpolation_start)
48 (interpolation_quote)
49 ] @string
50
51 (escape_sequence) @constant.character.escape
52
53 (boolean_literal) @constant.builtin.boolean
54 (null_literal) @constant.builtin
55
56 ;; Comments
57
58 (comment) @comment
59
60 ;; Tokens
61
62 [
63 ";"
64 "."
65 ","
66 ] @punctuation.delimiter
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 ".." ; range, and C# 12 collection-expression spread (`..rest`)
110 ] @operator
111
112 [
113 "("
114 ")"
115 "["
116 "]"
117 "{"
118 "}"
119 (interpolation_brace)
120 ] @punctuation.bracket
121
122 ;; Keywords
123
124 [
125 (modifier)
126 "this"
127 (implicit_type)
128 ] @keyword
129
130 [
131 "add"
132 "alias"
133 "as"
134 "base"
135 "break"
136 "catch"
137 "checked"
138 "class"
139 "continue"
140 "default"
141 "delegate"
142 "do"
143 "enum"
144 "event"
145 "explicit"
146 "extern"
147 "finally"
148 "for"
149 "foreach"
150 "global"
151 "goto"
152 "implicit"
153 "interface"
154 "is"
155 "lock"
156 "namespace"
157 "notnull"
158 "operator"
159 "params"
160 "return"
161 "remove"
162 "sizeof"
163 "stackalloc"
164 "static"
165 "struct"
166 "throw"
167 "try"
168 "typeof"
169 "unchecked"
170 "using"
171 "while"
172 "new"
173 "await"
174 "in"
175 "yield"
176 "get"
177 "set"
178 "when"
179 "out"
180 "ref"
181 "from"
182 "where"
183 "select"
184 "record"
185 "init"
186 "with"
187 "let"
188 ;; LINQ query clauses
189 "group"
190 "by"
191 "into"
192 "join"
193 "on"
194 "equals"
195 "orderby"
196 "ascending"
197 "descending"
198 ] @keyword
199
200 [
201 "case"
202 "else"
203 "if"
204 "switch"
205 "when"
206 ] @keyword.control.conditional
207
208 ;; Pattern matching combinators (`x is not null`, `> 0 and < 10`)
209
210 [
211 "and"
212 "or"
213 "not"
214 ] @keyword.operator
215
216 ;; Preprocessor directives
217
218 [
219 "#define"
220 "#undef"
221 "#if"
222 "#elif"
223 "#else"
224 "#endif"
225 "#region"
226 "#endregion"
227 "#error"
228 "#warning"
229 "#line"
230 "#nullable"
231 "#pragma"
232 ] @keyword.directive
233
234 ;; Attribute
235
236 (attribute name: (identifier) @attribute)
237 ; Named attribute argument `[Attr(Name = value)]`.
238 (attribute_argument name: (identifier) @variable.other.member)
239
240 ;; Parameters
241
242 (parameter
243 name: (identifier) @variable.parameter)
244
245 ;; Type constraints
246
247 (type_parameter_constraints_clause (identifier) @type.parameter)
248
249 ;; Member access. Before the method-call rules below so `obj.Method()` reclaims
250 ;; @function, while a plain `obj.field` stays a member.
251 (member_access_expression name: (identifier) @variable.other.member)
252
253 ;; Method calls
254
255 (invocation_expression (member_access_expression name: (identifier) @function))
256 ; Bare calls (`Method()` without a receiver)
257 (invocation_expression function: (identifier) @function)