@ulpi/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +200 -0
- package/dist/auth-PN7TMQHV-2W4ICG64.js +15 -0
- package/dist/chunk-247GVVKK.js +2259 -0
- package/dist/chunk-2CLNOKPA.js +793 -0
- package/dist/chunk-2HEE5OKX.js +79 -0
- package/dist/chunk-2MZER6ND.js +415 -0
- package/dist/chunk-3SBPZRB5.js +772 -0
- package/dist/chunk-4VNS5WPM.js +42 -0
- package/dist/chunk-6JCMYYBT.js +1546 -0
- package/dist/chunk-6OCEY7JY.js +422 -0
- package/dist/chunk-74WVVWJ4.js +375 -0
- package/dist/chunk-7AL4DOEJ.js +131 -0
- package/dist/chunk-7LXY5UVC.js +330 -0
- package/dist/chunk-DBMUNBNB.js +3048 -0
- package/dist/chunk-JWUUVXIV.js +13694 -0
- package/dist/chunk-KIKPIH6N.js +4048 -0
- package/dist/chunk-KLEASXUR.js +70 -0
- package/dist/chunk-MIAQVCFW.js +39 -0
- package/dist/chunk-NNUWU6CV.js +1610 -0
- package/dist/chunk-PKD4ASEM.js +115 -0
- package/dist/chunk-Q4HIY43N.js +4230 -0
- package/dist/chunk-QJ5GSMEC.js +146 -0
- package/dist/chunk-SIAQVRKG.js +2163 -0
- package/dist/chunk-SPOI23SB.js +197 -0
- package/dist/chunk-YM2HV4IA.js +505 -0
- package/dist/codemap-RRJIDBQ5.js +636 -0
- package/dist/config-EGAXXCGL.js +127 -0
- package/dist/dist-6G7JC2RA.js +90 -0
- package/dist/dist-7LHZ65GC.js +418 -0
- package/dist/dist-LZKZFPVX.js +140 -0
- package/dist/dist-R5F4MX3I.js +107 -0
- package/dist/dist-R5ZJ4LX5.js +56 -0
- package/dist/dist-RJGCUS3L.js +87 -0
- package/dist/dist-RKOGLK7R.js +151 -0
- package/dist/dist-W7K4WPAF.js +597 -0
- package/dist/export-import-4A5MWLIA.js +53 -0
- package/dist/history-ATTUKOHO.js +934 -0
- package/dist/index.js +2120 -0
- package/dist/init-AY5C2ZAS.js +393 -0
- package/dist/launchd-LF2QMSKZ.js +148 -0
- package/dist/log-TVTUXAYD.js +75 -0
- package/dist/mcp-installer-NQCGKQ23.js +124 -0
- package/dist/memory-J3G24QHS.js +406 -0
- package/dist/ollama-3XCUZMZT-FYKHW4TZ.js +7 -0
- package/dist/openai-E7G2YAHU-UYY4ZWON.js +8 -0
- package/dist/projects-ATHDD3D6.js +271 -0
- package/dist/review-ADUPV3PN.js +152 -0
- package/dist/rules-E427DKYJ.js +134 -0
- package/dist/server-MOYPE4SM-N7SE2AN7.js +18 -0
- package/dist/server-X5P6WH2M-7K2RY34N.js +11 -0
- package/dist/skills/ulpi-generate-guardian/SKILL.md +511 -0
- package/dist/skills/ulpi-generate-guardian/references/framework-rules.md +692 -0
- package/dist/skills/ulpi-generate-guardian/references/language-rules.md +596 -0
- package/dist/skills-CX73O3IV.js +76 -0
- package/dist/status-4DFHDJMN.js +66 -0
- package/dist/templates/biome.yml +24 -0
- package/dist/templates/conventional-commits.yml +18 -0
- package/dist/templates/django.yml +30 -0
- package/dist/templates/docker.yml +30 -0
- package/dist/templates/eslint.yml +13 -0
- package/dist/templates/express.yml +20 -0
- package/dist/templates/fastapi.yml +23 -0
- package/dist/templates/git-flow.yml +26 -0
- package/dist/templates/github-flow.yml +27 -0
- package/dist/templates/go.yml +33 -0
- package/dist/templates/jest.yml +24 -0
- package/dist/templates/laravel.yml +30 -0
- package/dist/templates/monorepo.yml +26 -0
- package/dist/templates/nestjs.yml +21 -0
- package/dist/templates/nextjs.yml +31 -0
- package/dist/templates/nodejs.yml +33 -0
- package/dist/templates/npm.yml +15 -0
- package/dist/templates/php.yml +25 -0
- package/dist/templates/pnpm.yml +15 -0
- package/dist/templates/prettier.yml +23 -0
- package/dist/templates/prisma.yml +21 -0
- package/dist/templates/python.yml +33 -0
- package/dist/templates/quality-of-life.yml +111 -0
- package/dist/templates/ruby.yml +25 -0
- package/dist/templates/rust.yml +34 -0
- package/dist/templates/typescript.yml +14 -0
- package/dist/templates/vitest.yml +24 -0
- package/dist/templates/yarn.yml +15 -0
- package/dist/templates-U7T6MARD.js +156 -0
- package/dist/ui-L7UAWXDY.js +167 -0
- package/dist/ui.html +698 -0
- package/dist/ulpi-RMMCUAGP-JCJ273T6.js +161 -0
- package/dist/uninstall-6SW35IK4.js +25 -0
- package/dist/update-M2B4RLGH.js +61 -0
- package/dist/version-checker-ANCS3IHR.js +10 -0
- package/package.json +92 -0
|
@@ -0,0 +1,2259 @@
|
|
|
1
|
+
import {
|
|
2
|
+
depgraphCacheFile,
|
|
3
|
+
depgraphGraphFile,
|
|
4
|
+
depgraphMetricsFile,
|
|
5
|
+
depgraphPagerankFile
|
|
6
|
+
} from "./chunk-7LXY5UVC.js";
|
|
7
|
+
|
|
8
|
+
// ../../packages/depgraph-engine/dist/index.js
|
|
9
|
+
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
10
|
+
import { dirname } from "path";
|
|
11
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
12
|
+
import { dirname as dirname2 } from "path";
|
|
13
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
14
|
+
import { dirname as dirname3 } from "path";
|
|
15
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
16
|
+
import { dirname as dirname4 } from "path";
|
|
17
|
+
var TAG_QUERIES = {
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// JavaScript — from tree-sitter-languages/javascript-tags.scm
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
javascript: `
|
|
22
|
+
(
|
|
23
|
+
(comment)* @doc
|
|
24
|
+
.
|
|
25
|
+
(method_definition
|
|
26
|
+
name: (property_identifier) @name.definition.method) @definition.method
|
|
27
|
+
(#not-eq? @name.definition.method "constructor")
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
(
|
|
31
|
+
(comment)* @doc
|
|
32
|
+
.
|
|
33
|
+
[
|
|
34
|
+
(class
|
|
35
|
+
name: (_) @name.definition.class)
|
|
36
|
+
(class_declaration
|
|
37
|
+
name: (_) @name.definition.class)
|
|
38
|
+
] @definition.class
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
(
|
|
42
|
+
(comment)* @doc
|
|
43
|
+
.
|
|
44
|
+
[
|
|
45
|
+
(function
|
|
46
|
+
name: (identifier) @name.definition.function)
|
|
47
|
+
(function_declaration
|
|
48
|
+
name: (identifier) @name.definition.function)
|
|
49
|
+
(generator_function
|
|
50
|
+
name: (identifier) @name.definition.function)
|
|
51
|
+
(generator_function_declaration
|
|
52
|
+
name: (identifier) @name.definition.function)
|
|
53
|
+
] @definition.function
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
(
|
|
57
|
+
(comment)* @doc
|
|
58
|
+
.
|
|
59
|
+
(lexical_declaration
|
|
60
|
+
(variable_declarator
|
|
61
|
+
name: (identifier) @name.definition.function
|
|
62
|
+
value: [(arrow_function) (function)]) @definition.function)
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
(
|
|
66
|
+
(comment)* @doc
|
|
67
|
+
.
|
|
68
|
+
(variable_declaration
|
|
69
|
+
(variable_declarator
|
|
70
|
+
name: (identifier) @name.definition.function
|
|
71
|
+
value: [(arrow_function) (function)]) @definition.function)
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
(assignment_expression
|
|
75
|
+
left: [
|
|
76
|
+
(identifier) @name.definition.function
|
|
77
|
+
(member_expression
|
|
78
|
+
property: (property_identifier) @name.definition.function)
|
|
79
|
+
]
|
|
80
|
+
right: [(arrow_function) (function)]
|
|
81
|
+
) @definition.function
|
|
82
|
+
|
|
83
|
+
(pair
|
|
84
|
+
key: (property_identifier) @name.definition.function
|
|
85
|
+
value: [(arrow_function) (function)]) @definition.function
|
|
86
|
+
|
|
87
|
+
(
|
|
88
|
+
(call_expression
|
|
89
|
+
function: (identifier) @name.reference.call) @reference.call
|
|
90
|
+
(#not-match? @name.reference.call "^(require)$")
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
(call_expression
|
|
94
|
+
function: (member_expression
|
|
95
|
+
property: (property_identifier) @name.reference.call)
|
|
96
|
+
arguments: (_) @reference.call)
|
|
97
|
+
|
|
98
|
+
(new_expression
|
|
99
|
+
constructor: (_) @name.reference.class) @reference.class
|
|
100
|
+
`,
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// TypeScript — JavaScript queries + tree-sitter-languages/typescript-tags.scm
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
typescript: `
|
|
105
|
+
; --- JavaScript base queries ---
|
|
106
|
+
|
|
107
|
+
(
|
|
108
|
+
(comment)* @doc
|
|
109
|
+
.
|
|
110
|
+
(method_definition
|
|
111
|
+
name: (property_identifier) @name.definition.method) @definition.method
|
|
112
|
+
(#not-eq? @name.definition.method "constructor")
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
(
|
|
116
|
+
(comment)* @doc
|
|
117
|
+
.
|
|
118
|
+
[
|
|
119
|
+
(class
|
|
120
|
+
name: (_) @name.definition.class)
|
|
121
|
+
(class_declaration
|
|
122
|
+
name: (_) @name.definition.class)
|
|
123
|
+
] @definition.class
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
(
|
|
127
|
+
(comment)* @doc
|
|
128
|
+
.
|
|
129
|
+
[
|
|
130
|
+
(function
|
|
131
|
+
name: (identifier) @name.definition.function)
|
|
132
|
+
(function_declaration
|
|
133
|
+
name: (identifier) @name.definition.function)
|
|
134
|
+
(generator_function
|
|
135
|
+
name: (identifier) @name.definition.function)
|
|
136
|
+
(generator_function_declaration
|
|
137
|
+
name: (identifier) @name.definition.function)
|
|
138
|
+
] @definition.function
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
(
|
|
142
|
+
(comment)* @doc
|
|
143
|
+
.
|
|
144
|
+
(lexical_declaration
|
|
145
|
+
(variable_declarator
|
|
146
|
+
name: (identifier) @name.definition.function
|
|
147
|
+
value: [(arrow_function) (function)]) @definition.function)
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
(
|
|
151
|
+
(comment)* @doc
|
|
152
|
+
.
|
|
153
|
+
(variable_declaration
|
|
154
|
+
(variable_declarator
|
|
155
|
+
name: (identifier) @name.definition.function
|
|
156
|
+
value: [(arrow_function) (function)]) @definition.function)
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
(assignment_expression
|
|
160
|
+
left: [
|
|
161
|
+
(identifier) @name.definition.function
|
|
162
|
+
(member_expression
|
|
163
|
+
property: (property_identifier) @name.definition.function)
|
|
164
|
+
]
|
|
165
|
+
right: [(arrow_function) (function)]
|
|
166
|
+
) @definition.function
|
|
167
|
+
|
|
168
|
+
(pair
|
|
169
|
+
key: (property_identifier) @name.definition.function
|
|
170
|
+
value: [(arrow_function) (function)]) @definition.function
|
|
171
|
+
|
|
172
|
+
(
|
|
173
|
+
(call_expression
|
|
174
|
+
function: (identifier) @name.reference.call) @reference.call
|
|
175
|
+
(#not-match? @name.reference.call "^(require)$")
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
(call_expression
|
|
179
|
+
function: (member_expression
|
|
180
|
+
property: (property_identifier) @name.reference.call)
|
|
181
|
+
arguments: (_) @reference.call)
|
|
182
|
+
|
|
183
|
+
(new_expression
|
|
184
|
+
constructor: (_) @name.reference.class) @reference.class
|
|
185
|
+
|
|
186
|
+
; --- TypeScript-specific queries ---
|
|
187
|
+
|
|
188
|
+
(function_signature
|
|
189
|
+
name: (identifier) @name.definition.function) @definition.function
|
|
190
|
+
|
|
191
|
+
(method_signature
|
|
192
|
+
name: (property_identifier) @name.definition.method) @definition.method
|
|
193
|
+
|
|
194
|
+
(abstract_method_signature
|
|
195
|
+
name: (property_identifier) @name.definition.method) @definition.method
|
|
196
|
+
|
|
197
|
+
(abstract_class_declaration
|
|
198
|
+
name: (type_identifier) @name.definition.class) @definition.class
|
|
199
|
+
|
|
200
|
+
(module
|
|
201
|
+
name: (identifier) @name.definition.module) @definition.module
|
|
202
|
+
|
|
203
|
+
(interface_declaration
|
|
204
|
+
name: (type_identifier) @name.definition.interface) @definition.interface
|
|
205
|
+
|
|
206
|
+
(type_annotation
|
|
207
|
+
(type_identifier) @name.reference.type) @reference.type
|
|
208
|
+
|
|
209
|
+
(new_expression
|
|
210
|
+
constructor: (identifier) @name.reference.class) @reference.class
|
|
211
|
+
|
|
212
|
+
(function_declaration
|
|
213
|
+
name: (identifier) @name.definition.function) @definition.function
|
|
214
|
+
|
|
215
|
+
(method_definition
|
|
216
|
+
name: (property_identifier) @name.definition.method) @definition.method
|
|
217
|
+
|
|
218
|
+
(class_declaration
|
|
219
|
+
name: (type_identifier) @name.definition.class) @definition.class
|
|
220
|
+
|
|
221
|
+
(interface_declaration
|
|
222
|
+
name: (type_identifier) @name.definition.class) @definition.class
|
|
223
|
+
|
|
224
|
+
(type_alias_declaration
|
|
225
|
+
name: (type_identifier) @name.definition.type) @definition.type
|
|
226
|
+
|
|
227
|
+
(enum_declaration
|
|
228
|
+
name: (identifier) @name.definition.enum) @definition.enum
|
|
229
|
+
`,
|
|
230
|
+
// ---------------------------------------------------------------------------
|
|
231
|
+
// TSX — same combined JS + TS queries (parsed by tsx grammar)
|
|
232
|
+
// ---------------------------------------------------------------------------
|
|
233
|
+
tsx: `
|
|
234
|
+
; --- JavaScript base queries ---
|
|
235
|
+
|
|
236
|
+
(
|
|
237
|
+
(comment)* @doc
|
|
238
|
+
.
|
|
239
|
+
(method_definition
|
|
240
|
+
name: (property_identifier) @name.definition.method) @definition.method
|
|
241
|
+
(#not-eq? @name.definition.method "constructor")
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
(
|
|
245
|
+
(comment)* @doc
|
|
246
|
+
.
|
|
247
|
+
[
|
|
248
|
+
(class
|
|
249
|
+
name: (_) @name.definition.class)
|
|
250
|
+
(class_declaration
|
|
251
|
+
name: (_) @name.definition.class)
|
|
252
|
+
] @definition.class
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
(
|
|
256
|
+
(comment)* @doc
|
|
257
|
+
.
|
|
258
|
+
[
|
|
259
|
+
(function
|
|
260
|
+
name: (identifier) @name.definition.function)
|
|
261
|
+
(function_declaration
|
|
262
|
+
name: (identifier) @name.definition.function)
|
|
263
|
+
(generator_function
|
|
264
|
+
name: (identifier) @name.definition.function)
|
|
265
|
+
(generator_function_declaration
|
|
266
|
+
name: (identifier) @name.definition.function)
|
|
267
|
+
] @definition.function
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
(
|
|
271
|
+
(comment)* @doc
|
|
272
|
+
.
|
|
273
|
+
(lexical_declaration
|
|
274
|
+
(variable_declarator
|
|
275
|
+
name: (identifier) @name.definition.function
|
|
276
|
+
value: [(arrow_function) (function)]) @definition.function)
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
(
|
|
280
|
+
(comment)* @doc
|
|
281
|
+
.
|
|
282
|
+
(variable_declaration
|
|
283
|
+
(variable_declarator
|
|
284
|
+
name: (identifier) @name.definition.function
|
|
285
|
+
value: [(arrow_function) (function)]) @definition.function)
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
(assignment_expression
|
|
289
|
+
left: [
|
|
290
|
+
(identifier) @name.definition.function
|
|
291
|
+
(member_expression
|
|
292
|
+
property: (property_identifier) @name.definition.function)
|
|
293
|
+
]
|
|
294
|
+
right: [(arrow_function) (function)]
|
|
295
|
+
) @definition.function
|
|
296
|
+
|
|
297
|
+
(pair
|
|
298
|
+
key: (property_identifier) @name.definition.function
|
|
299
|
+
value: [(arrow_function) (function)]) @definition.function
|
|
300
|
+
|
|
301
|
+
(
|
|
302
|
+
(call_expression
|
|
303
|
+
function: (identifier) @name.reference.call) @reference.call
|
|
304
|
+
(#not-match? @name.reference.call "^(require)$")
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
(call_expression
|
|
308
|
+
function: (member_expression
|
|
309
|
+
property: (property_identifier) @name.reference.call)
|
|
310
|
+
arguments: (_) @reference.call)
|
|
311
|
+
|
|
312
|
+
(new_expression
|
|
313
|
+
constructor: (_) @name.reference.class) @reference.class
|
|
314
|
+
|
|
315
|
+
; --- TypeScript-specific queries ---
|
|
316
|
+
|
|
317
|
+
(function_signature
|
|
318
|
+
name: (identifier) @name.definition.function) @definition.function
|
|
319
|
+
|
|
320
|
+
(method_signature
|
|
321
|
+
name: (property_identifier) @name.definition.method) @definition.method
|
|
322
|
+
|
|
323
|
+
(abstract_method_signature
|
|
324
|
+
name: (property_identifier) @name.definition.method) @definition.method
|
|
325
|
+
|
|
326
|
+
(abstract_class_declaration
|
|
327
|
+
name: (type_identifier) @name.definition.class) @definition.class
|
|
328
|
+
|
|
329
|
+
(module
|
|
330
|
+
name: (identifier) @name.definition.module) @definition.module
|
|
331
|
+
|
|
332
|
+
(interface_declaration
|
|
333
|
+
name: (type_identifier) @name.definition.interface) @definition.interface
|
|
334
|
+
|
|
335
|
+
(type_annotation
|
|
336
|
+
(type_identifier) @name.reference.type) @reference.type
|
|
337
|
+
|
|
338
|
+
(new_expression
|
|
339
|
+
constructor: (identifier) @name.reference.class) @reference.class
|
|
340
|
+
|
|
341
|
+
(function_declaration
|
|
342
|
+
name: (identifier) @name.definition.function) @definition.function
|
|
343
|
+
|
|
344
|
+
(method_definition
|
|
345
|
+
name: (property_identifier) @name.definition.method) @definition.method
|
|
346
|
+
|
|
347
|
+
(class_declaration
|
|
348
|
+
name: (type_identifier) @name.definition.class) @definition.class
|
|
349
|
+
|
|
350
|
+
(interface_declaration
|
|
351
|
+
name: (type_identifier) @name.definition.class) @definition.class
|
|
352
|
+
|
|
353
|
+
(type_alias_declaration
|
|
354
|
+
name: (type_identifier) @name.definition.type) @definition.type
|
|
355
|
+
|
|
356
|
+
(enum_declaration
|
|
357
|
+
name: (identifier) @name.definition.enum) @definition.enum
|
|
358
|
+
`,
|
|
359
|
+
// ---------------------------------------------------------------------------
|
|
360
|
+
// Python — from tree-sitter-languages/python-tags.scm
|
|
361
|
+
// ---------------------------------------------------------------------------
|
|
362
|
+
python: `
|
|
363
|
+
(class_definition
|
|
364
|
+
name: (identifier) @name.definition.class) @definition.class
|
|
365
|
+
|
|
366
|
+
(function_definition
|
|
367
|
+
name: (identifier) @name.definition.function) @definition.function
|
|
368
|
+
|
|
369
|
+
(call
|
|
370
|
+
function: [
|
|
371
|
+
(identifier) @name.reference.call
|
|
372
|
+
(attribute
|
|
373
|
+
attribute: (identifier) @name.reference.call)
|
|
374
|
+
]) @reference.call
|
|
375
|
+
`,
|
|
376
|
+
// ---------------------------------------------------------------------------
|
|
377
|
+
// Go — from tree-sitter-languages/go-tags.scm (stripped #strip!, #set-adjacent!)
|
|
378
|
+
// ---------------------------------------------------------------------------
|
|
379
|
+
go: `
|
|
380
|
+
(
|
|
381
|
+
(comment)* @doc
|
|
382
|
+
.
|
|
383
|
+
(function_declaration
|
|
384
|
+
name: (identifier) @name.definition.function) @definition.function
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
(
|
|
388
|
+
(comment)* @doc
|
|
389
|
+
.
|
|
390
|
+
(method_declaration
|
|
391
|
+
name: (field_identifier) @name.definition.method) @definition.method
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
(call_expression
|
|
395
|
+
function: [
|
|
396
|
+
(identifier) @name.reference.call
|
|
397
|
+
(parenthesized_expression (identifier) @name.reference.call)
|
|
398
|
+
(selector_expression field: (field_identifier) @name.reference.call)
|
|
399
|
+
(parenthesized_expression (selector_expression field: (field_identifier) @name.reference.call))
|
|
400
|
+
]) @reference.call
|
|
401
|
+
|
|
402
|
+
(type_spec
|
|
403
|
+
name: (type_identifier) @name.definition.type) @definition.type
|
|
404
|
+
|
|
405
|
+
(type_identifier) @name.reference.type @reference.type
|
|
406
|
+
`,
|
|
407
|
+
// ---------------------------------------------------------------------------
|
|
408
|
+
// PHP — from tree-sitter-languages/php-tags.scm
|
|
409
|
+
// ---------------------------------------------------------------------------
|
|
410
|
+
php: `
|
|
411
|
+
(class_declaration
|
|
412
|
+
name: (name) @name.definition.class) @definition.class
|
|
413
|
+
|
|
414
|
+
(function_definition
|
|
415
|
+
name: (name) @name.definition.function) @definition.function
|
|
416
|
+
|
|
417
|
+
(method_declaration
|
|
418
|
+
name: (name) @name.definition.function) @definition.function
|
|
419
|
+
|
|
420
|
+
(object_creation_expression
|
|
421
|
+
[
|
|
422
|
+
(qualified_name (name) @name.reference.class)
|
|
423
|
+
(variable_name (name) @name.reference.class)
|
|
424
|
+
]) @reference.class
|
|
425
|
+
|
|
426
|
+
(function_call_expression
|
|
427
|
+
function: [
|
|
428
|
+
(qualified_name (name) @name.reference.call)
|
|
429
|
+
(variable_name (name)) @name.reference.call
|
|
430
|
+
]) @reference.call
|
|
431
|
+
|
|
432
|
+
(scoped_call_expression
|
|
433
|
+
name: (name) @name.reference.call) @reference.call
|
|
434
|
+
|
|
435
|
+
(member_call_expression
|
|
436
|
+
name: (name) @name.reference.call) @reference.call
|
|
437
|
+
`,
|
|
438
|
+
// ---------------------------------------------------------------------------
|
|
439
|
+
// C — from tree-sitter-languages/c-tags.scm
|
|
440
|
+
// ---------------------------------------------------------------------------
|
|
441
|
+
c: `
|
|
442
|
+
(struct_specifier name: (type_identifier) @name.definition.class body:(_)) @definition.class
|
|
443
|
+
|
|
444
|
+
(declaration type: (union_specifier name: (type_identifier) @name.definition.class)) @definition.class
|
|
445
|
+
|
|
446
|
+
(function_declarator declarator: (identifier) @name.definition.function) @definition.function
|
|
447
|
+
|
|
448
|
+
(type_definition declarator: (type_identifier) @name.definition.type) @definition.type
|
|
449
|
+
|
|
450
|
+
(enum_specifier name: (type_identifier) @name.definition.type) @definition.type
|
|
451
|
+
`,
|
|
452
|
+
// ---------------------------------------------------------------------------
|
|
453
|
+
// C++ — from tree-sitter-languages/cpp-tags.scm
|
|
454
|
+
// ---------------------------------------------------------------------------
|
|
455
|
+
cpp: `
|
|
456
|
+
(struct_specifier name: (type_identifier) @name.definition.class body:(_)) @definition.class
|
|
457
|
+
|
|
458
|
+
(declaration type: (union_specifier name: (type_identifier) @name.definition.class)) @definition.class
|
|
459
|
+
|
|
460
|
+
(function_declarator declarator: (identifier) @name.definition.function) @definition.function
|
|
461
|
+
|
|
462
|
+
(function_declarator declarator: (field_identifier) @name.definition.function) @definition.function
|
|
463
|
+
|
|
464
|
+
(function_declarator declarator: (qualified_identifier scope: (namespace_identifier) @scope name: (identifier) @name.definition.method)) @definition.method
|
|
465
|
+
|
|
466
|
+
(type_definition declarator: (type_identifier) @name.definition.type) @definition.type
|
|
467
|
+
|
|
468
|
+
(enum_specifier name: (type_identifier) @name.definition.type) @definition.type
|
|
469
|
+
|
|
470
|
+
(class_specifier name: (type_identifier) @name.definition.class) @definition.class
|
|
471
|
+
`,
|
|
472
|
+
// ---------------------------------------------------------------------------
|
|
473
|
+
// C# — from tree-sitter-languages/c_sharp-tags.scm
|
|
474
|
+
// ---------------------------------------------------------------------------
|
|
475
|
+
csharp: `
|
|
476
|
+
(class_declaration
|
|
477
|
+
name: (identifier) @name.definition.class
|
|
478
|
+
) @definition.class
|
|
479
|
+
|
|
480
|
+
(class_declaration
|
|
481
|
+
bases: (base_list (_) @name.reference.class)
|
|
482
|
+
) @reference.class
|
|
483
|
+
|
|
484
|
+
(interface_declaration
|
|
485
|
+
name: (identifier) @name.definition.interface
|
|
486
|
+
) @definition.interface
|
|
487
|
+
|
|
488
|
+
(interface_declaration
|
|
489
|
+
bases: (base_list (_) @name.reference.interface)
|
|
490
|
+
) @reference.interface
|
|
491
|
+
|
|
492
|
+
(method_declaration
|
|
493
|
+
name: (identifier) @name.definition.method
|
|
494
|
+
) @definition.method
|
|
495
|
+
|
|
496
|
+
(object_creation_expression
|
|
497
|
+
type: (identifier) @name.reference.class
|
|
498
|
+
) @reference.class
|
|
499
|
+
|
|
500
|
+
(type_parameter_constraints_clause
|
|
501
|
+
target: (identifier) @name.reference.class
|
|
502
|
+
) @reference.class
|
|
503
|
+
|
|
504
|
+
(type_constraint
|
|
505
|
+
type: (identifier) @name.reference.class
|
|
506
|
+
) @reference.class
|
|
507
|
+
|
|
508
|
+
(variable_declaration
|
|
509
|
+
type: (identifier) @name.reference.class
|
|
510
|
+
) @reference.class
|
|
511
|
+
|
|
512
|
+
(invocation_expression
|
|
513
|
+
function:
|
|
514
|
+
(member_access_expression
|
|
515
|
+
name: (identifier) @name.reference.send
|
|
516
|
+
)
|
|
517
|
+
) @reference.send
|
|
518
|
+
|
|
519
|
+
(namespace_declaration
|
|
520
|
+
name: (identifier) @name.definition.module
|
|
521
|
+
) @definition.module
|
|
522
|
+
`,
|
|
523
|
+
// ---------------------------------------------------------------------------
|
|
524
|
+
// Java — from tree-sitter-languages/java-tags.scm
|
|
525
|
+
// ---------------------------------------------------------------------------
|
|
526
|
+
java: `
|
|
527
|
+
(class_declaration
|
|
528
|
+
name: (identifier) @name.definition.class) @definition.class
|
|
529
|
+
|
|
530
|
+
(method_declaration
|
|
531
|
+
name: (identifier) @name.definition.method) @definition.method
|
|
532
|
+
|
|
533
|
+
(method_invocation
|
|
534
|
+
name: (identifier) @name.reference.call
|
|
535
|
+
arguments: (argument_list) @reference.call)
|
|
536
|
+
|
|
537
|
+
(interface_declaration
|
|
538
|
+
name: (identifier) @name.definition.interface) @definition.interface
|
|
539
|
+
|
|
540
|
+
(type_list
|
|
541
|
+
(type_identifier) @name.reference.implementation) @reference.implementation
|
|
542
|
+
|
|
543
|
+
(object_creation_expression
|
|
544
|
+
type: (type_identifier) @name.reference.class) @reference.class
|
|
545
|
+
|
|
546
|
+
(superclass (type_identifier) @name.reference.class) @reference.class
|
|
547
|
+
`,
|
|
548
|
+
// ---------------------------------------------------------------------------
|
|
549
|
+
// Ruby — from tree-sitter-languages/ruby-tags.scm (stripped #strip!, #select-adjacent!, #is-not?)
|
|
550
|
+
// ---------------------------------------------------------------------------
|
|
551
|
+
ruby: `
|
|
552
|
+
; Method definitions
|
|
553
|
+
|
|
554
|
+
(
|
|
555
|
+
(comment)* @doc
|
|
556
|
+
.
|
|
557
|
+
[
|
|
558
|
+
(method
|
|
559
|
+
name: (_) @name.definition.method) @definition.method
|
|
560
|
+
(singleton_method
|
|
561
|
+
name: (_) @name.definition.method) @definition.method
|
|
562
|
+
]
|
|
563
|
+
)
|
|
564
|
+
|
|
565
|
+
(alias
|
|
566
|
+
name: (_) @name.definition.method) @definition.method
|
|
567
|
+
|
|
568
|
+
(setter
|
|
569
|
+
(identifier) @ignore)
|
|
570
|
+
|
|
571
|
+
; Class definitions
|
|
572
|
+
|
|
573
|
+
(
|
|
574
|
+
(comment)* @doc
|
|
575
|
+
.
|
|
576
|
+
[
|
|
577
|
+
(class
|
|
578
|
+
name: [
|
|
579
|
+
(constant) @name.definition.class
|
|
580
|
+
(scope_resolution
|
|
581
|
+
name: (_) @name.definition.class)
|
|
582
|
+
]) @definition.class
|
|
583
|
+
(singleton_class
|
|
584
|
+
value: [
|
|
585
|
+
(constant) @name.definition.class
|
|
586
|
+
(scope_resolution
|
|
587
|
+
name: (_) @name.definition.class)
|
|
588
|
+
]) @definition.class
|
|
589
|
+
]
|
|
590
|
+
)
|
|
591
|
+
|
|
592
|
+
; Module definitions
|
|
593
|
+
|
|
594
|
+
(
|
|
595
|
+
(module
|
|
596
|
+
name: [
|
|
597
|
+
(constant) @name.definition.module
|
|
598
|
+
(scope_resolution
|
|
599
|
+
name: (_) @name.definition.module)
|
|
600
|
+
]) @definition.module
|
|
601
|
+
)
|
|
602
|
+
|
|
603
|
+
; Calls
|
|
604
|
+
|
|
605
|
+
(call method: (identifier) @name.reference.call) @reference.call
|
|
606
|
+
|
|
607
|
+
(
|
|
608
|
+
[(identifier) (constant)] @name.reference.call @reference.call
|
|
609
|
+
(#not-match? @name.reference.call "^(lambda|load|require|require_relative|__FILE__|__LINE__)$")
|
|
610
|
+
)
|
|
611
|
+
`,
|
|
612
|
+
// ---------------------------------------------------------------------------
|
|
613
|
+
// Rust — from tree-sitter-languages/rust-tags.scm
|
|
614
|
+
// ---------------------------------------------------------------------------
|
|
615
|
+
rust: `
|
|
616
|
+
; ADT definitions
|
|
617
|
+
|
|
618
|
+
(struct_item
|
|
619
|
+
name: (type_identifier) @name.definition.class) @definition.class
|
|
620
|
+
|
|
621
|
+
(enum_item
|
|
622
|
+
name: (type_identifier) @name.definition.class) @definition.class
|
|
623
|
+
|
|
624
|
+
(union_item
|
|
625
|
+
name: (type_identifier) @name.definition.class) @definition.class
|
|
626
|
+
|
|
627
|
+
; type aliases
|
|
628
|
+
|
|
629
|
+
(type_item
|
|
630
|
+
name: (type_identifier) @name.definition.class) @definition.class
|
|
631
|
+
|
|
632
|
+
; method definitions
|
|
633
|
+
|
|
634
|
+
(declaration_list
|
|
635
|
+
(function_item
|
|
636
|
+
name: (identifier) @name.definition.method)) @definition.method
|
|
637
|
+
|
|
638
|
+
; function definitions
|
|
639
|
+
|
|
640
|
+
(function_item
|
|
641
|
+
name: (identifier) @name.definition.function) @definition.function
|
|
642
|
+
|
|
643
|
+
; trait definitions
|
|
644
|
+
(trait_item
|
|
645
|
+
name: (type_identifier) @name.definition.interface) @definition.interface
|
|
646
|
+
|
|
647
|
+
; module definitions
|
|
648
|
+
(mod_item
|
|
649
|
+
name: (identifier) @name.definition.module) @definition.module
|
|
650
|
+
|
|
651
|
+
; macro definitions
|
|
652
|
+
|
|
653
|
+
(macro_definition
|
|
654
|
+
name: (identifier) @name.definition.macro) @definition.macro
|
|
655
|
+
|
|
656
|
+
; references
|
|
657
|
+
|
|
658
|
+
(call_expression
|
|
659
|
+
function: (identifier) @name.reference.call) @reference.call
|
|
660
|
+
|
|
661
|
+
(call_expression
|
|
662
|
+
function: (field_expression
|
|
663
|
+
field: (field_identifier) @name.reference.call)) @reference.call
|
|
664
|
+
|
|
665
|
+
(macro_invocation
|
|
666
|
+
macro: (identifier) @name.reference.call) @reference.call
|
|
667
|
+
|
|
668
|
+
; implementations
|
|
669
|
+
|
|
670
|
+
(impl_item
|
|
671
|
+
trait: (type_identifier) @name.reference.implementation) @reference.implementation
|
|
672
|
+
|
|
673
|
+
(impl_item
|
|
674
|
+
type: (type_identifier) @name.reference.implementation
|
|
675
|
+
!trait) @reference.implementation
|
|
676
|
+
`,
|
|
677
|
+
// ---------------------------------------------------------------------------
|
|
678
|
+
// Kotlin — from tree-sitter-languages/kotlin-tags.scm
|
|
679
|
+
// ---------------------------------------------------------------------------
|
|
680
|
+
kotlin: `
|
|
681
|
+
; Definitions
|
|
682
|
+
|
|
683
|
+
(class_declaration
|
|
684
|
+
(type_identifier) @name.definition.class) @definition.class
|
|
685
|
+
|
|
686
|
+
(function_declaration
|
|
687
|
+
(simple_identifier) @name.definition.function) @definition.function
|
|
688
|
+
|
|
689
|
+
(object_declaration
|
|
690
|
+
(type_identifier) @name.definition.object) @definition.object
|
|
691
|
+
|
|
692
|
+
; References
|
|
693
|
+
|
|
694
|
+
(call_expression
|
|
695
|
+
[
|
|
696
|
+
(simple_identifier) @name.reference.call
|
|
697
|
+
(navigation_expression
|
|
698
|
+
(navigation_suffix
|
|
699
|
+
(simple_identifier) @name.reference.call))
|
|
700
|
+
]) @reference.call
|
|
701
|
+
|
|
702
|
+
(delegation_specifier
|
|
703
|
+
[
|
|
704
|
+
(user_type) @name.reference.type
|
|
705
|
+
(constructor_invocation
|
|
706
|
+
(user_type) @name.reference.type)
|
|
707
|
+
]) @reference.type
|
|
708
|
+
`,
|
|
709
|
+
// ---------------------------------------------------------------------------
|
|
710
|
+
// Scala — from tree-sitter-languages/scala-tags.scm
|
|
711
|
+
// ---------------------------------------------------------------------------
|
|
712
|
+
scala: `
|
|
713
|
+
; Definitions
|
|
714
|
+
|
|
715
|
+
(package_clause
|
|
716
|
+
name: (package_identifier) @name.definition.module) @definition.module
|
|
717
|
+
|
|
718
|
+
(trait_definition
|
|
719
|
+
name: (identifier) @name.definition.interface) @definition.interface
|
|
720
|
+
|
|
721
|
+
(enum_definition
|
|
722
|
+
name: (identifier) @name.definition.enum) @definition.enum
|
|
723
|
+
|
|
724
|
+
(simple_enum_case
|
|
725
|
+
name: (identifier) @name.definition.class) @definition.class
|
|
726
|
+
|
|
727
|
+
(full_enum_case
|
|
728
|
+
name: (identifier) @name.definition.class) @definition.class
|
|
729
|
+
|
|
730
|
+
(class_definition
|
|
731
|
+
name: (identifier) @name.definition.class) @definition.class
|
|
732
|
+
|
|
733
|
+
(object_definition
|
|
734
|
+
name: (identifier) @name.definition.object) @definition.object
|
|
735
|
+
|
|
736
|
+
(function_definition
|
|
737
|
+
name: (identifier) @name.definition.function) @definition.function
|
|
738
|
+
|
|
739
|
+
(val_definition
|
|
740
|
+
pattern: (identifier) @name.definition.variable) @definition.variable
|
|
741
|
+
|
|
742
|
+
(given_definition
|
|
743
|
+
name: (identifier) @name.definition.variable) @definition.variable
|
|
744
|
+
|
|
745
|
+
(var_definition
|
|
746
|
+
pattern: (identifier) @name.definition.variable) @definition.variable
|
|
747
|
+
|
|
748
|
+
(val_declaration
|
|
749
|
+
name: (identifier) @name.definition.variable) @definition.variable
|
|
750
|
+
|
|
751
|
+
(var_declaration
|
|
752
|
+
name: (identifier) @name.definition.variable) @definition.variable
|
|
753
|
+
|
|
754
|
+
(type_definition
|
|
755
|
+
name: (type_identifier) @name.definition.type) @definition.type
|
|
756
|
+
|
|
757
|
+
(class_parameter
|
|
758
|
+
name: (identifier) @name.definition.property) @definition.property
|
|
759
|
+
|
|
760
|
+
; References
|
|
761
|
+
|
|
762
|
+
(call_expression
|
|
763
|
+
(identifier) @name.reference.call) @reference.call
|
|
764
|
+
|
|
765
|
+
(instance_expression
|
|
766
|
+
(type_identifier) @name.reference.interface) @reference.interface
|
|
767
|
+
|
|
768
|
+
(instance_expression
|
|
769
|
+
(generic_type
|
|
770
|
+
(type_identifier) @name.reference.interface)) @reference.interface
|
|
771
|
+
|
|
772
|
+
(extends_clause
|
|
773
|
+
(type_identifier) @name.reference.class) @reference.class
|
|
774
|
+
|
|
775
|
+
(extends_clause
|
|
776
|
+
(generic_type
|
|
777
|
+
(type_identifier) @name.reference.class)) @reference.class
|
|
778
|
+
`,
|
|
779
|
+
// ---------------------------------------------------------------------------
|
|
780
|
+
// Dart — from tree-sitter-languages/dart-tags.scm
|
|
781
|
+
// ---------------------------------------------------------------------------
|
|
782
|
+
dart: `
|
|
783
|
+
(class_definition
|
|
784
|
+
name: (identifier) @name.definition.class) @definition.class
|
|
785
|
+
|
|
786
|
+
(method_signature
|
|
787
|
+
(function_signature)) @definition.method
|
|
788
|
+
|
|
789
|
+
(type_alias
|
|
790
|
+
(type_identifier) @name.definition.type) @definition.type
|
|
791
|
+
|
|
792
|
+
(method_signature
|
|
793
|
+
(getter_signature
|
|
794
|
+
name: (identifier) @name.definition.method)) @definition.method
|
|
795
|
+
|
|
796
|
+
(method_signature
|
|
797
|
+
(setter_signature
|
|
798
|
+
name: (identifier) @name.definition.method)) @definition.method
|
|
799
|
+
|
|
800
|
+
(method_signature
|
|
801
|
+
(function_signature
|
|
802
|
+
name: (identifier) @name.definition.method)) @definition.method
|
|
803
|
+
|
|
804
|
+
(method_signature
|
|
805
|
+
(factory_constructor_signature
|
|
806
|
+
(identifier) @name.definition.method)) @definition.method
|
|
807
|
+
|
|
808
|
+
(method_signature
|
|
809
|
+
(constructor_signature
|
|
810
|
+
name: (identifier) @name.definition.method)) @definition.method
|
|
811
|
+
|
|
812
|
+
(method_signature
|
|
813
|
+
(operator_signature)) @definition.method
|
|
814
|
+
|
|
815
|
+
(method_signature) @definition.method
|
|
816
|
+
|
|
817
|
+
(mixin_declaration
|
|
818
|
+
(mixin)
|
|
819
|
+
(identifier) @name.definition.mixin) @definition.mixin
|
|
820
|
+
|
|
821
|
+
(extension_declaration
|
|
822
|
+
name: (identifier) @name.definition.extension) @definition.extension
|
|
823
|
+
|
|
824
|
+
(enum_declaration
|
|
825
|
+
name: (identifier) @name.definition.enum) @definition.enum
|
|
826
|
+
|
|
827
|
+
(function_signature
|
|
828
|
+
name: (identifier) @name.definition.function) @definition.function
|
|
829
|
+
|
|
830
|
+
(new_expression
|
|
831
|
+
(type_identifier) @name.reference.class) @reference.class
|
|
832
|
+
|
|
833
|
+
(initialized_variable_definition
|
|
834
|
+
name: (identifier)
|
|
835
|
+
value: (identifier) @name.reference.class
|
|
836
|
+
value: (selector
|
|
837
|
+
"!"?
|
|
838
|
+
(argument_part
|
|
839
|
+
(arguments
|
|
840
|
+
(argument)*))?)?) @reference.class
|
|
841
|
+
|
|
842
|
+
(assignment_expression
|
|
843
|
+
left: (assignable_expression
|
|
844
|
+
(identifier)
|
|
845
|
+
(unconditional_assignable_selector
|
|
846
|
+
"."
|
|
847
|
+
(identifier) @name.reference.call))) @reference.call
|
|
848
|
+
|
|
849
|
+
(assignment_expression
|
|
850
|
+
left: (assignable_expression
|
|
851
|
+
(identifier)
|
|
852
|
+
(conditional_assignable_selector
|
|
853
|
+
"?."
|
|
854
|
+
(identifier) @name.reference.call))) @reference.call
|
|
855
|
+
|
|
856
|
+
((identifier) @name
|
|
857
|
+
(selector
|
|
858
|
+
"!"?
|
|
859
|
+
(conditional_assignable_selector
|
|
860
|
+
"?." (identifier) @name.reference.call)?
|
|
861
|
+
(unconditional_assignable_selector
|
|
862
|
+
"."? (identifier) @name.reference.call)?
|
|
863
|
+
(argument_part
|
|
864
|
+
(arguments
|
|
865
|
+
(argument)*))?)*
|
|
866
|
+
(cascade_section
|
|
867
|
+
(cascade_selector
|
|
868
|
+
(identifier)) @name.reference.call
|
|
869
|
+
(argument_part
|
|
870
|
+
(arguments
|
|
871
|
+
(argument)*))?)?) @reference.call
|
|
872
|
+
`,
|
|
873
|
+
// ---------------------------------------------------------------------------
|
|
874
|
+
// Swift — from tree-sitter-language-pack/swift-tags.scm (fallback only)
|
|
875
|
+
// ---------------------------------------------------------------------------
|
|
876
|
+
swift: `
|
|
877
|
+
(class_declaration
|
|
878
|
+
name: (type_identifier) @name.definition.class) @definition.class
|
|
879
|
+
|
|
880
|
+
(protocol_declaration
|
|
881
|
+
name: (type_identifier) @name.definition.interface) @definition.interface
|
|
882
|
+
|
|
883
|
+
(class_declaration
|
|
884
|
+
(class_body
|
|
885
|
+
[
|
|
886
|
+
(function_declaration
|
|
887
|
+
name: (simple_identifier) @name.definition.method
|
|
888
|
+
)
|
|
889
|
+
(subscript_declaration
|
|
890
|
+
(parameter (simple_identifier) @name.definition.method)
|
|
891
|
+
)
|
|
892
|
+
(init_declaration "init" @name.definition.method)
|
|
893
|
+
(deinit_declaration "deinit" @name.definition.method)
|
|
894
|
+
]
|
|
895
|
+
)
|
|
896
|
+
) @definition.method
|
|
897
|
+
|
|
898
|
+
(protocol_declaration
|
|
899
|
+
(protocol_body
|
|
900
|
+
[
|
|
901
|
+
(protocol_function_declaration
|
|
902
|
+
name: (simple_identifier) @name.definition.method
|
|
903
|
+
)
|
|
904
|
+
(subscript_declaration
|
|
905
|
+
(parameter (simple_identifier) @name.definition.method)
|
|
906
|
+
)
|
|
907
|
+
(init_declaration "init" @name.definition.method)
|
|
908
|
+
]
|
|
909
|
+
)
|
|
910
|
+
) @definition.method
|
|
911
|
+
|
|
912
|
+
(class_declaration
|
|
913
|
+
(class_body
|
|
914
|
+
[
|
|
915
|
+
(property_declaration
|
|
916
|
+
(pattern (simple_identifier) @name.definition.property)
|
|
917
|
+
)
|
|
918
|
+
]
|
|
919
|
+
)
|
|
920
|
+
) @definition.property
|
|
921
|
+
|
|
922
|
+
(property_declaration
|
|
923
|
+
(pattern (simple_identifier) @name.definition.property)
|
|
924
|
+
) @definition.property
|
|
925
|
+
|
|
926
|
+
(function_declaration
|
|
927
|
+
name: (simple_identifier) @name.definition.function) @definition.function
|
|
928
|
+
`,
|
|
929
|
+
// ---------------------------------------------------------------------------
|
|
930
|
+
// Lua — from tree-sitter-language-pack/lua-tags.scm (fallback only)
|
|
931
|
+
// ---------------------------------------------------------------------------
|
|
932
|
+
lua: `
|
|
933
|
+
(function_declaration
|
|
934
|
+
name: [
|
|
935
|
+
(identifier) @name.definition.function
|
|
936
|
+
(dot_index_expression
|
|
937
|
+
field: (identifier) @name.definition.function)
|
|
938
|
+
]) @definition.function
|
|
939
|
+
|
|
940
|
+
(function_declaration
|
|
941
|
+
name: (method_index_expression
|
|
942
|
+
method: (identifier) @name.definition.method)) @definition.method
|
|
943
|
+
|
|
944
|
+
(assignment_statement
|
|
945
|
+
(variable_list .
|
|
946
|
+
name: [
|
|
947
|
+
(identifier) @name.definition.function
|
|
948
|
+
(dot_index_expression
|
|
949
|
+
field: (identifier) @name.definition.function)
|
|
950
|
+
])
|
|
951
|
+
(expression_list .
|
|
952
|
+
value: (function_definition))) @definition.function
|
|
953
|
+
|
|
954
|
+
(table_constructor
|
|
955
|
+
(field
|
|
956
|
+
name: (identifier) @name.definition.function
|
|
957
|
+
value: (function_definition))) @definition.function
|
|
958
|
+
|
|
959
|
+
(function_call
|
|
960
|
+
name: [
|
|
961
|
+
(identifier) @name.reference.call
|
|
962
|
+
(dot_index_expression
|
|
963
|
+
field: (identifier) @name.reference.call)
|
|
964
|
+
(method_index_expression
|
|
965
|
+
method: (identifier) @name.reference.method)
|
|
966
|
+
]) @reference.call
|
|
967
|
+
`,
|
|
968
|
+
// ---------------------------------------------------------------------------
|
|
969
|
+
// Elixir — from tree-sitter-languages/elixir-tags.scm
|
|
970
|
+
// ---------------------------------------------------------------------------
|
|
971
|
+
elixir: `
|
|
972
|
+
; Definitions
|
|
973
|
+
|
|
974
|
+
; * modules and protocols
|
|
975
|
+
(call
|
|
976
|
+
target: (identifier) @ignore
|
|
977
|
+
(arguments (alias) @name.definition.module)
|
|
978
|
+
(#match? @ignore "^(defmodule|defprotocol)$")) @definition.module
|
|
979
|
+
|
|
980
|
+
; * functions/macros
|
|
981
|
+
(call
|
|
982
|
+
target: (identifier) @ignore
|
|
983
|
+
(arguments
|
|
984
|
+
[
|
|
985
|
+
; zero-arity functions with no parentheses
|
|
986
|
+
(identifier) @name.definition.function
|
|
987
|
+
; regular function clause
|
|
988
|
+
(call target: (identifier) @name.definition.function)
|
|
989
|
+
; function clause with a guard clause
|
|
990
|
+
(binary_operator
|
|
991
|
+
left: (call target: (identifier) @name.definition.function)
|
|
992
|
+
operator: "when")
|
|
993
|
+
])
|
|
994
|
+
(#match? @ignore "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$")) @definition.function
|
|
995
|
+
|
|
996
|
+
; References
|
|
997
|
+
|
|
998
|
+
; ignore calls to kernel/special-forms keywords
|
|
999
|
+
(call
|
|
1000
|
+
target: (identifier) @ignore
|
|
1001
|
+
(#match? @ignore "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defmodule|defprotocol|defimpl|defstruct|defexception|defoverridable|alias|case|cond|else|for|if|import|quote|raise|receive|require|reraise|super|throw|try|unless|unquote|unquote_splicing|use|with)$"))
|
|
1002
|
+
|
|
1003
|
+
; ignore module attributes
|
|
1004
|
+
(unary_operator
|
|
1005
|
+
operator: "@"
|
|
1006
|
+
operand: (call
|
|
1007
|
+
target: (identifier) @ignore))
|
|
1008
|
+
|
|
1009
|
+
; * function call
|
|
1010
|
+
(call
|
|
1011
|
+
target: [
|
|
1012
|
+
; local
|
|
1013
|
+
(identifier) @name.reference.call
|
|
1014
|
+
; remote
|
|
1015
|
+
(dot
|
|
1016
|
+
right: (identifier) @name.reference.call)
|
|
1017
|
+
]) @reference.call
|
|
1018
|
+
|
|
1019
|
+
; * pipe into function call
|
|
1020
|
+
(binary_operator
|
|
1021
|
+
operator: "|>"
|
|
1022
|
+
right: (identifier) @name.reference.call) @reference.call
|
|
1023
|
+
|
|
1024
|
+
; * modules
|
|
1025
|
+
(alias) @name.reference.module @reference.module
|
|
1026
|
+
`,
|
|
1027
|
+
// ---------------------------------------------------------------------------
|
|
1028
|
+
// Elm — from tree-sitter-languages/elm-tags.scm
|
|
1029
|
+
// ---------------------------------------------------------------------------
|
|
1030
|
+
elm: `
|
|
1031
|
+
(value_declaration (function_declaration_left (lower_case_identifier) @name.definition.function)) @definition.function
|
|
1032
|
+
|
|
1033
|
+
(function_call_expr (value_expr (value_qid) @name.reference.function)) @reference.function
|
|
1034
|
+
(exposed_value (lower_case_identifier) @name.reference.function) @reference.function
|
|
1035
|
+
(type_annotation ((lower_case_identifier) @name.reference.function) (colon)) @reference.function
|
|
1036
|
+
|
|
1037
|
+
(type_declaration ((upper_case_identifier) @name.definition.type)) @definition.type
|
|
1038
|
+
|
|
1039
|
+
(type_ref (upper_case_qid (upper_case_identifier) @name.reference.type)) @reference.type
|
|
1040
|
+
(exposed_type (upper_case_identifier) @name.reference.type) @reference.type
|
|
1041
|
+
|
|
1042
|
+
(type_declaration (union_variant (upper_case_identifier) @name.definition.union)) @definition.union
|
|
1043
|
+
|
|
1044
|
+
(value_expr (upper_case_qid (upper_case_identifier) @name.reference.union)) @reference.union
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
(module_declaration
|
|
1048
|
+
(upper_case_qid (upper_case_identifier)) @name.definition.module
|
|
1049
|
+
) @definition.module
|
|
1050
|
+
`,
|
|
1051
|
+
// ---------------------------------------------------------------------------
|
|
1052
|
+
// OCaml — from tree-sitter-languages/ocaml-tags.scm (stripped #strip!)
|
|
1053
|
+
// ---------------------------------------------------------------------------
|
|
1054
|
+
ocaml: `
|
|
1055
|
+
; Modules
|
|
1056
|
+
;--------
|
|
1057
|
+
|
|
1058
|
+
(
|
|
1059
|
+
(comment)? @doc .
|
|
1060
|
+
(module_definition (module_binding (module_name) @name.definition.module) @definition.module)
|
|
1061
|
+
)
|
|
1062
|
+
|
|
1063
|
+
(module_path (module_name) @name.reference.module) @reference.module
|
|
1064
|
+
|
|
1065
|
+
; Module types
|
|
1066
|
+
;--------------
|
|
1067
|
+
|
|
1068
|
+
(
|
|
1069
|
+
(comment)? @doc .
|
|
1070
|
+
(module_type_definition (module_type_name) @name.definition.interface) @definition.interface
|
|
1071
|
+
)
|
|
1072
|
+
|
|
1073
|
+
(module_type_path (module_type_name) @name.reference.implementation) @reference.implementation
|
|
1074
|
+
|
|
1075
|
+
; Functions
|
|
1076
|
+
;----------
|
|
1077
|
+
|
|
1078
|
+
(
|
|
1079
|
+
(comment)? @doc .
|
|
1080
|
+
(value_definition
|
|
1081
|
+
[
|
|
1082
|
+
(let_binding
|
|
1083
|
+
pattern: (value_name) @name.definition.function
|
|
1084
|
+
(parameter))
|
|
1085
|
+
(let_binding
|
|
1086
|
+
pattern: (value_name) @name.definition.function
|
|
1087
|
+
body: [(fun_expression) (function_expression)])
|
|
1088
|
+
] @definition.function
|
|
1089
|
+
)
|
|
1090
|
+
)
|
|
1091
|
+
|
|
1092
|
+
(
|
|
1093
|
+
(comment)? @doc .
|
|
1094
|
+
(external (value_name) @name.definition.function) @definition.function
|
|
1095
|
+
)
|
|
1096
|
+
|
|
1097
|
+
(application_expression
|
|
1098
|
+
function: (value_path (value_name) @name.reference.call)) @reference.call
|
|
1099
|
+
|
|
1100
|
+
(infix_expression
|
|
1101
|
+
left: (value_path (value_name) @name.reference.call)
|
|
1102
|
+
operator: (concat_operator) @reference.call
|
|
1103
|
+
(#eq? @reference.call "@@"))
|
|
1104
|
+
|
|
1105
|
+
(infix_expression
|
|
1106
|
+
operator: (rel_operator) @reference.call
|
|
1107
|
+
right: (value_path (value_name) @name.reference.call)
|
|
1108
|
+
(#eq? @reference.call "|>"))
|
|
1109
|
+
|
|
1110
|
+
; Operator
|
|
1111
|
+
;---------
|
|
1112
|
+
|
|
1113
|
+
(
|
|
1114
|
+
(comment)? @doc .
|
|
1115
|
+
(value_definition
|
|
1116
|
+
(let_binding
|
|
1117
|
+
pattern: (parenthesized_operator (_) @name.definition.function)) @definition.function)
|
|
1118
|
+
)
|
|
1119
|
+
|
|
1120
|
+
[
|
|
1121
|
+
(prefix_operator)
|
|
1122
|
+
(sign_operator)
|
|
1123
|
+
(pow_operator)
|
|
1124
|
+
(mult_operator)
|
|
1125
|
+
(add_operator)
|
|
1126
|
+
(concat_operator)
|
|
1127
|
+
(rel_operator)
|
|
1128
|
+
(and_operator)
|
|
1129
|
+
(or_operator)
|
|
1130
|
+
(assign_operator)
|
|
1131
|
+
(hash_operator)
|
|
1132
|
+
(indexing_operator)
|
|
1133
|
+
(let_operator)
|
|
1134
|
+
(let_and_operator)
|
|
1135
|
+
(match_operator)
|
|
1136
|
+
] @name.reference.call @reference.call
|
|
1137
|
+
|
|
1138
|
+
; Classes
|
|
1139
|
+
;--------
|
|
1140
|
+
|
|
1141
|
+
(
|
|
1142
|
+
(comment)? @doc .
|
|
1143
|
+
[
|
|
1144
|
+
(class_definition (class_binding (class_name) @name.definition.class) @definition.class)
|
|
1145
|
+
(class_type_definition (class_type_binding (class_type_name) @name.definition.class) @definition.class)
|
|
1146
|
+
]
|
|
1147
|
+
)
|
|
1148
|
+
|
|
1149
|
+
[
|
|
1150
|
+
(class_path (class_name) @name.reference.class)
|
|
1151
|
+
(class_type_path (class_type_name) @name.reference.class)
|
|
1152
|
+
] @reference.class
|
|
1153
|
+
|
|
1154
|
+
; Methods
|
|
1155
|
+
;--------
|
|
1156
|
+
|
|
1157
|
+
(
|
|
1158
|
+
(comment)? @doc .
|
|
1159
|
+
(method_definition (method_name) @name.definition.method) @definition.method
|
|
1160
|
+
)
|
|
1161
|
+
|
|
1162
|
+
(method_invocation (method_name) @name.reference.call) @reference.call
|
|
1163
|
+
`,
|
|
1164
|
+
// ---------------------------------------------------------------------------
|
|
1165
|
+
// OCaml Interface — from tree-sitter-languages/ocaml_interface-tags.scm (stripped #strip!)
|
|
1166
|
+
// ---------------------------------------------------------------------------
|
|
1167
|
+
ocaml_interface: `
|
|
1168
|
+
; Modules
|
|
1169
|
+
;--------
|
|
1170
|
+
|
|
1171
|
+
(
|
|
1172
|
+
(comment)? @doc .
|
|
1173
|
+
(module_definition
|
|
1174
|
+
(module_binding (module_name) @name) @definition.module
|
|
1175
|
+
)
|
|
1176
|
+
)
|
|
1177
|
+
|
|
1178
|
+
(module_path (module_name) @name) @reference.module
|
|
1179
|
+
(extended_module_path (module_name) @name) @reference.module
|
|
1180
|
+
|
|
1181
|
+
(
|
|
1182
|
+
(comment)? @doc .
|
|
1183
|
+
(module_type_definition (module_type_name) @name) @definition.interface
|
|
1184
|
+
)
|
|
1185
|
+
|
|
1186
|
+
(module_type_path (module_type_name) @name) @reference.implementation
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
; Classes
|
|
1190
|
+
;--------
|
|
1191
|
+
|
|
1192
|
+
(
|
|
1193
|
+
(comment)? @doc .
|
|
1194
|
+
[
|
|
1195
|
+
(class_definition
|
|
1196
|
+
(class_binding (class_name) @name) @definition.class
|
|
1197
|
+
)
|
|
1198
|
+
(class_type_definition
|
|
1199
|
+
(class_type_binding (class_type_name) @name) @definition.class
|
|
1200
|
+
)
|
|
1201
|
+
]
|
|
1202
|
+
)
|
|
1203
|
+
|
|
1204
|
+
[
|
|
1205
|
+
(class_path (class_name) @name)
|
|
1206
|
+
(class_type_path (class_type_name) @name)
|
|
1207
|
+
] @reference.class
|
|
1208
|
+
|
|
1209
|
+
(
|
|
1210
|
+
(comment)? @doc .
|
|
1211
|
+
(method_definition (method_name) @name) @definition.method
|
|
1212
|
+
)
|
|
1213
|
+
|
|
1214
|
+
(method_invocation (method_name) @name) @reference.call
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
; Types
|
|
1218
|
+
;------
|
|
1219
|
+
|
|
1220
|
+
(
|
|
1221
|
+
(comment)? @doc .
|
|
1222
|
+
(type_definition
|
|
1223
|
+
(type_binding
|
|
1224
|
+
name: [
|
|
1225
|
+
(type_constructor) @name
|
|
1226
|
+
(type_constructor_path (type_constructor) @name)
|
|
1227
|
+
]
|
|
1228
|
+
) @definition.type
|
|
1229
|
+
)
|
|
1230
|
+
)
|
|
1231
|
+
|
|
1232
|
+
(type_constructor_path (type_constructor) @name) @reference.type
|
|
1233
|
+
|
|
1234
|
+
[
|
|
1235
|
+
(constructor_declaration (constructor_name) @name)
|
|
1236
|
+
(tag_specification (tag) @name)
|
|
1237
|
+
] @definition.enum_variant
|
|
1238
|
+
|
|
1239
|
+
[
|
|
1240
|
+
(constructor_path (constructor_name) @name)
|
|
1241
|
+
(tag) @name
|
|
1242
|
+
] @reference.enum_variant
|
|
1243
|
+
|
|
1244
|
+
(field_declaration (field_name) @name) @definition.field
|
|
1245
|
+
|
|
1246
|
+
(field_path (field_name) @name) @reference.field
|
|
1247
|
+
|
|
1248
|
+
(
|
|
1249
|
+
(comment)? @doc .
|
|
1250
|
+
(external (value_name) @name) @definition.function
|
|
1251
|
+
)
|
|
1252
|
+
|
|
1253
|
+
(
|
|
1254
|
+
(comment)? @doc .
|
|
1255
|
+
(value_specification
|
|
1256
|
+
(value_name) @name.definition.function
|
|
1257
|
+
) @definition.function
|
|
1258
|
+
)
|
|
1259
|
+
`,
|
|
1260
|
+
// ---------------------------------------------------------------------------
|
|
1261
|
+
// HCL (Terraform) — from tree-sitter-languages/hcl-tags.scm
|
|
1262
|
+
// ---------------------------------------------------------------------------
|
|
1263
|
+
hcl: `
|
|
1264
|
+
;; Based on https://github.com/tree-sitter-grammars/tree-sitter-hcl/blob/main/make_grammar.js
|
|
1265
|
+
;; Which has Apache 2.0 License
|
|
1266
|
+
;; tags.scm for Terraform (tree-sitter-hcl)
|
|
1267
|
+
|
|
1268
|
+
; === Definitions: Terraform Blocks ===
|
|
1269
|
+
(block
|
|
1270
|
+
(identifier) @block_type
|
|
1271
|
+
(string_lit (template_literal) @resource_type)
|
|
1272
|
+
(string_lit (template_literal) @name.definition.resource)
|
|
1273
|
+
(body) @definition.resource
|
|
1274
|
+
) (#eq? @block_type "resource")
|
|
1275
|
+
|
|
1276
|
+
(block
|
|
1277
|
+
(identifier) @block_type
|
|
1278
|
+
(string_lit (template_literal) @name.definition.module)
|
|
1279
|
+
(body) @definition.module
|
|
1280
|
+
) (#eq? @block_type "module")
|
|
1281
|
+
|
|
1282
|
+
(block
|
|
1283
|
+
(identifier) @block_type
|
|
1284
|
+
(string_lit (template_literal) @name.definition.variable)
|
|
1285
|
+
(body) @definition.variable
|
|
1286
|
+
) (#eq? @block_type "variable")
|
|
1287
|
+
|
|
1288
|
+
(block
|
|
1289
|
+
(identifier) @block_type
|
|
1290
|
+
(string_lit (template_literal) @name.definition.output)
|
|
1291
|
+
(body) @definition.output
|
|
1292
|
+
) (#eq? @block_type "output")
|
|
1293
|
+
|
|
1294
|
+
(block
|
|
1295
|
+
(identifier) @block_type
|
|
1296
|
+
(string_lit (template_literal) @name.definition.provider)
|
|
1297
|
+
(body) @definition.provider
|
|
1298
|
+
) (#eq? @block_type "provider")
|
|
1299
|
+
|
|
1300
|
+
(block
|
|
1301
|
+
(identifier) @block_type
|
|
1302
|
+
(body
|
|
1303
|
+
(attribute
|
|
1304
|
+
(identifier) @name.definition.local
|
|
1305
|
+
(expression) @definition.local
|
|
1306
|
+
)+
|
|
1307
|
+
)
|
|
1308
|
+
) (#eq? @block_type "locals")
|
|
1309
|
+
|
|
1310
|
+
; === References: Variables, Locals, Modules, Data, Resources ===
|
|
1311
|
+
((variable_expr) @ref_type
|
|
1312
|
+
(get_attr (identifier) @name.reference.variable)
|
|
1313
|
+
) @reference.variable
|
|
1314
|
+
(#eq? @ref_type "var")
|
|
1315
|
+
|
|
1316
|
+
((variable_expr) @ref_type
|
|
1317
|
+
(get_attr (identifier) @name.reference.local)
|
|
1318
|
+
) @reference.local
|
|
1319
|
+
(#eq? @ref_type "local")
|
|
1320
|
+
|
|
1321
|
+
((variable_expr) @ref_type
|
|
1322
|
+
(get_attr (identifier) @name.reference.module)
|
|
1323
|
+
) @reference.module
|
|
1324
|
+
(#eq? @ref_type "module")
|
|
1325
|
+
|
|
1326
|
+
((variable_expr) @ref_type
|
|
1327
|
+
(get_attr (identifier) @data_source_type)
|
|
1328
|
+
(get_attr (identifier) @name.reference.data)
|
|
1329
|
+
) @reference.data
|
|
1330
|
+
(#eq? @ref_type "data")
|
|
1331
|
+
|
|
1332
|
+
((variable_expr) @resource_type
|
|
1333
|
+
(get_attr (identifier) @name.reference.resource)
|
|
1334
|
+
) @reference.resource
|
|
1335
|
+
(#not-eq? @resource_type "var")
|
|
1336
|
+
(#not-eq? @resource_type "local")
|
|
1337
|
+
(#not-eq? @resource_type "module")
|
|
1338
|
+
(#not-eq? @resource_type "data")
|
|
1339
|
+
(#not-eq? @resource_type "provider")
|
|
1340
|
+
(#not-eq? @resource_type "output")
|
|
1341
|
+
`,
|
|
1342
|
+
// ---------------------------------------------------------------------------
|
|
1343
|
+
// R — from tree-sitter-language-pack/r-tags.scm (fallback only)
|
|
1344
|
+
// ---------------------------------------------------------------------------
|
|
1345
|
+
r: `
|
|
1346
|
+
(binary_operator
|
|
1347
|
+
lhs: (identifier) @name.definition.function
|
|
1348
|
+
operator: "<-"
|
|
1349
|
+
rhs: (function_definition)
|
|
1350
|
+
) @definition.function
|
|
1351
|
+
|
|
1352
|
+
(binary_operator
|
|
1353
|
+
lhs: (identifier) @name.definition.function
|
|
1354
|
+
operator: "="
|
|
1355
|
+
rhs: (function_definition)
|
|
1356
|
+
) @definition.function
|
|
1357
|
+
|
|
1358
|
+
(call
|
|
1359
|
+
function: (identifier) @name.reference.call
|
|
1360
|
+
) @reference.call
|
|
1361
|
+
|
|
1362
|
+
(call
|
|
1363
|
+
function: (namespace_operator
|
|
1364
|
+
rhs: (identifier) @name.reference.call
|
|
1365
|
+
)
|
|
1366
|
+
) @reference.call
|
|
1367
|
+
`,
|
|
1368
|
+
// ---------------------------------------------------------------------------
|
|
1369
|
+
// D — from tree-sitter-language-pack/d-tags.scm (fallback only)
|
|
1370
|
+
// ---------------------------------------------------------------------------
|
|
1371
|
+
d: `
|
|
1372
|
+
(module_def (module_declaration (module_fqn) @name.definition.module)) @definition.module
|
|
1373
|
+
|
|
1374
|
+
(struct_declaration (struct) . (identifier) @name.definition.class) @definition.class
|
|
1375
|
+
(interface_declaration (interface) . (identifier) @name.definition.interface) @definition.interface
|
|
1376
|
+
(enum_declaration (enum) . (identifier) @name.definition.type) @definition.type
|
|
1377
|
+
|
|
1378
|
+
(class_declaration (class) . (identifier) @name.definition.class) @definition.class
|
|
1379
|
+
(constructor (this) @name.definition.method) @definition.method
|
|
1380
|
+
(destructor (this) @name.definition.method) @definition.method
|
|
1381
|
+
(postblit (this) @name.definition.method) @definition.method
|
|
1382
|
+
|
|
1383
|
+
(manifest_declarator . (identifier) @name.definition.type) @definition.type
|
|
1384
|
+
|
|
1385
|
+
(function_declaration (identifier) @name.definition.function) @definition.function
|
|
1386
|
+
|
|
1387
|
+
(union_declaration (union) . (identifier) @name.definition.type) @definition.type
|
|
1388
|
+
|
|
1389
|
+
(anonymous_enum_declaration (enum_member . (identifier) @name.definition.constant)) @definition.constant
|
|
1390
|
+
|
|
1391
|
+
(enum_declaration (enum_member . (identifier) @name.definition.constant)) @definition.constant
|
|
1392
|
+
|
|
1393
|
+
(call_expression (identifier) @name.reference.call) @reference.call
|
|
1394
|
+
(call_expression (type (template_instance (identifier) @name.reference.call))) @reference.call
|
|
1395
|
+
(parameter (type (identifier) @name.reference.class) @reference.class (identifier))
|
|
1396
|
+
|
|
1397
|
+
(variable_declaration (type (identifier) @name.reference.class) @reference.class (declarator))
|
|
1398
|
+
`,
|
|
1399
|
+
// ---------------------------------------------------------------------------
|
|
1400
|
+
// Gleam — from tree-sitter-language-pack/gleam-tags.scm (stripped #is-not?)
|
|
1401
|
+
// ---------------------------------------------------------------------------
|
|
1402
|
+
gleam: `
|
|
1403
|
+
; Modules
|
|
1404
|
+
(module) @name.reference.module @reference.module
|
|
1405
|
+
(import alias: (identifier) @name.reference.module) @reference.module
|
|
1406
|
+
(remote_type_identifier
|
|
1407
|
+
module: (identifier) @name.reference.module) @reference.module
|
|
1408
|
+
|
|
1409
|
+
; Functions
|
|
1410
|
+
(function
|
|
1411
|
+
name: (identifier) @name.definition.function) @definition.function
|
|
1412
|
+
(external_function
|
|
1413
|
+
name: (identifier) @name.definition.function) @definition.function
|
|
1414
|
+
(unqualified_import (identifier) @name.reference.function) @reference.function
|
|
1415
|
+
|
|
1416
|
+
; Types
|
|
1417
|
+
(type_definition
|
|
1418
|
+
(type_name
|
|
1419
|
+
name: (type_identifier) @name.definition.type)) @definition.type
|
|
1420
|
+
(type_definition
|
|
1421
|
+
(data_constructors
|
|
1422
|
+
(data_constructor
|
|
1423
|
+
name: (constructor_name) @name.definition.constructor))) @definition.constructor
|
|
1424
|
+
(external_type
|
|
1425
|
+
(type_name
|
|
1426
|
+
name: (type_identifier) @name.definition.type)) @definition.type
|
|
1427
|
+
|
|
1428
|
+
(type_identifier) @name.reference.type @reference.type
|
|
1429
|
+
(constructor_name) @name.reference.constructor @reference.constructor
|
|
1430
|
+
`,
|
|
1431
|
+
// ---------------------------------------------------------------------------
|
|
1432
|
+
// Solidity — from tree-sitter-language-pack/solidity-tags.scm (fallback only)
|
|
1433
|
+
// ---------------------------------------------------------------------------
|
|
1434
|
+
solidity: `
|
|
1435
|
+
;; Method and Function declarations
|
|
1436
|
+
(contract_declaration (_
|
|
1437
|
+
(function_definition
|
|
1438
|
+
name: (identifier) @name.definition.function) @definition.method))
|
|
1439
|
+
|
|
1440
|
+
(source_file
|
|
1441
|
+
(function_definition
|
|
1442
|
+
name: (identifier) @name.definition.function) @definition.function)
|
|
1443
|
+
|
|
1444
|
+
;; Contract, struct, enum and interface declarations
|
|
1445
|
+
(contract_declaration
|
|
1446
|
+
name: (identifier) @name.definition.class) @definition.class
|
|
1447
|
+
|
|
1448
|
+
(interface_declaration
|
|
1449
|
+
name: (identifier) @name.definition.interface) @definition.interface
|
|
1450
|
+
|
|
1451
|
+
(library_declaration
|
|
1452
|
+
name: (identifier) @name.definition.class) @definition.interface
|
|
1453
|
+
|
|
1454
|
+
(struct_declaration name: (identifier) @name.definition.class) @definition.class
|
|
1455
|
+
(enum_declaration name: (identifier) @name.definition.class) @definition.class
|
|
1456
|
+
(event_definition name: (identifier) @name.definition.class) @definition.class
|
|
1457
|
+
|
|
1458
|
+
;; Function calls
|
|
1459
|
+
(call_expression (expression (identifier)) @name.reference.call ) @reference.call
|
|
1460
|
+
|
|
1461
|
+
(call_expression
|
|
1462
|
+
(expression (member_expression
|
|
1463
|
+
property: (_) @name.reference.method ))) @reference.call
|
|
1464
|
+
|
|
1465
|
+
;; Log emit
|
|
1466
|
+
(emit_statement name: (_) @name.reference.class) @reference.class
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
;; Inheritance
|
|
1470
|
+
|
|
1471
|
+
(inheritance_specifier
|
|
1472
|
+
ancestor: (user_defined_type (_) @name.reference.class . )) @reference.class
|
|
1473
|
+
|
|
1474
|
+
|
|
1475
|
+
;; Imports ( note that unknown is not standardised )
|
|
1476
|
+
(import_directive
|
|
1477
|
+
import_name: (_) @name.reference.module ) @reference.unknown
|
|
1478
|
+
`,
|
|
1479
|
+
// ---------------------------------------------------------------------------
|
|
1480
|
+
// Elisp — from tree-sitter-languages/elisp-tags.scm (primary, richer)
|
|
1481
|
+
// ---------------------------------------------------------------------------
|
|
1482
|
+
elisp: `
|
|
1483
|
+
;; defun/defsubst
|
|
1484
|
+
(function_definition name: (symbol) @name.definition.function) @definition.function
|
|
1485
|
+
|
|
1486
|
+
;; Treat macros as function definitions for the sake of TAGS.
|
|
1487
|
+
(macro_definition name: (symbol) @name.definition.function) @definition.function
|
|
1488
|
+
|
|
1489
|
+
;; Match function calls
|
|
1490
|
+
(list (symbol) @name.reference.function) @reference.function
|
|
1491
|
+
`,
|
|
1492
|
+
// ---------------------------------------------------------------------------
|
|
1493
|
+
// Common Lisp — from tree-sitter-language-pack/commonlisp-tags.scm (fallback only)
|
|
1494
|
+
// ---------------------------------------------------------------------------
|
|
1495
|
+
commonlisp: `
|
|
1496
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1497
|
+
;;; Function Definitions ;;;;;;;;;;;;;;;;;;;;;;;
|
|
1498
|
+
|
|
1499
|
+
(defun_header
|
|
1500
|
+
function_name: (sym_lit) @name.definition.function) @definition.function
|
|
1501
|
+
|
|
1502
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1503
|
+
;;; Function Calls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1504
|
+
|
|
1505
|
+
;; Exclude lambda lists for function definitions
|
|
1506
|
+
(defun_header
|
|
1507
|
+
lambda_list: (list_lit . [(sym_lit) (package_lit)] @ignore))
|
|
1508
|
+
|
|
1509
|
+
;; Similar to the above, but for defmethod
|
|
1510
|
+
(defun_header
|
|
1511
|
+
lambda_list: (list_lit (list_lit . [(sym_lit) (package_lit)] @ignore)))
|
|
1512
|
+
|
|
1513
|
+
;; Exclude let/flet/labels bindings
|
|
1514
|
+
(list_lit . [(sym_lit) (package_lit)] @name.reference.call
|
|
1515
|
+
. (list_lit (list_lit . [(sym_lit) (package_lit)] @ignore))
|
|
1516
|
+
(#match? @name.reference.call
|
|
1517
|
+
"(?i)^(cl:)?(let|let\\\\*|flet|labels|macrolet|symbol-macrolet)$")
|
|
1518
|
+
)
|
|
1519
|
+
|
|
1520
|
+
;; Include all other cases - list literal with symbol as the first element
|
|
1521
|
+
(list_lit . [(sym_lit) (package_lit)] @name.reference.call) @reference.call
|
|
1522
|
+
|
|
1523
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1524
|
+
;;; classes
|
|
1525
|
+
|
|
1526
|
+
(list_lit . [(sym_lit) (package_lit)] @ignore
|
|
1527
|
+
. [(sym_lit) (package_lit)] @name.definition.class
|
|
1528
|
+
(#match? @ignore "(?i)^(cl:)?defclass$")
|
|
1529
|
+
) @definition.class
|
|
1530
|
+
|
|
1531
|
+
(list_lit . [(sym_lit) (package_lit)] @ignore
|
|
1532
|
+
. (quoting_lit [(sym_lit) (package_lit)] @name.reference.class)
|
|
1533
|
+
(#match? @ignore "(?i)^(cl:)?make-instance$")
|
|
1534
|
+
) @reference.class
|
|
1535
|
+
`,
|
|
1536
|
+
// ---------------------------------------------------------------------------
|
|
1537
|
+
// Racket — from tree-sitter-language-pack/racket-tags.scm (fallback only)
|
|
1538
|
+
// ---------------------------------------------------------------------------
|
|
1539
|
+
racket: `
|
|
1540
|
+
(list
|
|
1541
|
+
.
|
|
1542
|
+
(symbol) @reference._define
|
|
1543
|
+
(#match? @reference._define "^(define|define/contract)$")
|
|
1544
|
+
.
|
|
1545
|
+
(list
|
|
1546
|
+
.
|
|
1547
|
+
(symbol) @name.definition.function) @definition.function)
|
|
1548
|
+
|
|
1549
|
+
(list
|
|
1550
|
+
.
|
|
1551
|
+
(symbol) @name.reference.call)
|
|
1552
|
+
`,
|
|
1553
|
+
// ---------------------------------------------------------------------------
|
|
1554
|
+
// Pony — from tree-sitter-language-pack/pony-tags.scm (fallback only)
|
|
1555
|
+
// ---------------------------------------------------------------------------
|
|
1556
|
+
pony: `
|
|
1557
|
+
(
|
|
1558
|
+
(identifier) @reference.class
|
|
1559
|
+
(#match? @reference.class "^_*[A-Z][a-zA-Z0-9_]*$")
|
|
1560
|
+
)
|
|
1561
|
+
|
|
1562
|
+
(class_definition (identifier) @name.definition.class) @definition.class
|
|
1563
|
+
(actor_definition (identifier) @name.definition.class) @definition.class
|
|
1564
|
+
(primitive_definition (identifier) @name.definition.class) @definition.class
|
|
1565
|
+
(struct_definition (identifier) @name.definition.class) @definition.class
|
|
1566
|
+
(type_alias (identifier) @name.definition.class) @definition.class
|
|
1567
|
+
|
|
1568
|
+
(trait_definition (identifier) @name.definition.interface) @definition.interface
|
|
1569
|
+
(interface_definition (identifier) @name.definition.interface) @definition.interface
|
|
1570
|
+
|
|
1571
|
+
(constructor (identifier) @name.definition.method) @definition.method
|
|
1572
|
+
(method (identifier) @name.definition.method) @definition.method
|
|
1573
|
+
(behavior (identifier) @name.definition.method) @definition.method
|
|
1574
|
+
|
|
1575
|
+
(class_definition (type) @name.reference.implementation) @reference.implementation
|
|
1576
|
+
(actor_definition (type) @name.reference.implementation) @reference.implementation
|
|
1577
|
+
(primitive_definition (type) @name.reference.implementation) @reference.implementation
|
|
1578
|
+
(struct_definition (type) @name.reference.implementation) @reference.implementation
|
|
1579
|
+
(type_alias (type) @name.reference.implementation) @reference.implementation
|
|
1580
|
+
|
|
1581
|
+
; calls - not catching all possible call cases of callees for capturing the method name
|
|
1582
|
+
(call_expression callee: [(identifier) (ffi_identifier)] @name.reference.call) @reference.call
|
|
1583
|
+
(call_expression callee: (generic_expression [(identifier) (ffi_identifier)] @name.reference.call)) @reference.call
|
|
1584
|
+
(call_expression callee: (member_expression (identifier) @name.reference.call .)) @reference.call
|
|
1585
|
+
(call_expression callee: (member_expression (generic_expression [(identifier) (ffi_identifier)] @name.reference.call) .)) @reference.call
|
|
1586
|
+
(call_expression) @reference.call
|
|
1587
|
+
`,
|
|
1588
|
+
// ---------------------------------------------------------------------------
|
|
1589
|
+
// Arduino — from tree-sitter-language-pack/arduino-tags.scm (fallback only)
|
|
1590
|
+
// ---------------------------------------------------------------------------
|
|
1591
|
+
arduino: `
|
|
1592
|
+
(function_declarator
|
|
1593
|
+
declarator: (identifier) @name.definition.function) @definition.function
|
|
1594
|
+
|
|
1595
|
+
(call_expression
|
|
1596
|
+
function: (identifier) @name.reference.call) @reference.call
|
|
1597
|
+
`,
|
|
1598
|
+
// ---------------------------------------------------------------------------
|
|
1599
|
+
// QL (CodeQL) — from tree-sitter-languages/ql-tags.scm
|
|
1600
|
+
// ---------------------------------------------------------------------------
|
|
1601
|
+
ql: `
|
|
1602
|
+
(classlessPredicate
|
|
1603
|
+
name: (predicateName) @name.definition.function) @definition.function
|
|
1604
|
+
|
|
1605
|
+
(memberPredicate
|
|
1606
|
+
name: (predicateName) @name.definition.method) @definition.method
|
|
1607
|
+
|
|
1608
|
+
(aritylessPredicateExpr
|
|
1609
|
+
name: (literalId) @name.reference.call) @reference.call
|
|
1610
|
+
|
|
1611
|
+
(module
|
|
1612
|
+
name: (moduleName) @name.definition.module) @definition.module
|
|
1613
|
+
|
|
1614
|
+
(dataclass
|
|
1615
|
+
name: (className) @name.definition.class) @definition.class
|
|
1616
|
+
|
|
1617
|
+
(datatype
|
|
1618
|
+
name: (className) @name.definition.class) @definition.class
|
|
1619
|
+
|
|
1620
|
+
(datatypeBranch
|
|
1621
|
+
name: (className) @name.definition.class) @definition.class
|
|
1622
|
+
|
|
1623
|
+
(qualifiedRhs
|
|
1624
|
+
name: (predicateName) @name.reference.call) @reference.call
|
|
1625
|
+
|
|
1626
|
+
(typeExpr
|
|
1627
|
+
name: (className) @name.reference.type) @reference.type
|
|
1628
|
+
`,
|
|
1629
|
+
// ---------------------------------------------------------------------------
|
|
1630
|
+
// Chatito — from tree-sitter-language-pack/chatito-tags.scm (fallback only)
|
|
1631
|
+
// ---------------------------------------------------------------------------
|
|
1632
|
+
chatito: `
|
|
1633
|
+
; Definitions
|
|
1634
|
+
(intent_def
|
|
1635
|
+
(intent) @name.definition.intent) @definition.intent
|
|
1636
|
+
|
|
1637
|
+
(slot_def
|
|
1638
|
+
(slot) @name.definition.slot) @definition.slot
|
|
1639
|
+
|
|
1640
|
+
(alias_def
|
|
1641
|
+
(alias) @name.definition.alias) @definition.alias
|
|
1642
|
+
|
|
1643
|
+
; References
|
|
1644
|
+
(slot_ref
|
|
1645
|
+
(slot) @name.reference.slot) @reference.slot
|
|
1646
|
+
|
|
1647
|
+
(alias_ref
|
|
1648
|
+
(alias) @name.reference.alias) @reference.alias
|
|
1649
|
+
`,
|
|
1650
|
+
// ---------------------------------------------------------------------------
|
|
1651
|
+
// Properties — from tree-sitter-language-pack/properties-tags.scm (fallback only)
|
|
1652
|
+
// ---------------------------------------------------------------------------
|
|
1653
|
+
properties: `
|
|
1654
|
+
(property
|
|
1655
|
+
(key) @name.definition.property) @definition.property
|
|
1656
|
+
|
|
1657
|
+
(substitution
|
|
1658
|
+
(key) @name.reference.property) @reference.property
|
|
1659
|
+
`,
|
|
1660
|
+
// ---------------------------------------------------------------------------
|
|
1661
|
+
// udev — from tree-sitter-language-pack/udev-tags.scm (fallback only)
|
|
1662
|
+
// ---------------------------------------------------------------------------
|
|
1663
|
+
udev: `
|
|
1664
|
+
(assignment
|
|
1665
|
+
key: "LABEL"
|
|
1666
|
+
(value
|
|
1667
|
+
(content) @name.definition.label)) @definition.label
|
|
1668
|
+
|
|
1669
|
+
(assignment
|
|
1670
|
+
key: "GOTO"
|
|
1671
|
+
(value
|
|
1672
|
+
(content) @name.reference.label)) @reference.label
|
|
1673
|
+
|
|
1674
|
+
(assignment
|
|
1675
|
+
key: "ENV"
|
|
1676
|
+
(env_var) @name.definition.variable) @definition.variable
|
|
1677
|
+
|
|
1678
|
+
(match
|
|
1679
|
+
key: "ENV"
|
|
1680
|
+
(env_var) @name.reference.variable) @reference.variable
|
|
1681
|
+
|
|
1682
|
+
(var_sub
|
|
1683
|
+
(env_var) @name.reference.variable) @reference.variable
|
|
1684
|
+
`
|
|
1685
|
+
};
|
|
1686
|
+
function getTagQuery(language) {
|
|
1687
|
+
return TAG_QUERIES[language] ?? null;
|
|
1688
|
+
}
|
|
1689
|
+
function extractTagsFromTree(createQuery, rootNode, filePath, lang) {
|
|
1690
|
+
const querySource = getTagQuery(lang);
|
|
1691
|
+
if (!querySource) return [];
|
|
1692
|
+
const tags = [];
|
|
1693
|
+
let query;
|
|
1694
|
+
try {
|
|
1695
|
+
query = createQuery(querySource);
|
|
1696
|
+
} catch {
|
|
1697
|
+
return [];
|
|
1698
|
+
}
|
|
1699
|
+
try {
|
|
1700
|
+
const captures = query.captures(rootNode);
|
|
1701
|
+
for (const capture of captures) {
|
|
1702
|
+
const { name, node } = capture;
|
|
1703
|
+
let kind = null;
|
|
1704
|
+
let symbolType;
|
|
1705
|
+
if (name.startsWith("name.definition.")) {
|
|
1706
|
+
kind = "def";
|
|
1707
|
+
symbolType = name.slice("name.definition.".length);
|
|
1708
|
+
} else if (name.startsWith("name.reference.")) {
|
|
1709
|
+
kind = "ref";
|
|
1710
|
+
symbolType = name.slice("name.reference.".length);
|
|
1711
|
+
}
|
|
1712
|
+
if (kind && node.text) {
|
|
1713
|
+
tags.push({
|
|
1714
|
+
name: node.text,
|
|
1715
|
+
kind,
|
|
1716
|
+
filePath,
|
|
1717
|
+
line: node.startPosition.row + 1,
|
|
1718
|
+
// 1-indexed
|
|
1719
|
+
symbolType
|
|
1720
|
+
});
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
} finally {
|
|
1724
|
+
query.delete();
|
|
1725
|
+
}
|
|
1726
|
+
return tags;
|
|
1727
|
+
}
|
|
1728
|
+
function buildReferenceGraph(allTags, files) {
|
|
1729
|
+
const defIndex = /* @__PURE__ */ new Map();
|
|
1730
|
+
const refIndex = /* @__PURE__ */ new Map();
|
|
1731
|
+
const defCounts = /* @__PURE__ */ new Map();
|
|
1732
|
+
const refCounts = /* @__PURE__ */ new Map();
|
|
1733
|
+
for (const [filePath, tags] of allTags) {
|
|
1734
|
+
for (const tag of tags) {
|
|
1735
|
+
if (tag.kind === "def") {
|
|
1736
|
+
let defSet = defIndex.get(tag.name);
|
|
1737
|
+
if (!defSet) {
|
|
1738
|
+
defSet = /* @__PURE__ */ new Set();
|
|
1739
|
+
defIndex.set(tag.name, defSet);
|
|
1740
|
+
}
|
|
1741
|
+
defSet.add(filePath);
|
|
1742
|
+
defCounts.set(filePath, (defCounts.get(filePath) ?? 0) + 1);
|
|
1743
|
+
} else {
|
|
1744
|
+
let refSet = refIndex.get(tag.name);
|
|
1745
|
+
if (!refSet) {
|
|
1746
|
+
refSet = /* @__PURE__ */ new Set();
|
|
1747
|
+
refIndex.set(tag.name, refSet);
|
|
1748
|
+
}
|
|
1749
|
+
refSet.add(filePath);
|
|
1750
|
+
refCounts.set(filePath, (refCounts.get(filePath) ?? 0) + 1);
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
const nodes = {};
|
|
1755
|
+
for (const filePath of files) {
|
|
1756
|
+
const tags = allTags.get(filePath);
|
|
1757
|
+
const language = inferLanguage(filePath);
|
|
1758
|
+
nodes[filePath] = {
|
|
1759
|
+
filePath,
|
|
1760
|
+
language,
|
|
1761
|
+
sizeBytes: 0,
|
|
1762
|
+
// Caller may enrich later
|
|
1763
|
+
definitionCount: defCounts.get(filePath) ?? 0,
|
|
1764
|
+
referenceCount: refCounts.get(filePath) ?? 0
|
|
1765
|
+
};
|
|
1766
|
+
}
|
|
1767
|
+
const edgeMap = /* @__PURE__ */ new Map();
|
|
1768
|
+
for (const [symbolName, refFiles] of refIndex) {
|
|
1769
|
+
const defFiles = defIndex.get(symbolName);
|
|
1770
|
+
if (!defFiles) continue;
|
|
1771
|
+
for (const refFile of refFiles) {
|
|
1772
|
+
for (const defFile of defFiles) {
|
|
1773
|
+
if (refFile === defFile) continue;
|
|
1774
|
+
if (!nodes[refFile] || !nodes[defFile]) continue;
|
|
1775
|
+
const key = `${refFile}\0${defFile}`;
|
|
1776
|
+
let symbols = edgeMap.get(key);
|
|
1777
|
+
if (!symbols) {
|
|
1778
|
+
symbols = /* @__PURE__ */ new Set();
|
|
1779
|
+
edgeMap.set(key, symbols);
|
|
1780
|
+
}
|
|
1781
|
+
symbols.add(symbolName);
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
const edges = [];
|
|
1786
|
+
for (const [key, symbols] of edgeMap) {
|
|
1787
|
+
const [source, target] = key.split("\0");
|
|
1788
|
+
edges.push({
|
|
1789
|
+
source,
|
|
1790
|
+
target,
|
|
1791
|
+
symbols: Array.from(symbols).sort()
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
return {
|
|
1795
|
+
version: 1,
|
|
1796
|
+
nodes,
|
|
1797
|
+
edges,
|
|
1798
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1801
|
+
function getIncomingEdges(graph, filePath) {
|
|
1802
|
+
return graph.edges.filter((e) => e.target === filePath);
|
|
1803
|
+
}
|
|
1804
|
+
function getOutgoingEdges(graph, filePath) {
|
|
1805
|
+
return graph.edges.filter((e) => e.source === filePath);
|
|
1806
|
+
}
|
|
1807
|
+
function getTransitiveDeps(graph, filePath, maxDepth = 10) {
|
|
1808
|
+
return bfsTraversal(graph, filePath, "outgoing", maxDepth);
|
|
1809
|
+
}
|
|
1810
|
+
function getTransitiveRdeps(graph, filePath, maxDepth = 10) {
|
|
1811
|
+
return bfsTraversal(graph, filePath, "incoming", maxDepth);
|
|
1812
|
+
}
|
|
1813
|
+
function saveGraph(graph, projectDir, branch) {
|
|
1814
|
+
const filePath = depgraphGraphFile(projectDir, branch);
|
|
1815
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
1816
|
+
writeFileSync(filePath, JSON.stringify(graph, null, 2), "utf-8");
|
|
1817
|
+
}
|
|
1818
|
+
function loadGraph(projectDir, branch) {
|
|
1819
|
+
const filePath = depgraphGraphFile(projectDir, branch);
|
|
1820
|
+
try {
|
|
1821
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
1822
|
+
return JSON.parse(raw);
|
|
1823
|
+
} catch {
|
|
1824
|
+
return null;
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
function bfsTraversal(graph, startFile, direction, maxDepth) {
|
|
1828
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1829
|
+
const queue = [{ file: startFile, depth: 0 }];
|
|
1830
|
+
visited.add(startFile);
|
|
1831
|
+
const adjacency = /* @__PURE__ */ new Map();
|
|
1832
|
+
for (const edge of graph.edges) {
|
|
1833
|
+
const from = direction === "outgoing" ? edge.source : edge.target;
|
|
1834
|
+
const to = direction === "outgoing" ? edge.target : edge.source;
|
|
1835
|
+
let neighbors = adjacency.get(from);
|
|
1836
|
+
if (!neighbors) {
|
|
1837
|
+
neighbors = [];
|
|
1838
|
+
adjacency.set(from, neighbors);
|
|
1839
|
+
}
|
|
1840
|
+
neighbors.push(to);
|
|
1841
|
+
}
|
|
1842
|
+
while (queue.length > 0) {
|
|
1843
|
+
const { file, depth } = queue.shift();
|
|
1844
|
+
if (depth >= maxDepth) continue;
|
|
1845
|
+
const neighbors = adjacency.get(file);
|
|
1846
|
+
if (!neighbors) continue;
|
|
1847
|
+
for (const neighbor of neighbors) {
|
|
1848
|
+
if (!visited.has(neighbor)) {
|
|
1849
|
+
visited.add(neighbor);
|
|
1850
|
+
queue.push({ file: neighbor, depth: depth + 1 });
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
visited.delete(startFile);
|
|
1855
|
+
return Array.from(visited);
|
|
1856
|
+
}
|
|
1857
|
+
function inferLanguage(filePath) {
|
|
1858
|
+
const ext = filePath.split(".").pop()?.toLowerCase() ?? "";
|
|
1859
|
+
const map = {
|
|
1860
|
+
js: "javascript",
|
|
1861
|
+
jsx: "javascript",
|
|
1862
|
+
mjs: "javascript",
|
|
1863
|
+
cjs: "javascript",
|
|
1864
|
+
ts: "typescript",
|
|
1865
|
+
mts: "typescript",
|
|
1866
|
+
cts: "typescript",
|
|
1867
|
+
tsx: "tsx",
|
|
1868
|
+
py: "python",
|
|
1869
|
+
go: "go",
|
|
1870
|
+
php: "php",
|
|
1871
|
+
rb: "ruby",
|
|
1872
|
+
rs: "rust",
|
|
1873
|
+
java: "java",
|
|
1874
|
+
c: "c",
|
|
1875
|
+
cpp: "cpp",
|
|
1876
|
+
h: "c",
|
|
1877
|
+
hpp: "cpp",
|
|
1878
|
+
cs: "csharp",
|
|
1879
|
+
html: "html",
|
|
1880
|
+
css: "css"
|
|
1881
|
+
};
|
|
1882
|
+
return map[ext] ?? ext;
|
|
1883
|
+
}
|
|
1884
|
+
var DEFAULT_DAMPING = 0.85;
|
|
1885
|
+
var DEFAULT_MAX_ITERATIONS = 100;
|
|
1886
|
+
var DEFAULT_CONVERGENCE = 1e-6;
|
|
1887
|
+
var ACTIVE_FILE_BOOST = 100;
|
|
1888
|
+
var MENTIONED_FILE_BOOST = 5;
|
|
1889
|
+
var MENTIONED_IDENTIFIER_BOOST = 10;
|
|
1890
|
+
function computePageRank(graph, config, personalization) {
|
|
1891
|
+
const d = config?.dampingFactor ?? DEFAULT_DAMPING;
|
|
1892
|
+
const maxIter = config?.maxIterations ?? DEFAULT_MAX_ITERATIONS;
|
|
1893
|
+
const threshold = config?.convergenceThreshold ?? DEFAULT_CONVERGENCE;
|
|
1894
|
+
const files = Object.keys(graph.nodes);
|
|
1895
|
+
const N = files.length;
|
|
1896
|
+
if (N === 0) {
|
|
1897
|
+
return { ranks: {}, iterations: 0, converged: true, dampingFactor: d };
|
|
1898
|
+
}
|
|
1899
|
+
const outNeighbors = /* @__PURE__ */ new Map();
|
|
1900
|
+
const outDegree = /* @__PURE__ */ new Map();
|
|
1901
|
+
for (const file of files) {
|
|
1902
|
+
outNeighbors.set(file, []);
|
|
1903
|
+
outDegree.set(file, 0);
|
|
1904
|
+
}
|
|
1905
|
+
for (const edge of graph.edges) {
|
|
1906
|
+
const neighbors = outNeighbors.get(edge.source);
|
|
1907
|
+
if (neighbors) {
|
|
1908
|
+
neighbors.push(edge.target);
|
|
1909
|
+
outDegree.set(edge.source, (outDegree.get(edge.source) ?? 0) + 1);
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
const inNeighbors = /* @__PURE__ */ new Map();
|
|
1913
|
+
for (const file of files) {
|
|
1914
|
+
inNeighbors.set(file, []);
|
|
1915
|
+
}
|
|
1916
|
+
for (const edge of graph.edges) {
|
|
1917
|
+
const incoming = inNeighbors.get(edge.target);
|
|
1918
|
+
if (incoming) {
|
|
1919
|
+
incoming.push(edge.source);
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
const personalVector = buildPersonalizationVector(files, graph, personalization);
|
|
1923
|
+
let ranks = /* @__PURE__ */ new Map();
|
|
1924
|
+
const initial = 1 / N;
|
|
1925
|
+
for (const file of files) {
|
|
1926
|
+
ranks.set(file, initial);
|
|
1927
|
+
}
|
|
1928
|
+
let converged = false;
|
|
1929
|
+
let iterations = 0;
|
|
1930
|
+
for (let iter = 0; iter < maxIter; iter++) {
|
|
1931
|
+
iterations = iter + 1;
|
|
1932
|
+
const newRanks = /* @__PURE__ */ new Map();
|
|
1933
|
+
let danglingSum = 0;
|
|
1934
|
+
for (const file of files) {
|
|
1935
|
+
if ((outDegree.get(file) ?? 0) === 0) {
|
|
1936
|
+
danglingSum += ranks.get(file) ?? 0;
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
const personalTotal = personalVector ? Array.from(personalVector.values()).reduce((a, b) => a + b, 0) : 0;
|
|
1940
|
+
for (const file of files) {
|
|
1941
|
+
let linkSum = 0;
|
|
1942
|
+
const incoming = inNeighbors.get(file) ?? [];
|
|
1943
|
+
for (const src of incoming) {
|
|
1944
|
+
const srcRank = ranks.get(src) ?? 0;
|
|
1945
|
+
const srcDegree = outDegree.get(src) ?? 1;
|
|
1946
|
+
linkSum += srcRank / srcDegree;
|
|
1947
|
+
}
|
|
1948
|
+
const danglingContrib = danglingSum / N;
|
|
1949
|
+
let teleport;
|
|
1950
|
+
if (personalVector && personalTotal > 0) {
|
|
1951
|
+
teleport = (personalVector.get(file) ?? 0) / personalTotal;
|
|
1952
|
+
} else {
|
|
1953
|
+
teleport = 1 / N;
|
|
1954
|
+
}
|
|
1955
|
+
const rank = (1 - d) * teleport + d * (linkSum + danglingContrib);
|
|
1956
|
+
newRanks.set(file, rank);
|
|
1957
|
+
}
|
|
1958
|
+
let diff = 0;
|
|
1959
|
+
for (const file of files) {
|
|
1960
|
+
diff += Math.abs((newRanks.get(file) ?? 0) - (ranks.get(file) ?? 0));
|
|
1961
|
+
}
|
|
1962
|
+
ranks = newRanks;
|
|
1963
|
+
if (diff < threshold) {
|
|
1964
|
+
converged = true;
|
|
1965
|
+
break;
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
const result = {};
|
|
1969
|
+
for (const [file, rank] of ranks) {
|
|
1970
|
+
result[file] = rank;
|
|
1971
|
+
}
|
|
1972
|
+
return {
|
|
1973
|
+
ranks: result,
|
|
1974
|
+
iterations,
|
|
1975
|
+
converged,
|
|
1976
|
+
dampingFactor: d
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1979
|
+
function savePageRank(result, projectDir, branch) {
|
|
1980
|
+
const filePath = depgraphPagerankFile(projectDir, branch);
|
|
1981
|
+
mkdirSync2(dirname2(filePath), { recursive: true });
|
|
1982
|
+
writeFileSync2(filePath, JSON.stringify(result, null, 2), "utf-8");
|
|
1983
|
+
}
|
|
1984
|
+
function loadPageRank(projectDir, branch) {
|
|
1985
|
+
const filePath = depgraphPagerankFile(projectDir, branch);
|
|
1986
|
+
try {
|
|
1987
|
+
const raw = readFileSync2(filePath, "utf-8");
|
|
1988
|
+
return JSON.parse(raw);
|
|
1989
|
+
} catch {
|
|
1990
|
+
return null;
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
function loadPageRankMap(projectDir, branch) {
|
|
1994
|
+
const result = loadPageRank(projectDir, branch);
|
|
1995
|
+
if (!result) return null;
|
|
1996
|
+
return new Map(Object.entries(result.ranks));
|
|
1997
|
+
}
|
|
1998
|
+
function buildPersonalizationVector(files, graph, personalization) {
|
|
1999
|
+
if (!personalization) return null;
|
|
2000
|
+
const {
|
|
2001
|
+
activeFiles = [],
|
|
2002
|
+
mentionedFiles = [],
|
|
2003
|
+
mentionedIdentifiers = []
|
|
2004
|
+
} = personalization;
|
|
2005
|
+
if (activeFiles.length === 0 && mentionedFiles.length === 0 && mentionedIdentifiers.length === 0) {
|
|
2006
|
+
return null;
|
|
2007
|
+
}
|
|
2008
|
+
const vector = /* @__PURE__ */ new Map();
|
|
2009
|
+
for (const file of files) {
|
|
2010
|
+
vector.set(file, 1);
|
|
2011
|
+
}
|
|
2012
|
+
const activeSet = new Set(activeFiles);
|
|
2013
|
+
for (const file of files) {
|
|
2014
|
+
if (activeSet.has(file)) {
|
|
2015
|
+
vector.set(file, (vector.get(file) ?? 0) + ACTIVE_FILE_BOOST);
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
const mentionedSet = new Set(mentionedFiles);
|
|
2019
|
+
for (const file of files) {
|
|
2020
|
+
if (mentionedSet.has(file)) {
|
|
2021
|
+
vector.set(file, (vector.get(file) ?? 0) + MENTIONED_FILE_BOOST);
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
if (mentionedIdentifiers.length > 0) {
|
|
2025
|
+
const identSet = new Set(mentionedIdentifiers);
|
|
2026
|
+
for (const edge of graph.edges) {
|
|
2027
|
+
for (const sym of edge.symbols) {
|
|
2028
|
+
if (identSet.has(sym)) {
|
|
2029
|
+
vector.set(
|
|
2030
|
+
edge.target,
|
|
2031
|
+
(vector.get(edge.target) ?? 0) + MENTIONED_IDENTIFIER_BOOST
|
|
2032
|
+
);
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
return vector;
|
|
2038
|
+
}
|
|
2039
|
+
function detectCycles(graph) {
|
|
2040
|
+
const files = Object.keys(graph.nodes);
|
|
2041
|
+
const adj = /* @__PURE__ */ new Map();
|
|
2042
|
+
for (const file of files) {
|
|
2043
|
+
adj.set(file, []);
|
|
2044
|
+
}
|
|
2045
|
+
for (const edge of graph.edges) {
|
|
2046
|
+
const neighbors = adj.get(edge.source);
|
|
2047
|
+
if (neighbors) {
|
|
2048
|
+
neighbors.push(edge.target);
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
let index = 0;
|
|
2052
|
+
const nodeIndex = /* @__PURE__ */ new Map();
|
|
2053
|
+
const nodeLowlink = /* @__PURE__ */ new Map();
|
|
2054
|
+
const onStack = /* @__PURE__ */ new Set();
|
|
2055
|
+
const stack = [];
|
|
2056
|
+
const sccs = [];
|
|
2057
|
+
function strongConnect(v) {
|
|
2058
|
+
nodeIndex.set(v, index);
|
|
2059
|
+
nodeLowlink.set(v, index);
|
|
2060
|
+
index++;
|
|
2061
|
+
stack.push(v);
|
|
2062
|
+
onStack.add(v);
|
|
2063
|
+
for (const w of adj.get(v) ?? []) {
|
|
2064
|
+
if (!nodeIndex.has(w)) {
|
|
2065
|
+
strongConnect(w);
|
|
2066
|
+
nodeLowlink.set(v, Math.min(nodeLowlink.get(v), nodeLowlink.get(w)));
|
|
2067
|
+
} else if (onStack.has(w)) {
|
|
2068
|
+
nodeLowlink.set(v, Math.min(nodeLowlink.get(v), nodeIndex.get(w)));
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
if (nodeLowlink.get(v) === nodeIndex.get(v)) {
|
|
2072
|
+
const scc = [];
|
|
2073
|
+
let w;
|
|
2074
|
+
do {
|
|
2075
|
+
w = stack.pop();
|
|
2076
|
+
onStack.delete(w);
|
|
2077
|
+
scc.push(w);
|
|
2078
|
+
} while (w !== v);
|
|
2079
|
+
if (scc.length >= 2) {
|
|
2080
|
+
sccs.push(scc);
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
for (const file of files) {
|
|
2085
|
+
if (!nodeIndex.has(file)) {
|
|
2086
|
+
strongConnect(file);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
return sccs.map((scc) => {
|
|
2090
|
+
const sccSet = new Set(scc);
|
|
2091
|
+
let edgeCount = 0;
|
|
2092
|
+
for (const edge of graph.edges) {
|
|
2093
|
+
if (sccSet.has(edge.source) && sccSet.has(edge.target)) {
|
|
2094
|
+
edgeCount++;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
return {
|
|
2098
|
+
files: scc.sort(),
|
|
2099
|
+
edgeCount
|
|
2100
|
+
};
|
|
2101
|
+
});
|
|
2102
|
+
}
|
|
2103
|
+
function computeCoupling(graph) {
|
|
2104
|
+
const files = Object.keys(graph.nodes);
|
|
2105
|
+
const fanIn = /* @__PURE__ */ new Map();
|
|
2106
|
+
const fanOut = /* @__PURE__ */ new Map();
|
|
2107
|
+
for (const file of files) {
|
|
2108
|
+
fanIn.set(file, /* @__PURE__ */ new Set());
|
|
2109
|
+
fanOut.set(file, /* @__PURE__ */ new Set());
|
|
2110
|
+
}
|
|
2111
|
+
for (const edge of graph.edges) {
|
|
2112
|
+
fanIn.get(edge.target)?.add(edge.source);
|
|
2113
|
+
fanOut.get(edge.source)?.add(edge.target);
|
|
2114
|
+
}
|
|
2115
|
+
return files.map((file) => {
|
|
2116
|
+
const ca = fanIn.get(file)?.size ?? 0;
|
|
2117
|
+
const ce = fanOut.get(file)?.size ?? 0;
|
|
2118
|
+
const total = ca + ce;
|
|
2119
|
+
return {
|
|
2120
|
+
filePath: file,
|
|
2121
|
+
afferentCoupling: ca,
|
|
2122
|
+
efferentCoupling: ce,
|
|
2123
|
+
instability: total > 0 ? ce / total : 0
|
|
2124
|
+
};
|
|
2125
|
+
});
|
|
2126
|
+
}
|
|
2127
|
+
function detectHotspots(graph, pageRank) {
|
|
2128
|
+
const files = Object.keys(graph.nodes);
|
|
2129
|
+
const connectivity = /* @__PURE__ */ new Map();
|
|
2130
|
+
for (const file of files) {
|
|
2131
|
+
connectivity.set(file, 0);
|
|
2132
|
+
}
|
|
2133
|
+
for (const edge of graph.edges) {
|
|
2134
|
+
connectivity.set(edge.source, (connectivity.get(edge.source) ?? 0) + 1);
|
|
2135
|
+
connectivity.set(edge.target, (connectivity.get(edge.target) ?? 0) + 1);
|
|
2136
|
+
}
|
|
2137
|
+
return files.map((file) => ({
|
|
2138
|
+
filePath: file,
|
|
2139
|
+
connectivity: connectivity.get(file) ?? 0,
|
|
2140
|
+
pageRank: pageRank.ranks[file] ?? 0,
|
|
2141
|
+
definitionCount: graph.nodes[file]?.definitionCount ?? 0
|
|
2142
|
+
})).sort((a, b) => {
|
|
2143
|
+
if (b.pageRank !== a.pageRank) return b.pageRank - a.pageRank;
|
|
2144
|
+
if (b.connectivity !== a.connectivity) return b.connectivity - a.connectivity;
|
|
2145
|
+
return b.definitionCount - a.definitionCount;
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
function computeMetrics(graph, pageRank) {
|
|
2149
|
+
const files = Object.keys(graph.nodes);
|
|
2150
|
+
const cycles = detectCycles(graph);
|
|
2151
|
+
const coupling = computeCoupling(graph);
|
|
2152
|
+
const hotspots = detectHotspots(graph, pageRank);
|
|
2153
|
+
let totalDefinitions = 0;
|
|
2154
|
+
let totalReferences = 0;
|
|
2155
|
+
for (const node of Object.values(graph.nodes)) {
|
|
2156
|
+
totalDefinitions += node.definitionCount;
|
|
2157
|
+
totalReferences += node.referenceCount;
|
|
2158
|
+
}
|
|
2159
|
+
const fanIns = coupling.map((c) => c.afferentCoupling);
|
|
2160
|
+
const fanOuts = coupling.map((c) => c.efferentCoupling);
|
|
2161
|
+
const totalFiles = files.length;
|
|
2162
|
+
return {
|
|
2163
|
+
totalFiles,
|
|
2164
|
+
totalEdges: graph.edges.length,
|
|
2165
|
+
totalDefinitions,
|
|
2166
|
+
totalReferences,
|
|
2167
|
+
cycles,
|
|
2168
|
+
coupling,
|
|
2169
|
+
hotspots,
|
|
2170
|
+
avgFanIn: totalFiles > 0 ? sum(fanIns) / totalFiles : 0,
|
|
2171
|
+
avgFanOut: totalFiles > 0 ? sum(fanOuts) / totalFiles : 0,
|
|
2172
|
+
maxFanIn: fanIns.length > 0 ? Math.max(...fanIns) : 0,
|
|
2173
|
+
maxFanOut: fanOuts.length > 0 ? Math.max(...fanOuts) : 0
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
function saveMetrics(metrics, projectDir, branch) {
|
|
2177
|
+
const filePath = depgraphMetricsFile(projectDir, branch);
|
|
2178
|
+
mkdirSync3(dirname3(filePath), { recursive: true });
|
|
2179
|
+
writeFileSync3(filePath, JSON.stringify(metrics, null, 2), "utf-8");
|
|
2180
|
+
}
|
|
2181
|
+
function loadMetrics(projectDir, branch) {
|
|
2182
|
+
const filePath = depgraphMetricsFile(projectDir, branch);
|
|
2183
|
+
try {
|
|
2184
|
+
const raw = readFileSync3(filePath, "utf-8");
|
|
2185
|
+
return JSON.parse(raw);
|
|
2186
|
+
} catch {
|
|
2187
|
+
return null;
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
function sum(values) {
|
|
2191
|
+
let total = 0;
|
|
2192
|
+
for (const v of values) {
|
|
2193
|
+
total += v;
|
|
2194
|
+
}
|
|
2195
|
+
return total;
|
|
2196
|
+
}
|
|
2197
|
+
function loadTagsCache(projectDir, branch) {
|
|
2198
|
+
const filePath = depgraphCacheFile(projectDir, branch);
|
|
2199
|
+
try {
|
|
2200
|
+
const raw = readFileSync4(filePath, "utf-8");
|
|
2201
|
+
const parsed = JSON.parse(raw);
|
|
2202
|
+
if (parsed.version !== 1 || typeof parsed.files !== "object") {
|
|
2203
|
+
return null;
|
|
2204
|
+
}
|
|
2205
|
+
return parsed;
|
|
2206
|
+
} catch {
|
|
2207
|
+
return null;
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
function saveTagsCache(cache, projectDir, branch) {
|
|
2211
|
+
const filePath = depgraphCacheFile(projectDir, branch);
|
|
2212
|
+
mkdirSync4(dirname4(filePath), { recursive: true });
|
|
2213
|
+
writeFileSync4(filePath, JSON.stringify(cache, null, 2), "utf-8");
|
|
2214
|
+
}
|
|
2215
|
+
function isCacheValid(cache, filePath, contentHash) {
|
|
2216
|
+
const entry = cache.files[filePath];
|
|
2217
|
+
if (!entry) return false;
|
|
2218
|
+
return entry.contentHash === contentHash;
|
|
2219
|
+
}
|
|
2220
|
+
function getCachedTags(cache, filePath) {
|
|
2221
|
+
const entry = cache.files[filePath];
|
|
2222
|
+
if (!entry) return null;
|
|
2223
|
+
return entry.tags;
|
|
2224
|
+
}
|
|
2225
|
+
function updateCacheEntry(cache, filePath, contentHash, mtime, tags) {
|
|
2226
|
+
cache.files[filePath] = {
|
|
2227
|
+
contentHash,
|
|
2228
|
+
mtime,
|
|
2229
|
+
tags
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
export {
|
|
2234
|
+
TAG_QUERIES,
|
|
2235
|
+
getTagQuery,
|
|
2236
|
+
extractTagsFromTree,
|
|
2237
|
+
buildReferenceGraph,
|
|
2238
|
+
getIncomingEdges,
|
|
2239
|
+
getOutgoingEdges,
|
|
2240
|
+
getTransitiveDeps,
|
|
2241
|
+
getTransitiveRdeps,
|
|
2242
|
+
saveGraph,
|
|
2243
|
+
loadGraph,
|
|
2244
|
+
computePageRank,
|
|
2245
|
+
savePageRank,
|
|
2246
|
+
loadPageRank,
|
|
2247
|
+
loadPageRankMap,
|
|
2248
|
+
detectCycles,
|
|
2249
|
+
computeCoupling,
|
|
2250
|
+
detectHotspots,
|
|
2251
|
+
computeMetrics,
|
|
2252
|
+
saveMetrics,
|
|
2253
|
+
loadMetrics,
|
|
2254
|
+
loadTagsCache,
|
|
2255
|
+
saveTagsCache,
|
|
2256
|
+
isCacheValid,
|
|
2257
|
+
getCachedTags,
|
|
2258
|
+
updateCacheEntry
|
|
2259
|
+
};
|