gitnexus 1.4.0 → 1.4.1

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.
Files changed (131) hide show
  1. package/README.md +194 -214
  2. package/dist/cli/ai-context.d.ts +1 -2
  3. package/dist/cli/ai-context.js +90 -117
  4. package/dist/cli/analyze.d.ts +0 -2
  5. package/dist/cli/analyze.js +2 -20
  6. package/dist/cli/index.js +25 -17
  7. package/dist/cli/setup.js +19 -17
  8. package/dist/core/augmentation/engine.js +20 -20
  9. package/dist/core/embeddings/embedding-pipeline.js +26 -26
  10. package/dist/core/graph/types.d.ts +2 -5
  11. package/dist/core/ingestion/ast-cache.js +2 -3
  12. package/dist/core/ingestion/call-processor.d.ts +5 -5
  13. package/dist/core/ingestion/call-processor.js +258 -173
  14. package/dist/core/ingestion/cluster-enricher.js +16 -16
  15. package/dist/core/ingestion/entry-point-scoring.d.ts +1 -2
  16. package/dist/core/ingestion/entry-point-scoring.js +22 -81
  17. package/dist/core/ingestion/framework-detection.d.ts +1 -5
  18. package/dist/core/ingestion/framework-detection.js +8 -39
  19. package/dist/core/ingestion/heritage-processor.d.ts +4 -13
  20. package/dist/core/ingestion/heritage-processor.js +28 -92
  21. package/dist/core/ingestion/import-processor.d.ts +19 -17
  22. package/dist/core/ingestion/import-processor.js +695 -170
  23. package/dist/core/ingestion/parsing-processor.d.ts +10 -1
  24. package/dist/core/ingestion/parsing-processor.js +177 -41
  25. package/dist/core/ingestion/pipeline.js +26 -49
  26. package/dist/core/ingestion/process-processor.js +1 -2
  27. package/dist/core/ingestion/symbol-table.d.ts +1 -12
  28. package/dist/core/ingestion/symbol-table.js +12 -19
  29. package/dist/core/ingestion/tree-sitter-queries.d.ts +11 -11
  30. package/dist/core/ingestion/tree-sitter-queries.js +485 -590
  31. package/dist/core/ingestion/utils.d.ts +0 -67
  32. package/dist/core/ingestion/utils.js +9 -692
  33. package/dist/core/ingestion/workers/parse-worker.d.ts +3 -20
  34. package/dist/core/ingestion/workers/parse-worker.js +345 -84
  35. package/dist/core/ingestion/workers/worker-pool.js +0 -8
  36. package/dist/core/kuzu/csv-generator.js +3 -19
  37. package/dist/core/kuzu/kuzu-adapter.js +19 -14
  38. package/dist/core/kuzu/schema.d.ts +3 -3
  39. package/dist/core/kuzu/schema.js +288 -303
  40. package/dist/core/search/bm25-index.js +6 -7
  41. package/dist/core/search/hybrid-search.js +3 -3
  42. package/dist/core/wiki/diagrams.d.ts +27 -0
  43. package/dist/core/wiki/diagrams.js +163 -0
  44. package/dist/core/wiki/generator.d.ts +50 -2
  45. package/dist/core/wiki/generator.js +548 -49
  46. package/dist/core/wiki/graph-queries.d.ts +42 -0
  47. package/dist/core/wiki/graph-queries.js +276 -97
  48. package/dist/core/wiki/html-viewer.js +192 -192
  49. package/dist/core/wiki/llm-client.js +73 -11
  50. package/dist/core/wiki/prompts.d.ts +52 -8
  51. package/dist/core/wiki/prompts.js +200 -86
  52. package/dist/mcp/core/kuzu-adapter.d.ts +3 -1
  53. package/dist/mcp/core/kuzu-adapter.js +44 -13
  54. package/dist/mcp/local/local-backend.js +128 -128
  55. package/dist/mcp/resources.js +42 -42
  56. package/dist/mcp/server.js +19 -18
  57. package/dist/mcp/tools.js +104 -103
  58. package/hooks/claude/gitnexus-hook.cjs +155 -238
  59. package/hooks/claude/pre-tool-use.sh +79 -79
  60. package/hooks/claude/session-start.sh +42 -42
  61. package/package.json +96 -96
  62. package/scripts/patch-tree-sitter-swift.cjs +74 -74
  63. package/skills/gitnexus-cli.md +82 -82
  64. package/skills/gitnexus-debugging.md +89 -89
  65. package/skills/gitnexus-exploring.md +78 -78
  66. package/skills/gitnexus-guide.md +64 -64
  67. package/skills/gitnexus-impact-analysis.md +97 -97
  68. package/skills/gitnexus-pr-review.md +163 -163
  69. package/skills/gitnexus-refactoring.md +121 -121
  70. package/vendor/leiden/index.cjs +355 -355
  71. package/vendor/leiden/utils.cjs +392 -392
  72. package/dist/cli/lazy-action.d.ts +0 -6
  73. package/dist/cli/lazy-action.js +0 -18
  74. package/dist/cli/skill-gen.d.ts +0 -26
  75. package/dist/cli/skill-gen.js +0 -549
  76. package/dist/core/ingestion/constants.d.ts +0 -16
  77. package/dist/core/ingestion/constants.js +0 -16
  78. package/dist/core/ingestion/export-detection.d.ts +0 -18
  79. package/dist/core/ingestion/export-detection.js +0 -230
  80. package/dist/core/ingestion/language-config.d.ts +0 -46
  81. package/dist/core/ingestion/language-config.js +0 -167
  82. package/dist/core/ingestion/mro-processor.d.ts +0 -45
  83. package/dist/core/ingestion/mro-processor.js +0 -369
  84. package/dist/core/ingestion/named-binding-extraction.d.ts +0 -61
  85. package/dist/core/ingestion/named-binding-extraction.js +0 -363
  86. package/dist/core/ingestion/resolvers/csharp.d.ts +0 -22
  87. package/dist/core/ingestion/resolvers/csharp.js +0 -109
  88. package/dist/core/ingestion/resolvers/go.d.ts +0 -19
  89. package/dist/core/ingestion/resolvers/go.js +0 -42
  90. package/dist/core/ingestion/resolvers/index.d.ts +0 -16
  91. package/dist/core/ingestion/resolvers/index.js +0 -11
  92. package/dist/core/ingestion/resolvers/jvm.d.ts +0 -23
  93. package/dist/core/ingestion/resolvers/jvm.js +0 -87
  94. package/dist/core/ingestion/resolvers/php.d.ts +0 -15
  95. package/dist/core/ingestion/resolvers/php.js +0 -35
  96. package/dist/core/ingestion/resolvers/rust.d.ts +0 -15
  97. package/dist/core/ingestion/resolvers/rust.js +0 -73
  98. package/dist/core/ingestion/resolvers/standard.d.ts +0 -28
  99. package/dist/core/ingestion/resolvers/standard.js +0 -145
  100. package/dist/core/ingestion/resolvers/utils.d.ts +0 -33
  101. package/dist/core/ingestion/resolvers/utils.js +0 -120
  102. package/dist/core/ingestion/symbol-resolver.d.ts +0 -32
  103. package/dist/core/ingestion/symbol-resolver.js +0 -83
  104. package/dist/core/ingestion/type-env.d.ts +0 -27
  105. package/dist/core/ingestion/type-env.js +0 -86
  106. package/dist/core/ingestion/type-extractors/c-cpp.d.ts +0 -2
  107. package/dist/core/ingestion/type-extractors/c-cpp.js +0 -60
  108. package/dist/core/ingestion/type-extractors/csharp.d.ts +0 -2
  109. package/dist/core/ingestion/type-extractors/csharp.js +0 -89
  110. package/dist/core/ingestion/type-extractors/go.d.ts +0 -2
  111. package/dist/core/ingestion/type-extractors/go.js +0 -105
  112. package/dist/core/ingestion/type-extractors/index.d.ts +0 -21
  113. package/dist/core/ingestion/type-extractors/index.js +0 -29
  114. package/dist/core/ingestion/type-extractors/jvm.d.ts +0 -3
  115. package/dist/core/ingestion/type-extractors/jvm.js +0 -121
  116. package/dist/core/ingestion/type-extractors/php.d.ts +0 -2
  117. package/dist/core/ingestion/type-extractors/php.js +0 -31
  118. package/dist/core/ingestion/type-extractors/python.d.ts +0 -2
  119. package/dist/core/ingestion/type-extractors/python.js +0 -41
  120. package/dist/core/ingestion/type-extractors/rust.d.ts +0 -2
  121. package/dist/core/ingestion/type-extractors/rust.js +0 -39
  122. package/dist/core/ingestion/type-extractors/shared.d.ts +0 -17
  123. package/dist/core/ingestion/type-extractors/shared.js +0 -97
  124. package/dist/core/ingestion/type-extractors/swift.d.ts +0 -2
  125. package/dist/core/ingestion/type-extractors/swift.js +0 -43
  126. package/dist/core/ingestion/type-extractors/types.d.ts +0 -14
  127. package/dist/core/ingestion/type-extractors/types.js +0 -1
  128. package/dist/core/ingestion/type-extractors/typescript.d.ts +0 -2
  129. package/dist/core/ingestion/type-extractors/typescript.js +0 -46
  130. package/dist/mcp/compatible-stdio-transport.d.ts +0 -25
  131. package/dist/mcp/compatible-stdio-transport.js +0 -200
@@ -7,618 +7,513 @@ import { SupportedLanguages } from '../../config/supported-languages.js';
7
7
  * compatible with the standard tree-sitter grammars.
8
8
  */
9
9
  // TypeScript queries - works with tree-sitter-typescript
10
- export const TYPESCRIPT_QUERIES = `
11
- (class_declaration
12
- name: (type_identifier) @name) @definition.class
13
-
14
- (interface_declaration
15
- name: (type_identifier) @name) @definition.interface
16
-
17
- (function_declaration
18
- name: (identifier) @name) @definition.function
19
-
20
- (method_definition
21
- name: (property_identifier) @name) @definition.method
22
-
23
- (lexical_declaration
24
- (variable_declarator
25
- name: (identifier) @name
26
- value: (arrow_function))) @definition.function
27
-
28
- (lexical_declaration
29
- (variable_declarator
30
- name: (identifier) @name
31
- value: (function_expression))) @definition.function
32
-
33
- (export_statement
34
- declaration: (lexical_declaration
35
- (variable_declarator
36
- name: (identifier) @name
37
- value: (arrow_function)))) @definition.function
38
-
39
- (export_statement
40
- declaration: (lexical_declaration
41
- (variable_declarator
42
- name: (identifier) @name
43
- value: (function_expression)))) @definition.function
44
-
45
- (import_statement
46
- source: (string) @import.source) @import
47
-
48
- ; Re-export statements: export { X } from './y'
49
- (export_statement
50
- source: (string) @import.source) @import
51
-
52
- (call_expression
53
- function: (identifier) @call.name) @call
54
-
55
- (call_expression
56
- function: (member_expression
57
- property: (property_identifier) @call.name)) @call
58
-
59
- ; Constructor calls: new Foo()
60
- (new_expression
61
- constructor: (identifier) @call.name) @call
62
-
63
- ; Heritage queries - class extends
64
- (class_declaration
65
- name: (type_identifier) @heritage.class
66
- (class_heritage
67
- (extends_clause
68
- value: (identifier) @heritage.extends))) @heritage
69
-
70
- ; Heritage queries - class implements interface
71
- (class_declaration
72
- name: (type_identifier) @heritage.class
73
- (class_heritage
74
- (implements_clause
75
- (type_identifier) @heritage.implements))) @heritage.impl
10
+ export const TYPESCRIPT_QUERIES = `
11
+ (class_declaration
12
+ name: (type_identifier) @name) @definition.class
13
+
14
+ (interface_declaration
15
+ name: (type_identifier) @name) @definition.interface
16
+
17
+ (function_declaration
18
+ name: (identifier) @name) @definition.function
19
+
20
+ (method_definition
21
+ name: (property_identifier) @name) @definition.method
22
+
23
+ (lexical_declaration
24
+ (variable_declarator
25
+ name: (identifier) @name
26
+ value: (arrow_function))) @definition.function
27
+
28
+ (lexical_declaration
29
+ (variable_declarator
30
+ name: (identifier) @name
31
+ value: (function_expression))) @definition.function
32
+
33
+ (export_statement
34
+ declaration: (lexical_declaration
35
+ (variable_declarator
36
+ name: (identifier) @name
37
+ value: (arrow_function)))) @definition.function
38
+
39
+ (export_statement
40
+ declaration: (lexical_declaration
41
+ (variable_declarator
42
+ name: (identifier) @name
43
+ value: (function_expression)))) @definition.function
44
+
45
+ (import_statement
46
+ source: (string) @import.source) @import
47
+
48
+ (call_expression
49
+ function: (identifier) @call.name) @call
50
+
51
+ (call_expression
52
+ function: (member_expression
53
+ property: (property_identifier) @call.name)) @call
54
+
55
+ ; Heritage queries - class extends
56
+ (class_declaration
57
+ name: (type_identifier) @heritage.class
58
+ (class_heritage
59
+ (extends_clause
60
+ value: (identifier) @heritage.extends))) @heritage
61
+
62
+ ; Heritage queries - class implements interface
63
+ (class_declaration
64
+ name: (type_identifier) @heritage.class
65
+ (class_heritage
66
+ (implements_clause
67
+ (type_identifier) @heritage.implements))) @heritage.impl
76
68
  `;
77
- // JavaScript queries - works with tree-sitter-javascript
78
- export const JAVASCRIPT_QUERIES = `
79
- (class_declaration
80
- name: (identifier) @name) @definition.class
81
-
82
- (function_declaration
83
- name: (identifier) @name) @definition.function
84
-
85
- (method_definition
86
- name: (property_identifier) @name) @definition.method
87
-
88
- (lexical_declaration
89
- (variable_declarator
90
- name: (identifier) @name
91
- value: (arrow_function))) @definition.function
92
-
93
- (lexical_declaration
94
- (variable_declarator
95
- name: (identifier) @name
96
- value: (function_expression))) @definition.function
97
-
98
- (export_statement
99
- declaration: (lexical_declaration
100
- (variable_declarator
101
- name: (identifier) @name
102
- value: (arrow_function)))) @definition.function
103
-
104
- (export_statement
105
- declaration: (lexical_declaration
106
- (variable_declarator
107
- name: (identifier) @name
108
- value: (function_expression)))) @definition.function
109
-
110
- (import_statement
111
- source: (string) @import.source) @import
112
-
113
- ; Re-export statements: export { X } from './y'
114
- (export_statement
115
- source: (string) @import.source) @import
116
-
117
- (call_expression
118
- function: (identifier) @call.name) @call
119
-
120
- (call_expression
121
- function: (member_expression
122
- property: (property_identifier) @call.name)) @call
123
-
124
- ; Constructor calls: new Foo()
125
- (new_expression
126
- constructor: (identifier) @call.name) @call
127
-
128
- ; Heritage queries - class extends (JavaScript uses different AST than TypeScript)
129
- ; In tree-sitter-javascript, class_heritage directly contains the parent identifier
130
- (class_declaration
131
- name: (identifier) @heritage.class
132
- (class_heritage
133
- (identifier) @heritage.extends)) @heritage
69
+ // JavaScript queries - works with tree-sitter-javascript
70
+ export const JAVASCRIPT_QUERIES = `
71
+ (class_declaration
72
+ name: (identifier) @name) @definition.class
73
+
74
+ (function_declaration
75
+ name: (identifier) @name) @definition.function
76
+
77
+ (method_definition
78
+ name: (property_identifier) @name) @definition.method
79
+
80
+ (lexical_declaration
81
+ (variable_declarator
82
+ name: (identifier) @name
83
+ value: (arrow_function))) @definition.function
84
+
85
+ (lexical_declaration
86
+ (variable_declarator
87
+ name: (identifier) @name
88
+ value: (function_expression))) @definition.function
89
+
90
+ (export_statement
91
+ declaration: (lexical_declaration
92
+ (variable_declarator
93
+ name: (identifier) @name
94
+ value: (arrow_function)))) @definition.function
95
+
96
+ (export_statement
97
+ declaration: (lexical_declaration
98
+ (variable_declarator
99
+ name: (identifier) @name
100
+ value: (function_expression)))) @definition.function
101
+
102
+ (import_statement
103
+ source: (string) @import.source) @import
104
+
105
+ (call_expression
106
+ function: (identifier) @call.name) @call
107
+
108
+ (call_expression
109
+ function: (member_expression
110
+ property: (property_identifier) @call.name)) @call
111
+
112
+ ; Heritage queries - class extends (JavaScript uses different AST than TypeScript)
113
+ ; In tree-sitter-javascript, class_heritage directly contains the parent identifier
114
+ (class_declaration
115
+ name: (identifier) @heritage.class
116
+ (class_heritage
117
+ (identifier) @heritage.extends)) @heritage
134
118
  `;
135
119
  // Python queries - works with tree-sitter-python
136
- export const PYTHON_QUERIES = `
137
- (class_definition
138
- name: (identifier) @name) @definition.class
139
-
140
- (function_definition
141
- name: (identifier) @name) @definition.function
142
-
143
- (import_statement
144
- name: (dotted_name) @import.source) @import
145
-
146
- (import_from_statement
147
- module_name: (dotted_name) @import.source) @import
148
-
149
- (import_from_statement
150
- module_name: (relative_import) @import.source) @import
151
-
152
- (call
153
- function: (identifier) @call.name) @call
154
-
155
- (call
156
- function: (attribute
157
- attribute: (identifier) @call.name)) @call
158
-
159
- ; Heritage queries - Python class inheritance
160
- (class_definition
161
- name: (identifier) @heritage.class
162
- superclasses: (argument_list
163
- (identifier) @heritage.extends)) @heritage
120
+ export const PYTHON_QUERIES = `
121
+ (class_definition
122
+ name: (identifier) @name) @definition.class
123
+
124
+ (function_definition
125
+ name: (identifier) @name) @definition.function
126
+
127
+ (import_statement
128
+ name: (dotted_name) @import.source) @import
129
+
130
+ (import_from_statement
131
+ module_name: (dotted_name) @import.source) @import
132
+
133
+ (call
134
+ function: (identifier) @call.name) @call
135
+
136
+ (call
137
+ function: (attribute
138
+ attribute: (identifier) @call.name)) @call
139
+
140
+ ; Heritage queries - Python class inheritance
141
+ (class_definition
142
+ name: (identifier) @heritage.class
143
+ superclasses: (argument_list
144
+ (identifier) @heritage.extends)) @heritage
164
145
  `;
165
146
  // Java queries - works with tree-sitter-java
166
- export const JAVA_QUERIES = `
167
- ; Classes, Interfaces, Enums, Annotations
168
- (class_declaration name: (identifier) @name) @definition.class
169
- (interface_declaration name: (identifier) @name) @definition.interface
170
- (enum_declaration name: (identifier) @name) @definition.enum
171
- (annotation_type_declaration name: (identifier) @name) @definition.annotation
172
-
173
- ; Methods & Constructors
174
- (method_declaration name: (identifier) @name) @definition.method
175
- (constructor_declaration name: (identifier) @name) @definition.constructor
176
-
177
- ; Imports - capture any import declaration child as source
178
- (import_declaration (_) @import.source) @import
179
-
180
- ; Calls
181
- (method_invocation name: (identifier) @call.name) @call
182
- (method_invocation object: (_) name: (identifier) @call.name) @call
183
-
184
- ; Constructor calls: new Foo()
185
- (object_creation_expression type: (type_identifier) @call.name) @call
186
-
187
- ; Heritage - extends class
188
- (class_declaration name: (identifier) @heritage.class
189
- (superclass (type_identifier) @heritage.extends)) @heritage
190
-
191
- ; Heritage - implements interfaces
192
- (class_declaration name: (identifier) @heritage.class
193
- (super_interfaces (type_list (type_identifier) @heritage.implements))) @heritage.impl
147
+ export const JAVA_QUERIES = `
148
+ ; Classes, Interfaces, Enums, Annotations
149
+ (class_declaration name: (identifier) @name) @definition.class
150
+ (interface_declaration name: (identifier) @name) @definition.interface
151
+ (enum_declaration name: (identifier) @name) @definition.enum
152
+ (annotation_type_declaration name: (identifier) @name) @definition.annotation
153
+
154
+ ; Methods & Constructors
155
+ (method_declaration name: (identifier) @name) @definition.method
156
+ (constructor_declaration name: (identifier) @name) @definition.constructor
157
+
158
+ ; Imports - capture any import declaration child as source
159
+ (import_declaration (_) @import.source) @import
160
+
161
+ ; Calls
162
+ (method_invocation name: (identifier) @call.name) @call
163
+ (method_invocation object: (_) name: (identifier) @call.name) @call
164
+
165
+ ; Heritage - extends class
166
+ (class_declaration name: (identifier) @heritage.class
167
+ (superclass (type_identifier) @heritage.extends)) @heritage
168
+
169
+ ; Heritage - implements interfaces
170
+ (class_declaration name: (identifier) @heritage.class
171
+ (super_interfaces (type_list (type_identifier) @heritage.implements))) @heritage.impl
194
172
  `;
195
173
  // C queries - works with tree-sitter-c
196
- export const C_QUERIES = `
197
- ; Functions (direct declarator)
198
- (function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
199
- (declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function
200
-
201
- ; Functions returning pointers (pointer_declarator wraps function_declarator)
202
- (function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
203
- (declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
204
-
205
- ; Functions returning double pointers (nested pointer_declarator)
206
- (function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function
207
-
208
- ; Structs, Unions, Enums, Typedefs
209
- (struct_specifier name: (type_identifier) @name) @definition.struct
210
- (union_specifier name: (type_identifier) @name) @definition.union
211
- (enum_specifier name: (type_identifier) @name) @definition.enum
212
- (type_definition declarator: (type_identifier) @name) @definition.typedef
213
-
214
- ; Macros
215
- (preproc_function_def name: (identifier) @name) @definition.macro
216
- (preproc_def name: (identifier) @name) @definition.macro
217
-
218
- ; Includes
219
- (preproc_include path: (_) @import.source) @import
220
-
221
- ; Calls
222
- (call_expression function: (identifier) @call.name) @call
223
- (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
174
+ export const C_QUERIES = `
175
+ ; Functions
176
+ (function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
177
+ (declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function
178
+
179
+ ; Structs, Unions, Enums, Typedefs
180
+ (struct_specifier name: (type_identifier) @name) @definition.struct
181
+ (union_specifier name: (type_identifier) @name) @definition.union
182
+ (enum_specifier name: (type_identifier) @name) @definition.enum
183
+ (type_definition declarator: (type_identifier) @name) @definition.typedef
184
+
185
+ ; Macros
186
+ (preproc_function_def name: (identifier) @name) @definition.macro
187
+ (preproc_def name: (identifier) @name) @definition.macro
188
+
189
+ ; Includes
190
+ (preproc_include path: (_) @import.source) @import
191
+
192
+ ; Calls
193
+ (call_expression function: (identifier) @call.name) @call
194
+ (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
224
195
  `;
225
196
  // Go queries - works with tree-sitter-go
226
- export const GO_QUERIES = `
227
- ; Functions & Methods
228
- (function_declaration name: (identifier) @name) @definition.function
229
- (method_declaration name: (field_identifier) @name) @definition.method
230
-
231
- ; Types
232
- (type_declaration (type_spec name: (type_identifier) @name type: (struct_type))) @definition.struct
233
- (type_declaration (type_spec name: (type_identifier) @name type: (interface_type))) @definition.interface
234
-
235
- ; Imports
236
- (import_declaration (import_spec path: (interpreted_string_literal) @import.source)) @import
237
- (import_declaration (import_spec_list (import_spec path: (interpreted_string_literal) @import.source))) @import
238
-
239
- ; Struct embedding (anonymous fields = inheritance)
240
- (type_declaration
241
- (type_spec
242
- name: (type_identifier) @heritage.class
243
- type: (struct_type
244
- (field_declaration_list
245
- (field_declaration
246
- type: (type_identifier) @heritage.extends))))) @definition.struct
247
-
248
- ; Calls
249
- (call_expression function: (identifier) @call.name) @call
250
- (call_expression function: (selector_expression field: (field_identifier) @call.name)) @call
251
-
252
- ; Struct literal construction: User{Name: "Alice"}
253
- (composite_literal type: (type_identifier) @call.name) @call
197
+ export const GO_QUERIES = `
198
+ ; Functions & Methods
199
+ (function_declaration name: (identifier) @name) @definition.function
200
+ (method_declaration name: (field_identifier) @name) @definition.method
201
+
202
+ ; Types
203
+ (type_declaration (type_spec name: (type_identifier) @name type: (struct_type))) @definition.struct
204
+ (type_declaration (type_spec name: (type_identifier) @name type: (interface_type))) @definition.interface
205
+ (type_declaration (type_spec name: (type_identifier) @name)) @definition.type
206
+
207
+ ; Imports
208
+ (import_declaration (import_spec path: (interpreted_string_literal) @import.source)) @import
209
+ (import_declaration (import_spec_list (import_spec path: (interpreted_string_literal) @import.source))) @import
210
+
211
+ ; Calls
212
+ (call_expression function: (identifier) @call.name) @call
213
+ (call_expression function: (selector_expression field: (field_identifier) @call.name)) @call
254
214
  `;
255
215
  // C++ queries - works with tree-sitter-cpp
256
- export const CPP_QUERIES = `
257
- ; Classes, Structs, Namespaces
258
- (class_specifier name: (type_identifier) @name) @definition.class
259
- (struct_specifier name: (type_identifier) @name) @definition.struct
260
- (namespace_definition name: (namespace_identifier) @name) @definition.namespace
261
- (enum_specifier name: (type_identifier) @name) @definition.enum
262
-
263
- ; Typedefs and unions (common in C-style headers and mixed C/C++ code)
264
- (type_definition declarator: (type_identifier) @name) @definition.typedef
265
- (union_specifier name: (type_identifier) @name) @definition.union
266
-
267
- ; Macros
268
- (preproc_function_def name: (identifier) @name) @definition.macro
269
- (preproc_def name: (identifier) @name) @definition.macro
270
-
271
- ; Functions & Methods (direct declarator)
272
- (function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
273
- (function_definition declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))) @definition.method
274
-
275
- ; Functions/methods returning pointers (pointer_declarator wraps function_declarator)
276
- (function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
277
- (function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method
278
-
279
- ; Functions/methods returning double pointers (nested pointer_declarator)
280
- (function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function
281
- (function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))))) @definition.method
282
-
283
- ; Functions/methods returning references (reference_declarator wraps function_declarator)
284
- (function_definition declarator: (reference_declarator (function_declarator declarator: (identifier) @name))) @definition.function
285
- (function_definition declarator: (reference_declarator (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method
286
-
287
- ; Destructors (destructor_name is distinct from identifier in tree-sitter-cpp)
288
- (function_definition declarator: (function_declarator declarator: (qualified_identifier name: (destructor_name) @name))) @definition.method
289
-
290
- ; Function declarations / prototypes (common in headers)
291
- (declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function
292
- (declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
293
-
294
- ; Inline class method declarations (inside class body, no body: void Foo();)
295
- (field_declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.method
296
-
297
- ; Inline class method definitions (inside class body, with body: void Foo() { ... })
298
- (field_declaration_list
299
- (function_definition
300
- declarator: (function_declarator
301
- declarator: [(field_identifier) (identifier) (operator_name) (destructor_name)] @name))) @definition.method
302
-
303
- ; Templates
304
- (template_declaration (class_specifier name: (type_identifier) @name)) @definition.template
305
- (template_declaration (function_definition declarator: (function_declarator declarator: (identifier) @name))) @definition.template
306
-
307
- ; Includes
308
- (preproc_include path: (_) @import.source) @import
309
-
310
- ; Calls
311
- (call_expression function: (identifier) @call.name) @call
312
- (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
313
- (call_expression function: (qualified_identifier name: (identifier) @call.name)) @call
314
- (call_expression function: (template_function name: (identifier) @call.name)) @call
315
-
316
- ; Constructor calls: new User()
317
- (new_expression type: (type_identifier) @call.name) @call
318
-
319
- ; Heritage
320
- (class_specifier name: (type_identifier) @heritage.class
321
- (base_class_clause (type_identifier) @heritage.extends)) @heritage
322
- (class_specifier name: (type_identifier) @heritage.class
323
- (base_class_clause (access_specifier) (type_identifier) @heritage.extends)) @heritage
216
+ export const CPP_QUERIES = `
217
+ ; Classes, Structs, Namespaces
218
+ (class_specifier name: (type_identifier) @name) @definition.class
219
+ (struct_specifier name: (type_identifier) @name) @definition.struct
220
+ (namespace_definition name: (namespace_identifier) @name) @definition.namespace
221
+ (enum_specifier name: (type_identifier) @name) @definition.enum
222
+
223
+ ; Functions & Methods
224
+ (function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
225
+ (function_definition declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))) @definition.method
226
+
227
+ ; Templates
228
+ (template_declaration (class_specifier name: (type_identifier) @name)) @definition.template
229
+ (template_declaration (function_definition declarator: (function_declarator declarator: (identifier) @name))) @definition.template
230
+
231
+ ; Includes
232
+ (preproc_include path: (_) @import.source) @import
233
+
234
+ ; Calls
235
+ (call_expression function: (identifier) @call.name) @call
236
+ (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
237
+ (call_expression function: (qualified_identifier name: (identifier) @call.name)) @call
238
+ (call_expression function: (template_function name: (identifier) @call.name)) @call
239
+
240
+ ; Heritage
241
+ (class_specifier name: (type_identifier) @heritage.class
242
+ (base_class_clause (type_identifier) @heritage.extends)) @heritage
243
+ (class_specifier name: (type_identifier) @heritage.class
244
+ (base_class_clause (access_specifier) (type_identifier) @heritage.extends)) @heritage
324
245
  `;
325
246
  // C# queries - works with tree-sitter-c-sharp
326
- export const CSHARP_QUERIES = `
327
- ; Types
328
- (class_declaration name: (identifier) @name) @definition.class
329
- (interface_declaration name: (identifier) @name) @definition.interface
330
- (struct_declaration name: (identifier) @name) @definition.struct
331
- (enum_declaration name: (identifier) @name) @definition.enum
332
- (record_declaration name: (identifier) @name) @definition.record
333
- (delegate_declaration name: (identifier) @name) @definition.delegate
334
-
335
- ; Namespaces (block form and C# 10+ file-scoped form)
336
- (namespace_declaration name: (identifier) @name) @definition.namespace
337
- (namespace_declaration name: (qualified_name) @name) @definition.namespace
338
- (file_scoped_namespace_declaration name: (identifier) @name) @definition.namespace
339
- (file_scoped_namespace_declaration name: (qualified_name) @name) @definition.namespace
340
-
341
- ; Methods & Properties
342
- (method_declaration name: (identifier) @name) @definition.method
343
- (local_function_statement name: (identifier) @name) @definition.function
344
- (constructor_declaration name: (identifier) @name) @definition.constructor
345
- (property_declaration name: (identifier) @name) @definition.property
346
-
347
- ; Primary constructors (C# 12): class User(string name, int age) { }
348
- (class_declaration name: (identifier) @name (parameter_list) @definition.constructor)
349
- (record_declaration name: (identifier) @name (parameter_list) @definition.constructor)
350
-
351
- ; Using
352
- (using_directive (qualified_name) @import.source) @import
353
- (using_directive (identifier) @import.source) @import
354
-
355
- ; Calls
356
- (invocation_expression function: (identifier) @call.name) @call
357
- (invocation_expression function: (member_access_expression name: (identifier) @call.name)) @call
358
-
359
- ; Constructor calls: new Foo() and new Foo { Props }
360
- (object_creation_expression type: (identifier) @call.name) @call
361
-
362
- ; Target-typed new (C# 9): User u = new("x", 5)
363
- (variable_declaration type: (identifier) @call.name (variable_declarator (implicit_object_creation_expression) @call))
364
-
365
- ; Heritage
366
- (class_declaration name: (identifier) @heritage.class
367
- (base_list (identifier) @heritage.extends)) @heritage
368
- (class_declaration name: (identifier) @heritage.class
369
- (base_list (generic_name (identifier) @heritage.extends))) @heritage
247
+ export const CSHARP_QUERIES = `
248
+ ; Types
249
+ (class_declaration name: (identifier) @name) @definition.class
250
+ (interface_declaration name: (identifier) @name) @definition.interface
251
+ (struct_declaration name: (identifier) @name) @definition.struct
252
+ (enum_declaration name: (identifier) @name) @definition.enum
253
+ (record_declaration name: (identifier) @name) @definition.record
254
+ (delegate_declaration name: (identifier) @name) @definition.delegate
255
+
256
+ ; Namespaces
257
+ (namespace_declaration name: (identifier) @name) @definition.namespace
258
+ (namespace_declaration name: (qualified_name) @name) @definition.namespace
259
+
260
+ ; Methods & Properties
261
+ (method_declaration name: (identifier) @name) @definition.method
262
+ (local_function_statement name: (identifier) @name) @definition.function
263
+ (constructor_declaration name: (identifier) @name) @definition.constructor
264
+ (property_declaration name: (identifier) @name) @definition.property
265
+
266
+ ; Using
267
+ (using_directive (qualified_name) @import.source) @import
268
+ (using_directive (identifier) @import.source) @import
269
+
270
+ ; Calls
271
+ (invocation_expression function: (identifier) @call.name) @call
272
+ (invocation_expression function: (member_access_expression name: (identifier) @call.name)) @call
273
+
274
+ ; Heritage
275
+ (class_declaration name: (identifier) @heritage.class
276
+ (base_list (simple_base_type (identifier) @heritage.extends))) @heritage
277
+ (class_declaration name: (identifier) @heritage.class
278
+ (base_list (simple_base_type (generic_name (identifier) @heritage.extends)))) @heritage
370
279
  `;
371
280
  // Rust queries - works with tree-sitter-rust
372
- export const RUST_QUERIES = `
373
- ; Functions & Items
374
- (function_item name: (identifier) @name) @definition.function
375
- (struct_item name: (type_identifier) @name) @definition.struct
376
- (enum_item name: (type_identifier) @name) @definition.enum
377
- (trait_item name: (type_identifier) @name) @definition.trait
378
- (impl_item type: (type_identifier) @name !trait) @definition.impl
379
- (impl_item type: (generic_type type: (type_identifier) @name) !trait) @definition.impl
380
- (mod_item name: (identifier) @name) @definition.module
381
-
382
- ; Type aliases, const, static, macros
383
- (type_item name: (type_identifier) @name) @definition.type
384
- (const_item name: (identifier) @name) @definition.const
385
- (static_item name: (identifier) @name) @definition.static
386
- (macro_definition name: (identifier) @name) @definition.macro
387
-
388
- ; Use statements
389
- (use_declaration argument: (_) @import.source) @import
390
-
391
- ; Calls
392
- (call_expression function: (identifier) @call.name) @call
393
- (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
394
- (call_expression function: (scoped_identifier name: (identifier) @call.name)) @call
395
- (call_expression function: (generic_function function: (identifier) @call.name)) @call
396
-
397
- ; Struct literal construction: User { name: value }
398
- (struct_expression name: (type_identifier) @call.name) @call
399
-
400
- ; Heritage (trait implementation) — all combinations of concrete/generic trait × concrete/generic type
401
- (impl_item trait: (type_identifier) @heritage.trait type: (type_identifier) @heritage.class) @heritage
402
- (impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (type_identifier) @heritage.class) @heritage
403
- (impl_item trait: (type_identifier) @heritage.trait type: (generic_type type: (type_identifier) @heritage.class)) @heritage
404
- (impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (generic_type type: (type_identifier) @heritage.class)) @heritage
281
+ export const RUST_QUERIES = `
282
+ ; Functions & Items
283
+ (function_item name: (identifier) @name) @definition.function
284
+ (struct_item name: (type_identifier) @name) @definition.struct
285
+ (enum_item name: (type_identifier) @name) @definition.enum
286
+ (trait_item name: (type_identifier) @name) @definition.trait
287
+ (impl_item type: (type_identifier) @name) @definition.impl
288
+ (mod_item name: (identifier) @name) @definition.module
289
+
290
+ ; Type aliases, const, static, macros
291
+ (type_item name: (type_identifier) @name) @definition.type
292
+ (const_item name: (identifier) @name) @definition.const
293
+ (static_item name: (identifier) @name) @definition.static
294
+ (macro_definition name: (identifier) @name) @definition.macro
295
+
296
+ ; Use statements
297
+ (use_declaration argument: (_) @import.source) @import
298
+
299
+ ; Calls
300
+ (call_expression function: (identifier) @call.name) @call
301
+ (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
302
+ (call_expression function: (scoped_identifier name: (identifier) @call.name)) @call
303
+ (call_expression function: (generic_function function: (identifier) @call.name)) @call
304
+
305
+ ; Heritage (trait implementation)
306
+ (impl_item trait: (type_identifier) @heritage.trait type: (type_identifier) @heritage.class) @heritage
307
+ (impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (type_identifier) @heritage.class) @heritage
405
308
  `;
406
309
  // PHP queries - works with tree-sitter-php (php_only grammar)
407
- export const PHP_QUERIES = `
408
- ; ── Namespace ────────────────────────────────────────────────────────────────
409
- (namespace_definition
410
- name: (namespace_name) @name) @definition.namespace
411
-
412
- ; ── Classes ──────────────────────────────────────────────────────────────────
413
- (class_declaration
414
- name: (name) @name) @definition.class
415
-
416
- ; ── Interfaces ───────────────────────────────────────────────────────────────
417
- (interface_declaration
418
- name: (name) @name) @definition.interface
419
-
420
- ; ── Traits ───────────────────────────────────────────────────────────────────
421
- (trait_declaration
422
- name: (name) @name) @definition.trait
423
-
424
- ; ── Enums (PHP 8.1) ──────────────────────────────────────────────────────────
425
- (enum_declaration
426
- name: (name) @name) @definition.enum
427
-
428
- ; ── Top-level functions ───────────────────────────────────────────────────────
429
- (function_definition
430
- name: (name) @name) @definition.function
431
-
432
- ; ── Methods (including constructors) ─────────────────────────────────────────
433
- (method_declaration
434
- name: (name) @name) @definition.method
435
-
436
- ; ── Class properties (including Eloquent $fillable, $casts, etc.) ────────────
437
- (property_declaration
438
- (property_element
439
- (variable_name
440
- (name) @name))) @definition.property
441
-
442
- ; ── Imports: use statements ──────────────────────────────────────────────────
443
- ; Simple: use App\\Models\\User;
444
- (namespace_use_declaration
445
- (namespace_use_clause
446
- (qualified_name) @import.source)) @import
447
-
448
- ; ── Function/method calls ────────────────────────────────────────────────────
449
- ; Regular function call: foo()
450
- (function_call_expression
451
- function: (name) @call.name) @call
452
-
453
- ; Method call: $obj->method()
454
- (member_call_expression
455
- name: (name) @call.name) @call
456
-
457
- ; Nullsafe method call: $obj?->method()
458
- (nullsafe_member_call_expression
459
- name: (name) @call.name) @call
460
-
461
- ; Static call: Foo::bar() (php_only uses scoped_call_expression)
462
- (scoped_call_expression
463
- name: (name) @call.name) @call
464
-
465
- ; Constructor call: new User()
466
- (object_creation_expression (name) @call.name) @call
467
-
468
- ; ── Heritage: extends ────────────────────────────────────────────────────────
469
- (class_declaration
470
- name: (name) @heritage.class
471
- (base_clause
472
- [(name) (qualified_name)] @heritage.extends)) @heritage
473
-
474
- ; ── Heritage: implements ─────────────────────────────────────────────────────
475
- (class_declaration
476
- name: (name) @heritage.class
477
- (class_interface_clause
478
- [(name) (qualified_name)] @heritage.implements)) @heritage.impl
479
-
480
- ; ── Heritage: use trait (must capture enclosing class name) ──────────────────
481
- (class_declaration
482
- name: (name) @heritage.class
483
- body: (declaration_list
484
- (use_declaration
485
- [(name) (qualified_name)] @heritage.trait))) @heritage
310
+ export const PHP_QUERIES = `
311
+ ; ── Namespace ────────────────────────────────────────────────────────────────
312
+ (namespace_definition
313
+ name: (namespace_name) @name) @definition.namespace
314
+
315
+ ; ── Classes ──────────────────────────────────────────────────────────────────
316
+ (class_declaration
317
+ name: (name) @name) @definition.class
318
+
319
+ ; ── Interfaces ───────────────────────────────────────────────────────────────
320
+ (interface_declaration
321
+ name: (name) @name) @definition.interface
322
+
323
+ ; ── Traits ───────────────────────────────────────────────────────────────────
324
+ (trait_declaration
325
+ name: (name) @name) @definition.trait
326
+
327
+ ; ── Enums (PHP 8.1) ──────────────────────────────────────────────────────────
328
+ (enum_declaration
329
+ name: (name) @name) @definition.enum
330
+
331
+ ; ── Top-level functions ───────────────────────────────────────────────────────
332
+ (function_definition
333
+ name: (name) @name) @definition.function
334
+
335
+ ; ── Methods (including constructors) ─────────────────────────────────────────
336
+ (method_declaration
337
+ name: (name) @name) @definition.method
338
+
339
+ ; ── Class properties (including Eloquent $fillable, $casts, etc.) ────────────
340
+ (property_declaration
341
+ (property_element
342
+ (variable_name
343
+ (name) @name))) @definition.property
344
+
345
+ ; ── Imports: use statements ──────────────────────────────────────────────────
346
+ ; Simple: use App\\Models\\User;
347
+ (namespace_use_declaration
348
+ (namespace_use_clause
349
+ (qualified_name) @import.source)) @import
350
+
351
+ ; ── Function/method calls ────────────────────────────────────────────────────
352
+ ; Regular function call: foo()
353
+ (function_call_expression
354
+ function: (name) @call.name) @call
355
+
356
+ ; Method call: $obj->method()
357
+ (member_call_expression
358
+ name: (name) @call.name) @call
359
+
360
+ ; Nullsafe method call: $obj?->method()
361
+ (nullsafe_member_call_expression
362
+ name: (name) @call.name) @call
363
+
364
+ ; Static call: Foo::bar() (php_only uses scoped_call_expression)
365
+ (scoped_call_expression
366
+ name: (name) @call.name) @call
367
+
368
+ ; ── Heritage: extends ────────────────────────────────────────────────────────
369
+ (class_declaration
370
+ name: (name) @heritage.class
371
+ (base_clause
372
+ [(name) (qualified_name)] @heritage.extends)) @heritage
373
+
374
+ ; ── Heritage: implements ─────────────────────────────────────────────────────
375
+ (class_declaration
376
+ name: (name) @heritage.class
377
+ (class_interface_clause
378
+ [(name) (qualified_name)] @heritage.implements)) @heritage.impl
379
+
380
+ ; ── Heritage: use trait (must capture enclosing class name) ──────────────────
381
+ (class_declaration
382
+ name: (name) @heritage.class
383
+ body: (declaration_list
384
+ (use_declaration
385
+ [(name) (qualified_name)] @heritage.trait))) @heritage
486
386
  `;
487
387
  // Kotlin queries - works with tree-sitter-kotlin (fwcd/tree-sitter-kotlin)
488
388
  // Based on official tags.scm; functions use simple_identifier, classes use type_identifier
489
- export const KOTLIN_QUERIES = `
490
- ; ── Interfaces ─────────────────────────────────────────────────────────────
491
- ; tree-sitter-kotlin (fwcd) has no interface_declaration node type.
492
- ; Interfaces are class_declaration nodes with an anonymous "interface" keyword child.
493
- (class_declaration
494
- "interface"
495
- (type_identifier) @name) @definition.interface
496
-
497
- ; ── Classes (regular, data, sealed, enum) ────────────────────────────────
498
- ; All have the anonymous "class" keyword child. enum class has both
499
- ; "enum" and "class" children — the "class" child still matches.
500
- (class_declaration
501
- "class"
502
- (type_identifier) @name) @definition.class
503
-
504
- ; ── Object declarations (Kotlin singletons) ──────────────────────────────
505
- (object_declaration
506
- (type_identifier) @name) @definition.class
507
-
508
- ; ── Companion objects (named only) ───────────────────────────────────────
509
- (companion_object
510
- (type_identifier) @name) @definition.class
511
-
512
- ; ── Functions (top-level, member, extension) ──────────────────────────────
513
- (function_declaration
514
- (simple_identifier) @name) @definition.function
515
-
516
- ; ── Properties ───────────────────────────────────────────────────────────
517
- (property_declaration
518
- (variable_declaration
519
- (simple_identifier) @name)) @definition.property
520
-
521
- ; ── Enum entries ─────────────────────────────────────────────────────────
522
- (enum_entry
523
- (simple_identifier) @name) @definition.enum
524
-
525
- ; ── Type aliases ─────────────────────────────────────────────────────────
526
- (type_alias
527
- (type_identifier) @name) @definition.type
528
-
529
- ; ── Imports ──────────────────────────────────────────────────────────────
530
- (import_header
531
- (identifier) @import.source) @import
532
-
533
- ; ── Function calls (direct) ──────────────────────────────────────────────
534
- (call_expression
535
- (simple_identifier) @call.name) @call
536
-
537
- ; ── Method calls (via navigation: obj.method()) ──────────────────────────
538
- (call_expression
539
- (navigation_expression
540
- (navigation_suffix
541
- (simple_identifier) @call.name))) @call
542
-
543
- ; ── Constructor invocations ──────────────────────────────────────────────
544
- (constructor_invocation
545
- (user_type
546
- (type_identifier) @call.name)) @call
547
-
548
- ; ── Infix function calls (e.g., a to b, x until y) ──────────────────────
549
- (infix_expression
550
- (simple_identifier) @call.name) @call
551
-
552
- ; ── Heritage: extends / implements via delegation_specifier ──────────────
553
- ; Interface implementation (bare user_type): class Foo : Bar
554
- (class_declaration
555
- (type_identifier) @heritage.class
556
- (delegation_specifier
557
- (user_type (type_identifier) @heritage.extends))) @heritage
558
-
559
- ; Class extension (constructor_invocation): class Foo : Bar()
560
- (class_declaration
561
- (type_identifier) @heritage.class
562
- (delegation_specifier
563
- (constructor_invocation
564
- (user_type (type_identifier) @heritage.extends)))) @heritage
389
+ export const KOTLIN_QUERIES = `
390
+ ; ── Interfaces ─────────────────────────────────────────────────────────────
391
+ ; tree-sitter-kotlin (fwcd) has no interface_declaration node type.
392
+ ; Interfaces are class_declaration nodes with an anonymous "interface" keyword child.
393
+ (class_declaration
394
+ "interface"
395
+ (type_identifier) @name) @definition.interface
396
+
397
+ ; ── Classes (regular, data, sealed, enum) ────────────────────────────────
398
+ ; All have the anonymous "class" keyword child. enum class has both
399
+ ; "enum" and "class" children — the "class" child still matches.
400
+ (class_declaration
401
+ "class"
402
+ (type_identifier) @name) @definition.class
403
+
404
+ ; ── Object declarations (Kotlin singletons) ──────────────────────────────
405
+ (object_declaration
406
+ (type_identifier) @name) @definition.class
407
+
408
+ ; ── Companion objects (named only) ───────────────────────────────────────
409
+ (companion_object
410
+ (type_identifier) @name) @definition.class
411
+
412
+ ; ── Functions (top-level, member, extension) ──────────────────────────────
413
+ (function_declaration
414
+ (simple_identifier) @name) @definition.function
415
+
416
+ ; ── Properties ───────────────────────────────────────────────────────────
417
+ (property_declaration
418
+ (variable_declaration
419
+ (simple_identifier) @name)) @definition.property
420
+
421
+ ; ── Enum entries ─────────────────────────────────────────────────────────
422
+ (enum_entry
423
+ (simple_identifier) @name) @definition.enum
424
+
425
+ ; ── Type aliases ─────────────────────────────────────────────────────────
426
+ (type_alias
427
+ (type_identifier) @name) @definition.type
428
+
429
+ ; ── Imports ──────────────────────────────────────────────────────────────
430
+ (import_header
431
+ (identifier) @import.source) @import
432
+
433
+ ; ── Function calls (direct) ──────────────────────────────────────────────
434
+ (call_expression
435
+ (simple_identifier) @call.name) @call
436
+
437
+ ; ── Method calls (via navigation: obj.method()) ──────────────────────────
438
+ (call_expression
439
+ (navigation_expression
440
+ (navigation_suffix
441
+ (simple_identifier) @call.name))) @call
442
+
443
+ ; ── Constructor invocations ──────────────────────────────────────────────
444
+ (constructor_invocation
445
+ (user_type
446
+ (type_identifier) @call.name)) @call
447
+
448
+ ; ── Infix function calls (e.g., a to b, x until y) ──────────────────────
449
+ (infix_expression
450
+ (simple_identifier) @call.name) @call
451
+
452
+ ; ── Heritage: extends / implements via delegation_specifier ──────────────
453
+ ; Interface implementation (bare user_type): class Foo : Bar
454
+ (class_declaration
455
+ (type_identifier) @heritage.class
456
+ (delegation_specifier
457
+ (user_type (type_identifier) @heritage.extends))) @heritage
458
+
459
+ ; Class extension (constructor_invocation): class Foo : Bar()
460
+ (class_declaration
461
+ (type_identifier) @heritage.class
462
+ (delegation_specifier
463
+ (constructor_invocation
464
+ (user_type (type_identifier) @heritage.extends)))) @heritage
565
465
  `;
566
466
  // Swift queries - works with tree-sitter-swift
567
- export const SWIFT_QUERIES = `
568
- ; Classes
569
- (class_declaration "class" name: (type_identifier) @name) @definition.class
570
-
571
- ; Structs
572
- (class_declaration "struct" name: (type_identifier) @name) @definition.struct
573
-
574
- ; Enums
575
- (class_declaration "enum" name: (type_identifier) @name) @definition.enum
576
-
577
- ; Extensions (mapped to class — no dedicated label in schema)
578
- (class_declaration "extension" name: (user_type (type_identifier) @name)) @definition.class
579
-
580
- ; Actors
581
- (class_declaration "actor" name: (type_identifier) @name) @definition.class
582
-
583
- ; Protocols (mapped to interface)
584
- (protocol_declaration name: (type_identifier) @name) @definition.interface
585
-
586
- ; Type aliases
587
- (typealias_declaration name: (type_identifier) @name) @definition.type
588
-
589
- ; Functions (top-level and methods)
590
- (function_declaration name: (simple_identifier) @name) @definition.function
591
-
592
- ; Protocol method declarations
593
- (protocol_function_declaration name: (simple_identifier) @name) @definition.method
594
-
595
- ; Initializers
596
- (init_declaration) @definition.constructor
597
-
598
- ; Properties (stored and computed)
599
- (property_declaration (pattern (simple_identifier) @name)) @definition.property
600
-
601
- ; Imports
602
- (import_declaration (identifier (simple_identifier) @import.source)) @import
603
-
604
- ; Calls - direct function calls
605
- (call_expression (simple_identifier) @call.name) @call
606
-
607
- ; Calls - member/navigation calls (obj.method())
608
- (call_expression (navigation_expression (navigation_suffix (simple_identifier) @call.name))) @call
609
-
610
- ; Heritage - class/struct/enum inheritance and protocol conformance
611
- (class_declaration name: (type_identifier) @heritage.class
612
- (inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
613
-
614
- ; Heritage - protocol inheritance
615
- (protocol_declaration name: (type_identifier) @heritage.class
616
- (inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
617
-
618
- ; Heritage - extension protocol conformance (e.g. extension Foo: SomeProtocol)
619
- ; Extensions wrap the name in user_type unlike class/struct/enum declarations
620
- (class_declaration "extension" name: (user_type (type_identifier) @heritage.class)
621
- (inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
467
+ export const SWIFT_QUERIES = `
468
+ ; Classes
469
+ (class_declaration "class" name: (type_identifier) @name) @definition.class
470
+
471
+ ; Structs
472
+ (class_declaration "struct" name: (type_identifier) @name) @definition.struct
473
+
474
+ ; Enums
475
+ (class_declaration "enum" name: (type_identifier) @name) @definition.enum
476
+
477
+ ; Extensions (mapped to class — no dedicated label in schema)
478
+ (class_declaration "extension" name: (user_type (type_identifier) @name)) @definition.class
479
+
480
+ ; Actors
481
+ (class_declaration "actor" name: (type_identifier) @name) @definition.class
482
+
483
+ ; Protocols (mapped to interface)
484
+ (protocol_declaration name: (type_identifier) @name) @definition.interface
485
+
486
+ ; Type aliases
487
+ (typealias_declaration name: (type_identifier) @name) @definition.type
488
+
489
+ ; Functions (top-level and methods)
490
+ (function_declaration name: (simple_identifier) @name) @definition.function
491
+
492
+ ; Protocol method declarations
493
+ (protocol_function_declaration name: (simple_identifier) @name) @definition.method
494
+
495
+ ; Initializers
496
+ (init_declaration) @definition.constructor
497
+
498
+ ; Properties (stored and computed)
499
+ (property_declaration (pattern (simple_identifier) @name)) @definition.property
500
+
501
+ ; Imports
502
+ (import_declaration (identifier (simple_identifier) @import.source)) @import
503
+
504
+ ; Calls - direct function calls
505
+ (call_expression (simple_identifier) @call.name) @call
506
+
507
+ ; Calls - member/navigation calls (obj.method())
508
+ (call_expression (navigation_expression (navigation_suffix (simple_identifier) @call.name))) @call
509
+
510
+ ; Heritage - class/struct/enum inheritance and protocol conformance
511
+ (class_declaration name: (type_identifier) @heritage.class
512
+ (inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
513
+
514
+ ; Heritage - protocol inheritance
515
+ (protocol_declaration name: (type_identifier) @heritage.class
516
+ (inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
622
517
  `;
623
518
  export const LANGUAGE_QUERIES = {
624
519
  [SupportedLanguages.TypeScript]: TYPESCRIPT_QUERIES,