@duytransipher/gitnexus 1.0.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 +73 -0
- package/README.md +261 -0
- package/dist/cli/ai-context.d.ts +23 -0
- package/dist/cli/ai-context.js +265 -0
- package/dist/cli/analyze.d.ts +12 -0
- package/dist/cli/analyze.js +345 -0
- package/dist/cli/augment.d.ts +13 -0
- package/dist/cli/augment.js +33 -0
- package/dist/cli/clean.d.ts +10 -0
- package/dist/cli/clean.js +60 -0
- package/dist/cli/eval-server.d.ts +37 -0
- package/dist/cli/eval-server.js +389 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +137 -0
- package/dist/cli/lazy-action.d.ts +6 -0
- package/dist/cli/lazy-action.js +18 -0
- package/dist/cli/list.d.ts +6 -0
- package/dist/cli/list.js +30 -0
- package/dist/cli/mcp.d.ts +8 -0
- package/dist/cli/mcp.js +36 -0
- package/dist/cli/serve.d.ts +4 -0
- package/dist/cli/serve.js +6 -0
- package/dist/cli/setup.d.ts +8 -0
- package/dist/cli/setup.js +367 -0
- package/dist/cli/sipher-patched.d.ts +2 -0
- package/dist/cli/sipher-patched.js +77 -0
- package/dist/cli/skill-gen.d.ts +26 -0
- package/dist/cli/skill-gen.js +549 -0
- package/dist/cli/status.d.ts +6 -0
- package/dist/cli/status.js +36 -0
- package/dist/cli/tool.d.ts +60 -0
- package/dist/cli/tool.js +180 -0
- package/dist/cli/wiki.d.ts +15 -0
- package/dist/cli/wiki.js +365 -0
- package/dist/config/ignore-service.d.ts +26 -0
- package/dist/config/ignore-service.js +284 -0
- package/dist/config/supported-languages.d.ts +15 -0
- package/dist/config/supported-languages.js +16 -0
- package/dist/core/augmentation/engine.d.ts +26 -0
- package/dist/core/augmentation/engine.js +240 -0
- package/dist/core/embeddings/embedder.d.ts +60 -0
- package/dist/core/embeddings/embedder.js +251 -0
- package/dist/core/embeddings/embedding-pipeline.d.ts +51 -0
- package/dist/core/embeddings/embedding-pipeline.js +356 -0
- package/dist/core/embeddings/index.d.ts +9 -0
- package/dist/core/embeddings/index.js +9 -0
- package/dist/core/embeddings/text-generator.d.ts +24 -0
- package/dist/core/embeddings/text-generator.js +182 -0
- package/dist/core/embeddings/types.d.ts +87 -0
- package/dist/core/embeddings/types.js +32 -0
- package/dist/core/graph/graph.d.ts +2 -0
- package/dist/core/graph/graph.js +66 -0
- package/dist/core/graph/types.d.ts +66 -0
- package/dist/core/graph/types.js +1 -0
- package/dist/core/ingestion/ast-cache.d.ts +11 -0
- package/dist/core/ingestion/ast-cache.js +35 -0
- package/dist/core/ingestion/call-processor.d.ts +23 -0
- package/dist/core/ingestion/call-processor.js +793 -0
- package/dist/core/ingestion/call-routing.d.ts +68 -0
- package/dist/core/ingestion/call-routing.js +129 -0
- package/dist/core/ingestion/cluster-enricher.d.ts +38 -0
- package/dist/core/ingestion/cluster-enricher.js +170 -0
- package/dist/core/ingestion/community-processor.d.ts +39 -0
- package/dist/core/ingestion/community-processor.js +312 -0
- package/dist/core/ingestion/constants.d.ts +16 -0
- package/dist/core/ingestion/constants.js +16 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +40 -0
- package/dist/core/ingestion/entry-point-scoring.js +353 -0
- package/dist/core/ingestion/export-detection.d.ts +18 -0
- package/dist/core/ingestion/export-detection.js +231 -0
- package/dist/core/ingestion/filesystem-walker.d.ts +28 -0
- package/dist/core/ingestion/filesystem-walker.js +81 -0
- package/dist/core/ingestion/framework-detection.d.ts +54 -0
- package/dist/core/ingestion/framework-detection.js +411 -0
- package/dist/core/ingestion/heritage-processor.d.ts +28 -0
- package/dist/core/ingestion/heritage-processor.js +251 -0
- package/dist/core/ingestion/import-processor.d.ts +34 -0
- package/dist/core/ingestion/import-processor.js +398 -0
- package/dist/core/ingestion/language-config.d.ts +46 -0
- package/dist/core/ingestion/language-config.js +167 -0
- package/dist/core/ingestion/mro-processor.d.ts +45 -0
- package/dist/core/ingestion/mro-processor.js +369 -0
- package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
- package/dist/core/ingestion/named-binding-extraction.js +363 -0
- package/dist/core/ingestion/parsing-processor.d.ts +19 -0
- package/dist/core/ingestion/parsing-processor.js +315 -0
- package/dist/core/ingestion/pipeline.d.ts +6 -0
- package/dist/core/ingestion/pipeline.js +401 -0
- package/dist/core/ingestion/process-processor.d.ts +51 -0
- package/dist/core/ingestion/process-processor.js +315 -0
- package/dist/core/ingestion/resolution-context.d.ts +53 -0
- package/dist/core/ingestion/resolution-context.js +132 -0
- package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
- package/dist/core/ingestion/resolvers/csharp.js +109 -0
- package/dist/core/ingestion/resolvers/go.d.ts +19 -0
- package/dist/core/ingestion/resolvers/go.js +42 -0
- package/dist/core/ingestion/resolvers/index.d.ts +18 -0
- package/dist/core/ingestion/resolvers/index.js +13 -0
- package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
- package/dist/core/ingestion/resolvers/jvm.js +87 -0
- package/dist/core/ingestion/resolvers/php.d.ts +15 -0
- package/dist/core/ingestion/resolvers/php.js +35 -0
- package/dist/core/ingestion/resolvers/python.d.ts +19 -0
- package/dist/core/ingestion/resolvers/python.js +52 -0
- package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
- package/dist/core/ingestion/resolvers/ruby.js +15 -0
- package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
- package/dist/core/ingestion/resolvers/rust.js +73 -0
- package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
- package/dist/core/ingestion/resolvers/standard.js +123 -0
- package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
- package/dist/core/ingestion/resolvers/utils.js +122 -0
- package/dist/core/ingestion/structure-processor.d.ts +2 -0
- package/dist/core/ingestion/structure-processor.js +36 -0
- package/dist/core/ingestion/symbol-table.d.ts +63 -0
- package/dist/core/ingestion/symbol-table.js +85 -0
- package/dist/core/ingestion/tree-sitter-queries.d.ts +15 -0
- package/dist/core/ingestion/tree-sitter-queries.js +888 -0
- package/dist/core/ingestion/type-env.d.ts +49 -0
- package/dist/core/ingestion/type-env.js +613 -0
- package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
- package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/csharp.js +383 -0
- package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/go.js +467 -0
- package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
- package/dist/core/ingestion/type-extractors/index.js +31 -0
- package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
- package/dist/core/ingestion/type-extractors/jvm.js +681 -0
- package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/php.js +549 -0
- package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/python.js +455 -0
- package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/ruby.js +389 -0
- package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/rust.js +456 -0
- package/dist/core/ingestion/type-extractors/shared.d.ts +145 -0
- package/dist/core/ingestion/type-extractors/shared.js +810 -0
- package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/swift.js +137 -0
- package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
- package/dist/core/ingestion/type-extractors/types.js +1 -0
- package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/typescript.js +494 -0
- package/dist/core/ingestion/utils.d.ts +138 -0
- package/dist/core/ingestion/utils.js +1290 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +122 -0
- package/dist/core/ingestion/workers/parse-worker.js +1126 -0
- package/dist/core/ingestion/workers/worker-pool.d.ts +16 -0
- package/dist/core/ingestion/workers/worker-pool.js +128 -0
- package/dist/core/lbug/csv-generator.d.ts +33 -0
- package/dist/core/lbug/csv-generator.js +366 -0
- package/dist/core/lbug/lbug-adapter.d.ts +103 -0
- package/dist/core/lbug/lbug-adapter.js +769 -0
- package/dist/core/lbug/schema.d.ts +53 -0
- package/dist/core/lbug/schema.js +430 -0
- package/dist/core/search/bm25-index.d.ts +23 -0
- package/dist/core/search/bm25-index.js +96 -0
- package/dist/core/search/hybrid-search.d.ts +49 -0
- package/dist/core/search/hybrid-search.js +118 -0
- package/dist/core/tree-sitter/parser-loader.d.ts +5 -0
- package/dist/core/tree-sitter/parser-loader.js +63 -0
- package/dist/core/wiki/generator.d.ts +120 -0
- package/dist/core/wiki/generator.js +939 -0
- package/dist/core/wiki/graph-queries.d.ts +80 -0
- package/dist/core/wiki/graph-queries.js +238 -0
- package/dist/core/wiki/html-viewer.d.ts +10 -0
- package/dist/core/wiki/html-viewer.js +297 -0
- package/dist/core/wiki/llm-client.d.ts +43 -0
- package/dist/core/wiki/llm-client.js +186 -0
- package/dist/core/wiki/prompts.d.ts +53 -0
- package/dist/core/wiki/prompts.js +174 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +3 -0
- package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
- package/dist/mcp/compatible-stdio-transport.js +200 -0
- package/dist/mcp/core/embedder.d.ts +27 -0
- package/dist/mcp/core/embedder.js +108 -0
- package/dist/mcp/core/lbug-adapter.d.ts +57 -0
- package/dist/mcp/core/lbug-adapter.js +455 -0
- package/dist/mcp/local/local-backend.d.ts +181 -0
- package/dist/mcp/local/local-backend.js +1722 -0
- package/dist/mcp/resources.d.ts +31 -0
- package/dist/mcp/resources.js +411 -0
- package/dist/mcp/server.d.ts +23 -0
- package/dist/mcp/server.js +296 -0
- package/dist/mcp/staleness.d.ts +15 -0
- package/dist/mcp/staleness.js +29 -0
- package/dist/mcp/tools.d.ts +24 -0
- package/dist/mcp/tools.js +292 -0
- package/dist/server/api.d.ts +10 -0
- package/dist/server/api.js +344 -0
- package/dist/server/mcp-http.d.ts +13 -0
- package/dist/server/mcp-http.js +100 -0
- package/dist/storage/git.d.ts +6 -0
- package/dist/storage/git.js +35 -0
- package/dist/storage/repo-manager.d.ts +138 -0
- package/dist/storage/repo-manager.js +299 -0
- package/dist/types/pipeline.d.ts +32 -0
- package/dist/types/pipeline.js +18 -0
- package/dist/unreal/bridge.d.ts +4 -0
- package/dist/unreal/bridge.js +113 -0
- package/dist/unreal/config.d.ts +6 -0
- package/dist/unreal/config.js +55 -0
- package/dist/unreal/types.d.ts +105 -0
- package/dist/unreal/types.js +1 -0
- package/hooks/claude/gitnexus-hook.cjs +238 -0
- package/hooks/claude/pre-tool-use.sh +79 -0
- package/hooks/claude/session-start.sh +42 -0
- package/package.json +100 -0
- package/scripts/ensure-cli-executable.cjs +21 -0
- package/scripts/patch-tree-sitter-swift.cjs +74 -0
- package/scripts/setup-unreal-gitnexus.ps1 +191 -0
- package/skills/gitnexus-cli.md +82 -0
- package/skills/gitnexus-debugging.md +89 -0
- package/skills/gitnexus-exploring.md +78 -0
- package/skills/gitnexus-guide.md +64 -0
- package/skills/gitnexus-impact-analysis.md +97 -0
- package/skills/gitnexus-pr-review.md +163 -0
- package/skills/gitnexus-refactoring.md +121 -0
- package/vendor/GitNexusUnreal/GitNexusUnreal.uplugin +18 -0
- package/vendor/GitNexusUnreal/Source/GitNexusUnreal/GitNexusUnreal.Build.cs +29 -0
- package/vendor/GitNexusUnreal/Source/GitNexusUnreal/Private/GitNexusBlueprintAnalyzerCommandlet.cpp +465 -0
- package/vendor/GitNexusUnreal/Source/GitNexusUnreal/Private/GitNexusUnrealModule.cpp +15 -0
- package/vendor/GitNexusUnreal/Source/GitNexusUnreal/Public/GitNexusBlueprintAnalyzerCommandlet.h +46 -0
- package/vendor/GitNexusUnreal/Source/GitNexusUnreal/Public/GitNexusUnrealModule.h +10 -0
- package/vendor/leiden/index.cjs +355 -0
- package/vendor/leiden/utils.cjs +392 -0
|
@@ -0,0 +1,888 @@
|
|
|
1
|
+
import { SupportedLanguages } from '../../config/supported-languages.js';
|
|
2
|
+
/*
|
|
3
|
+
* Tree-sitter queries for extracting code definitions.
|
|
4
|
+
*
|
|
5
|
+
* Note: Different grammars (typescript vs tsx vs javascript) may have
|
|
6
|
+
* slightly different node types. These queries are designed to be
|
|
7
|
+
* compatible with the standard tree-sitter grammars.
|
|
8
|
+
*/
|
|
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
|
+
; Class properties — public_field_definition covers most TS class fields
|
|
64
|
+
(public_field_definition
|
|
65
|
+
name: (property_identifier) @name) @definition.property
|
|
66
|
+
|
|
67
|
+
; Private class fields: #address: Address
|
|
68
|
+
(public_field_definition
|
|
69
|
+
name: (private_property_identifier) @name) @definition.property
|
|
70
|
+
|
|
71
|
+
; Constructor parameter properties: constructor(public address: Address)
|
|
72
|
+
(required_parameter
|
|
73
|
+
(accessibility_modifier)
|
|
74
|
+
pattern: (identifier) @name) @definition.property
|
|
75
|
+
|
|
76
|
+
; Heritage queries - class extends
|
|
77
|
+
(class_declaration
|
|
78
|
+
name: (type_identifier) @heritage.class
|
|
79
|
+
(class_heritage
|
|
80
|
+
(extends_clause
|
|
81
|
+
value: (identifier) @heritage.extends))) @heritage
|
|
82
|
+
|
|
83
|
+
; Heritage queries - class implements interface
|
|
84
|
+
(class_declaration
|
|
85
|
+
name: (type_identifier) @heritage.class
|
|
86
|
+
(class_heritage
|
|
87
|
+
(implements_clause
|
|
88
|
+
(type_identifier) @heritage.implements))) @heritage.impl
|
|
89
|
+
|
|
90
|
+
; Write access: obj.field = value
|
|
91
|
+
(assignment_expression
|
|
92
|
+
left: (member_expression
|
|
93
|
+
object: (_) @assignment.receiver
|
|
94
|
+
property: (property_identifier) @assignment.property)
|
|
95
|
+
right: (_)) @assignment
|
|
96
|
+
|
|
97
|
+
; Write access: obj.field += value (compound assignment)
|
|
98
|
+
(augmented_assignment_expression
|
|
99
|
+
left: (member_expression
|
|
100
|
+
object: (_) @assignment.receiver
|
|
101
|
+
property: (property_identifier) @assignment.property)
|
|
102
|
+
right: (_)) @assignment
|
|
103
|
+
`;
|
|
104
|
+
// JavaScript queries - works with tree-sitter-javascript
|
|
105
|
+
export const JAVASCRIPT_QUERIES = `
|
|
106
|
+
(class_declaration
|
|
107
|
+
name: (identifier) @name) @definition.class
|
|
108
|
+
|
|
109
|
+
(function_declaration
|
|
110
|
+
name: (identifier) @name) @definition.function
|
|
111
|
+
|
|
112
|
+
(method_definition
|
|
113
|
+
name: (property_identifier) @name) @definition.method
|
|
114
|
+
|
|
115
|
+
(lexical_declaration
|
|
116
|
+
(variable_declarator
|
|
117
|
+
name: (identifier) @name
|
|
118
|
+
value: (arrow_function))) @definition.function
|
|
119
|
+
|
|
120
|
+
(lexical_declaration
|
|
121
|
+
(variable_declarator
|
|
122
|
+
name: (identifier) @name
|
|
123
|
+
value: (function_expression))) @definition.function
|
|
124
|
+
|
|
125
|
+
(export_statement
|
|
126
|
+
declaration: (lexical_declaration
|
|
127
|
+
(variable_declarator
|
|
128
|
+
name: (identifier) @name
|
|
129
|
+
value: (arrow_function)))) @definition.function
|
|
130
|
+
|
|
131
|
+
(export_statement
|
|
132
|
+
declaration: (lexical_declaration
|
|
133
|
+
(variable_declarator
|
|
134
|
+
name: (identifier) @name
|
|
135
|
+
value: (function_expression)))) @definition.function
|
|
136
|
+
|
|
137
|
+
(import_statement
|
|
138
|
+
source: (string) @import.source) @import
|
|
139
|
+
|
|
140
|
+
; Re-export statements: export { X } from './y'
|
|
141
|
+
(export_statement
|
|
142
|
+
source: (string) @import.source) @import
|
|
143
|
+
|
|
144
|
+
(call_expression
|
|
145
|
+
function: (identifier) @call.name) @call
|
|
146
|
+
|
|
147
|
+
(call_expression
|
|
148
|
+
function: (member_expression
|
|
149
|
+
property: (property_identifier) @call.name)) @call
|
|
150
|
+
|
|
151
|
+
; Constructor calls: new Foo()
|
|
152
|
+
(new_expression
|
|
153
|
+
constructor: (identifier) @call.name) @call
|
|
154
|
+
|
|
155
|
+
; Class fields — field_definition captures JS class fields (class User { address = ... })
|
|
156
|
+
(field_definition
|
|
157
|
+
property: (property_identifier) @name) @definition.property
|
|
158
|
+
|
|
159
|
+
; Heritage queries - class extends (JavaScript uses different AST than TypeScript)
|
|
160
|
+
; In tree-sitter-javascript, class_heritage directly contains the parent identifier
|
|
161
|
+
(class_declaration
|
|
162
|
+
name: (identifier) @heritage.class
|
|
163
|
+
(class_heritage
|
|
164
|
+
(identifier) @heritage.extends)) @heritage
|
|
165
|
+
|
|
166
|
+
; Write access: obj.field = value
|
|
167
|
+
(assignment_expression
|
|
168
|
+
left: (member_expression
|
|
169
|
+
object: (_) @assignment.receiver
|
|
170
|
+
property: (property_identifier) @assignment.property)
|
|
171
|
+
right: (_)) @assignment
|
|
172
|
+
|
|
173
|
+
; Write access: obj.field += value (compound assignment)
|
|
174
|
+
(augmented_assignment_expression
|
|
175
|
+
left: (member_expression
|
|
176
|
+
object: (_) @assignment.receiver
|
|
177
|
+
property: (property_identifier) @assignment.property)
|
|
178
|
+
right: (_)) @assignment
|
|
179
|
+
`;
|
|
180
|
+
// Python queries - works with tree-sitter-python
|
|
181
|
+
export const PYTHON_QUERIES = `
|
|
182
|
+
(class_definition
|
|
183
|
+
name: (identifier) @name) @definition.class
|
|
184
|
+
|
|
185
|
+
(function_definition
|
|
186
|
+
name: (identifier) @name) @definition.function
|
|
187
|
+
|
|
188
|
+
(import_statement
|
|
189
|
+
name: (dotted_name) @import.source) @import
|
|
190
|
+
|
|
191
|
+
(import_from_statement
|
|
192
|
+
module_name: (dotted_name) @import.source) @import
|
|
193
|
+
|
|
194
|
+
(import_from_statement
|
|
195
|
+
module_name: (relative_import) @import.source) @import
|
|
196
|
+
|
|
197
|
+
(call
|
|
198
|
+
function: (identifier) @call.name) @call
|
|
199
|
+
|
|
200
|
+
(call
|
|
201
|
+
function: (attribute
|
|
202
|
+
attribute: (identifier) @call.name)) @call
|
|
203
|
+
|
|
204
|
+
; Class attribute type annotations — PEP 526: address: Address or address: Address = Address()
|
|
205
|
+
; Both bare annotations (address: Address) and annotated assignments (name: str = "test")
|
|
206
|
+
; are parsed as (assignment left: ... type: ...) in tree-sitter-python.
|
|
207
|
+
(expression_statement
|
|
208
|
+
(assignment
|
|
209
|
+
left: (identifier) @name
|
|
210
|
+
type: (type)) @definition.property)
|
|
211
|
+
|
|
212
|
+
; Heritage queries - Python class inheritance
|
|
213
|
+
(class_definition
|
|
214
|
+
name: (identifier) @heritage.class
|
|
215
|
+
superclasses: (argument_list
|
|
216
|
+
(identifier) @heritage.extends)) @heritage
|
|
217
|
+
|
|
218
|
+
; Write access: obj.field = value
|
|
219
|
+
(assignment
|
|
220
|
+
left: (attribute
|
|
221
|
+
object: (_) @assignment.receiver
|
|
222
|
+
attribute: (identifier) @assignment.property)
|
|
223
|
+
right: (_)) @assignment
|
|
224
|
+
|
|
225
|
+
; Write access: obj.field += value (compound assignment)
|
|
226
|
+
(augmented_assignment
|
|
227
|
+
left: (attribute
|
|
228
|
+
object: (_) @assignment.receiver
|
|
229
|
+
attribute: (identifier) @assignment.property)
|
|
230
|
+
right: (_)) @assignment
|
|
231
|
+
`;
|
|
232
|
+
// Java queries - works with tree-sitter-java
|
|
233
|
+
export const JAVA_QUERIES = `
|
|
234
|
+
; Classes, Interfaces, Enums, Annotations
|
|
235
|
+
(class_declaration name: (identifier) @name) @definition.class
|
|
236
|
+
(interface_declaration name: (identifier) @name) @definition.interface
|
|
237
|
+
(enum_declaration name: (identifier) @name) @definition.enum
|
|
238
|
+
(annotation_type_declaration name: (identifier) @name) @definition.annotation
|
|
239
|
+
|
|
240
|
+
; Methods & Constructors
|
|
241
|
+
(method_declaration name: (identifier) @name) @definition.method
|
|
242
|
+
(constructor_declaration name: (identifier) @name) @definition.constructor
|
|
243
|
+
|
|
244
|
+
; Fields — typed field declarations inside class bodies
|
|
245
|
+
(field_declaration
|
|
246
|
+
declarator: (variable_declarator
|
|
247
|
+
name: (identifier) @name)) @definition.property
|
|
248
|
+
|
|
249
|
+
; Imports - capture any import declaration child as source
|
|
250
|
+
(import_declaration (_) @import.source) @import
|
|
251
|
+
|
|
252
|
+
; Calls
|
|
253
|
+
(method_invocation name: (identifier) @call.name) @call
|
|
254
|
+
(method_invocation object: (_) name: (identifier) @call.name) @call
|
|
255
|
+
|
|
256
|
+
; Constructor calls: new Foo()
|
|
257
|
+
(object_creation_expression type: (type_identifier) @call.name) @call
|
|
258
|
+
|
|
259
|
+
; Heritage - extends class
|
|
260
|
+
(class_declaration name: (identifier) @heritage.class
|
|
261
|
+
(superclass (type_identifier) @heritage.extends)) @heritage
|
|
262
|
+
|
|
263
|
+
; Heritage - implements interfaces
|
|
264
|
+
(class_declaration name: (identifier) @heritage.class
|
|
265
|
+
(super_interfaces (type_list (type_identifier) @heritage.implements))) @heritage.impl
|
|
266
|
+
|
|
267
|
+
; Write access: obj.field = value
|
|
268
|
+
(assignment_expression
|
|
269
|
+
left: (field_access
|
|
270
|
+
object: (_) @assignment.receiver
|
|
271
|
+
field: (identifier) @assignment.property)
|
|
272
|
+
right: (_)) @assignment
|
|
273
|
+
`;
|
|
274
|
+
// C queries - works with tree-sitter-c
|
|
275
|
+
export const C_QUERIES = `
|
|
276
|
+
; Functions (direct declarator)
|
|
277
|
+
(function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
|
|
278
|
+
(declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function
|
|
279
|
+
|
|
280
|
+
; Functions returning pointers (pointer_declarator wraps function_declarator)
|
|
281
|
+
(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
|
|
282
|
+
(declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
|
|
283
|
+
|
|
284
|
+
; Functions returning double pointers (nested pointer_declarator)
|
|
285
|
+
(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function
|
|
286
|
+
|
|
287
|
+
; Structs, Unions, Enums, Typedefs
|
|
288
|
+
(struct_specifier name: (type_identifier) @name) @definition.struct
|
|
289
|
+
(union_specifier name: (type_identifier) @name) @definition.union
|
|
290
|
+
(enum_specifier name: (type_identifier) @name) @definition.enum
|
|
291
|
+
(type_definition declarator: (type_identifier) @name) @definition.typedef
|
|
292
|
+
|
|
293
|
+
; Macros
|
|
294
|
+
(preproc_function_def name: (identifier) @name) @definition.macro
|
|
295
|
+
(preproc_def name: (identifier) @name) @definition.macro
|
|
296
|
+
|
|
297
|
+
; Includes
|
|
298
|
+
(preproc_include path: (_) @import.source) @import
|
|
299
|
+
|
|
300
|
+
; Calls
|
|
301
|
+
(call_expression function: (identifier) @call.name) @call
|
|
302
|
+
(call_expression function: (field_expression field: (field_identifier) @call.name)) @call
|
|
303
|
+
`;
|
|
304
|
+
// Go queries - works with tree-sitter-go
|
|
305
|
+
export const GO_QUERIES = `
|
|
306
|
+
; Functions & Methods
|
|
307
|
+
(function_declaration name: (identifier) @name) @definition.function
|
|
308
|
+
(method_declaration name: (field_identifier) @name) @definition.method
|
|
309
|
+
|
|
310
|
+
; Types
|
|
311
|
+
(type_declaration (type_spec name: (type_identifier) @name type: (struct_type))) @definition.struct
|
|
312
|
+
(type_declaration (type_spec name: (type_identifier) @name type: (interface_type))) @definition.interface
|
|
313
|
+
|
|
314
|
+
; Imports
|
|
315
|
+
(import_declaration (import_spec path: (interpreted_string_literal) @import.source)) @import
|
|
316
|
+
(import_declaration (import_spec_list (import_spec path: (interpreted_string_literal) @import.source))) @import
|
|
317
|
+
|
|
318
|
+
; Struct fields — named field declarations inside struct types
|
|
319
|
+
(field_declaration_list
|
|
320
|
+
(field_declaration
|
|
321
|
+
name: (field_identifier) @name) @definition.property)
|
|
322
|
+
|
|
323
|
+
; Struct embedding (anonymous fields = inheritance)
|
|
324
|
+
(type_declaration
|
|
325
|
+
(type_spec
|
|
326
|
+
name: (type_identifier) @heritage.class
|
|
327
|
+
type: (struct_type
|
|
328
|
+
(field_declaration_list
|
|
329
|
+
(field_declaration
|
|
330
|
+
type: (type_identifier) @heritage.extends))))) @definition.struct
|
|
331
|
+
|
|
332
|
+
; Calls
|
|
333
|
+
(call_expression function: (identifier) @call.name) @call
|
|
334
|
+
(call_expression function: (selector_expression field: (field_identifier) @call.name)) @call
|
|
335
|
+
|
|
336
|
+
; Struct literal construction: User{Name: "Alice"}
|
|
337
|
+
(composite_literal type: (type_identifier) @call.name) @call
|
|
338
|
+
|
|
339
|
+
; Write access: obj.field = value
|
|
340
|
+
(assignment_statement
|
|
341
|
+
left: (expression_list
|
|
342
|
+
(selector_expression
|
|
343
|
+
operand: (_) @assignment.receiver
|
|
344
|
+
field: (field_identifier) @assignment.property))
|
|
345
|
+
right: (_)) @assignment
|
|
346
|
+
`;
|
|
347
|
+
// C++ queries - works with tree-sitter-cpp
|
|
348
|
+
export const CPP_QUERIES = `
|
|
349
|
+
; Classes, Structs, Namespaces
|
|
350
|
+
(class_specifier name: (type_identifier) @name) @definition.class
|
|
351
|
+
(struct_specifier name: (type_identifier) @name) @definition.struct
|
|
352
|
+
(namespace_definition name: (namespace_identifier) @name) @definition.namespace
|
|
353
|
+
(enum_specifier name: (type_identifier) @name) @definition.enum
|
|
354
|
+
|
|
355
|
+
; Typedefs and unions (common in C-style headers and mixed C/C++ code)
|
|
356
|
+
(type_definition declarator: (type_identifier) @name) @definition.typedef
|
|
357
|
+
(union_specifier name: (type_identifier) @name) @definition.union
|
|
358
|
+
|
|
359
|
+
; Macros
|
|
360
|
+
(preproc_function_def name: (identifier) @name) @definition.macro
|
|
361
|
+
(preproc_def name: (identifier) @name) @definition.macro
|
|
362
|
+
|
|
363
|
+
; Functions & Methods (direct declarator)
|
|
364
|
+
(function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
|
|
365
|
+
(function_definition declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))) @definition.method
|
|
366
|
+
|
|
367
|
+
; Functions/methods returning pointers (pointer_declarator wraps function_declarator)
|
|
368
|
+
(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
|
|
369
|
+
(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method
|
|
370
|
+
|
|
371
|
+
; Functions/methods returning double pointers (nested pointer_declarator)
|
|
372
|
+
(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function
|
|
373
|
+
(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))))) @definition.method
|
|
374
|
+
|
|
375
|
+
; Functions/methods returning references (reference_declarator wraps function_declarator)
|
|
376
|
+
(function_definition declarator: (reference_declarator (function_declarator declarator: (identifier) @name))) @definition.function
|
|
377
|
+
(function_definition declarator: (reference_declarator (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method
|
|
378
|
+
|
|
379
|
+
; Destructors (destructor_name is distinct from identifier in tree-sitter-cpp)
|
|
380
|
+
(function_definition declarator: (function_declarator declarator: (qualified_identifier name: (destructor_name) @name))) @definition.method
|
|
381
|
+
|
|
382
|
+
; Function declarations / prototypes (common in headers)
|
|
383
|
+
(declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function
|
|
384
|
+
(declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
|
|
385
|
+
|
|
386
|
+
; Class/struct data member fields (Address address; int count;)
|
|
387
|
+
; Uses field_identifier to exclude method declarations (which use function_declarator)
|
|
388
|
+
(field_declaration
|
|
389
|
+
declarator: (field_identifier) @name) @definition.property
|
|
390
|
+
|
|
391
|
+
; Pointer member fields (Address* address;)
|
|
392
|
+
(field_declaration
|
|
393
|
+
declarator: (pointer_declarator
|
|
394
|
+
declarator: (field_identifier) @name)) @definition.property
|
|
395
|
+
|
|
396
|
+
; Reference member fields (Address& address;)
|
|
397
|
+
(field_declaration
|
|
398
|
+
declarator: (reference_declarator
|
|
399
|
+
(field_identifier) @name)) @definition.property
|
|
400
|
+
|
|
401
|
+
; Inline class method declarations (inside class body, no body: void Foo();)
|
|
402
|
+
(field_declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.method
|
|
403
|
+
|
|
404
|
+
; Inline class method definitions (inside class body, with body: void Foo() { ... })
|
|
405
|
+
(field_declaration_list
|
|
406
|
+
(function_definition
|
|
407
|
+
declarator: (function_declarator
|
|
408
|
+
declarator: [(field_identifier) (identifier) (operator_name) (destructor_name)] @name)) @definition.method)
|
|
409
|
+
|
|
410
|
+
; Templates
|
|
411
|
+
(template_declaration (class_specifier name: (type_identifier) @name)) @definition.template
|
|
412
|
+
(template_declaration (function_definition declarator: (function_declarator declarator: (identifier) @name))) @definition.template
|
|
413
|
+
|
|
414
|
+
; Includes
|
|
415
|
+
(preproc_include path: (_) @import.source) @import
|
|
416
|
+
|
|
417
|
+
; Calls
|
|
418
|
+
(call_expression function: (identifier) @call.name) @call
|
|
419
|
+
(call_expression function: (field_expression field: (field_identifier) @call.name)) @call
|
|
420
|
+
(call_expression function: (qualified_identifier name: (identifier) @call.name)) @call
|
|
421
|
+
(call_expression function: (template_function name: (identifier) @call.name)) @call
|
|
422
|
+
|
|
423
|
+
; Constructor calls: new User()
|
|
424
|
+
(new_expression type: (type_identifier) @call.name) @call
|
|
425
|
+
|
|
426
|
+
; Heritage
|
|
427
|
+
(class_specifier name: (type_identifier) @heritage.class
|
|
428
|
+
(base_class_clause (type_identifier) @heritage.extends)) @heritage
|
|
429
|
+
(class_specifier name: (type_identifier) @heritage.class
|
|
430
|
+
(base_class_clause (access_specifier) (type_identifier) @heritage.extends)) @heritage
|
|
431
|
+
|
|
432
|
+
; Write access: obj.field = value
|
|
433
|
+
(assignment_expression
|
|
434
|
+
left: (field_expression
|
|
435
|
+
argument: (_) @assignment.receiver
|
|
436
|
+
field: (field_identifier) @assignment.property)
|
|
437
|
+
right: (_)) @assignment
|
|
438
|
+
|
|
439
|
+
`;
|
|
440
|
+
// C# queries - works with tree-sitter-c-sharp
|
|
441
|
+
export const CSHARP_QUERIES = `
|
|
442
|
+
; Types
|
|
443
|
+
(class_declaration name: (identifier) @name) @definition.class
|
|
444
|
+
(interface_declaration name: (identifier) @name) @definition.interface
|
|
445
|
+
(struct_declaration name: (identifier) @name) @definition.struct
|
|
446
|
+
(enum_declaration name: (identifier) @name) @definition.enum
|
|
447
|
+
(record_declaration name: (identifier) @name) @definition.record
|
|
448
|
+
(delegate_declaration name: (identifier) @name) @definition.delegate
|
|
449
|
+
|
|
450
|
+
; Namespaces (block form and C# 10+ file-scoped form)
|
|
451
|
+
(namespace_declaration name: (identifier) @name) @definition.namespace
|
|
452
|
+
(namespace_declaration name: (qualified_name) @name) @definition.namespace
|
|
453
|
+
(file_scoped_namespace_declaration name: (identifier) @name) @definition.namespace
|
|
454
|
+
(file_scoped_namespace_declaration name: (qualified_name) @name) @definition.namespace
|
|
455
|
+
|
|
456
|
+
; Methods & Properties
|
|
457
|
+
(method_declaration name: (identifier) @name) @definition.method
|
|
458
|
+
(local_function_statement name: (identifier) @name) @definition.function
|
|
459
|
+
(constructor_declaration name: (identifier) @name) @definition.constructor
|
|
460
|
+
(property_declaration name: (identifier) @name) @definition.property
|
|
461
|
+
|
|
462
|
+
; Primary constructors (C# 12): class User(string name, int age) { }
|
|
463
|
+
(class_declaration name: (identifier) @name (parameter_list) @definition.constructor)
|
|
464
|
+
(record_declaration name: (identifier) @name (parameter_list) @definition.constructor)
|
|
465
|
+
|
|
466
|
+
; Using
|
|
467
|
+
(using_directive (qualified_name) @import.source) @import
|
|
468
|
+
(using_directive (identifier) @import.source) @import
|
|
469
|
+
|
|
470
|
+
; Calls
|
|
471
|
+
(invocation_expression function: (identifier) @call.name) @call
|
|
472
|
+
(invocation_expression function: (member_access_expression name: (identifier) @call.name)) @call
|
|
473
|
+
|
|
474
|
+
; Null-conditional method calls: user?.Save()
|
|
475
|
+
; Parses as: invocation_expression → conditional_access_expression → member_binding_expression → identifier
|
|
476
|
+
(invocation_expression
|
|
477
|
+
function: (conditional_access_expression
|
|
478
|
+
(member_binding_expression
|
|
479
|
+
(identifier) @call.name))) @call
|
|
480
|
+
|
|
481
|
+
; Constructor calls: new Foo() and new Foo { Props }
|
|
482
|
+
(object_creation_expression type: (identifier) @call.name) @call
|
|
483
|
+
|
|
484
|
+
; Target-typed new (C# 9): User u = new("x", 5)
|
|
485
|
+
(variable_declaration type: (identifier) @call.name (variable_declarator (implicit_object_creation_expression) @call))
|
|
486
|
+
|
|
487
|
+
; Heritage
|
|
488
|
+
(class_declaration name: (identifier) @heritage.class
|
|
489
|
+
(base_list (identifier) @heritage.extends)) @heritage
|
|
490
|
+
(class_declaration name: (identifier) @heritage.class
|
|
491
|
+
(base_list (generic_name (identifier) @heritage.extends))) @heritage
|
|
492
|
+
|
|
493
|
+
; Write access: obj.field = value
|
|
494
|
+
(assignment_expression
|
|
495
|
+
left: (member_access_expression
|
|
496
|
+
expression: (_) @assignment.receiver
|
|
497
|
+
name: (identifier) @assignment.property)
|
|
498
|
+
right: (_)) @assignment
|
|
499
|
+
`;
|
|
500
|
+
// Rust queries - works with tree-sitter-rust
|
|
501
|
+
export const RUST_QUERIES = `
|
|
502
|
+
; Functions & Items
|
|
503
|
+
(function_item name: (identifier) @name) @definition.function
|
|
504
|
+
(struct_item name: (type_identifier) @name) @definition.struct
|
|
505
|
+
(enum_item name: (type_identifier) @name) @definition.enum
|
|
506
|
+
(trait_item name: (type_identifier) @name) @definition.trait
|
|
507
|
+
(impl_item type: (type_identifier) @name !trait) @definition.impl
|
|
508
|
+
(impl_item type: (generic_type type: (type_identifier) @name) !trait) @definition.impl
|
|
509
|
+
(mod_item name: (identifier) @name) @definition.module
|
|
510
|
+
|
|
511
|
+
; Type aliases, const, static, macros
|
|
512
|
+
(type_item name: (type_identifier) @name) @definition.type
|
|
513
|
+
(const_item name: (identifier) @name) @definition.const
|
|
514
|
+
(static_item name: (identifier) @name) @definition.static
|
|
515
|
+
(macro_definition name: (identifier) @name) @definition.macro
|
|
516
|
+
|
|
517
|
+
; Use statements
|
|
518
|
+
(use_declaration argument: (_) @import.source) @import
|
|
519
|
+
|
|
520
|
+
; Calls
|
|
521
|
+
(call_expression function: (identifier) @call.name) @call
|
|
522
|
+
(call_expression function: (field_expression field: (field_identifier) @call.name)) @call
|
|
523
|
+
(call_expression function: (scoped_identifier name: (identifier) @call.name)) @call
|
|
524
|
+
(call_expression function: (generic_function function: (identifier) @call.name)) @call
|
|
525
|
+
|
|
526
|
+
; Struct literal construction: User { name: value }
|
|
527
|
+
(struct_expression name: (type_identifier) @call.name) @call
|
|
528
|
+
|
|
529
|
+
; Struct fields — named field declarations inside struct bodies
|
|
530
|
+
(field_declaration_list
|
|
531
|
+
(field_declaration
|
|
532
|
+
name: (field_identifier) @name) @definition.property)
|
|
533
|
+
|
|
534
|
+
; Heritage (trait implementation) — all combinations of concrete/generic trait × concrete/generic type
|
|
535
|
+
(impl_item trait: (type_identifier) @heritage.trait type: (type_identifier) @heritage.class) @heritage
|
|
536
|
+
(impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (type_identifier) @heritage.class) @heritage
|
|
537
|
+
(impl_item trait: (type_identifier) @heritage.trait type: (generic_type type: (type_identifier) @heritage.class)) @heritage
|
|
538
|
+
(impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (generic_type type: (type_identifier) @heritage.class)) @heritage
|
|
539
|
+
|
|
540
|
+
; Write access: obj.field = value
|
|
541
|
+
(assignment_expression
|
|
542
|
+
left: (field_expression
|
|
543
|
+
value: (_) @assignment.receiver
|
|
544
|
+
field: (field_identifier) @assignment.property)
|
|
545
|
+
right: (_)) @assignment
|
|
546
|
+
|
|
547
|
+
; Write access: obj.field += value (compound assignment)
|
|
548
|
+
(compound_assignment_expr
|
|
549
|
+
left: (field_expression
|
|
550
|
+
value: (_) @assignment.receiver
|
|
551
|
+
field: (field_identifier) @assignment.property)
|
|
552
|
+
right: (_)) @assignment
|
|
553
|
+
`;
|
|
554
|
+
// PHP queries - works with tree-sitter-php (php_only grammar)
|
|
555
|
+
export const PHP_QUERIES = `
|
|
556
|
+
; ── Namespace ────────────────────────────────────────────────────────────────
|
|
557
|
+
(namespace_definition
|
|
558
|
+
name: (namespace_name) @name) @definition.namespace
|
|
559
|
+
|
|
560
|
+
; ── Classes ──────────────────────────────────────────────────────────────────
|
|
561
|
+
(class_declaration
|
|
562
|
+
name: (name) @name) @definition.class
|
|
563
|
+
|
|
564
|
+
; ── Interfaces ───────────────────────────────────────────────────────────────
|
|
565
|
+
(interface_declaration
|
|
566
|
+
name: (name) @name) @definition.interface
|
|
567
|
+
|
|
568
|
+
; ── Traits ───────────────────────────────────────────────────────────────────
|
|
569
|
+
(trait_declaration
|
|
570
|
+
name: (name) @name) @definition.trait
|
|
571
|
+
|
|
572
|
+
; ── Enums (PHP 8.1) ──────────────────────────────────────────────────────────
|
|
573
|
+
(enum_declaration
|
|
574
|
+
name: (name) @name) @definition.enum
|
|
575
|
+
|
|
576
|
+
; ── Top-level functions ───────────────────────────────────────────────────────
|
|
577
|
+
(function_definition
|
|
578
|
+
name: (name) @name) @definition.function
|
|
579
|
+
|
|
580
|
+
; ── Methods (including constructors) ─────────────────────────────────────────
|
|
581
|
+
(method_declaration
|
|
582
|
+
name: (name) @name) @definition.method
|
|
583
|
+
|
|
584
|
+
; ── Class properties (including Eloquent $fillable, $casts, etc.) ────────────
|
|
585
|
+
(property_declaration
|
|
586
|
+
(property_element
|
|
587
|
+
(variable_name
|
|
588
|
+
(name) @name))) @definition.property
|
|
589
|
+
|
|
590
|
+
; Constructor property promotion (PHP 8.0+: public Address $address in __construct)
|
|
591
|
+
(method_declaration
|
|
592
|
+
parameters: (formal_parameters
|
|
593
|
+
(property_promotion_parameter
|
|
594
|
+
name: (variable_name
|
|
595
|
+
(name) @name)))) @definition.property
|
|
596
|
+
|
|
597
|
+
; ── Imports: use statements ──────────────────────────────────────────────────
|
|
598
|
+
; Simple: use App\\Models\\User;
|
|
599
|
+
(namespace_use_declaration
|
|
600
|
+
(namespace_use_clause
|
|
601
|
+
(qualified_name) @import.source)) @import
|
|
602
|
+
|
|
603
|
+
; ── Function/method calls ────────────────────────────────────────────────────
|
|
604
|
+
; Regular function call: foo()
|
|
605
|
+
(function_call_expression
|
|
606
|
+
function: (name) @call.name) @call
|
|
607
|
+
|
|
608
|
+
; Method call: $obj->method()
|
|
609
|
+
(member_call_expression
|
|
610
|
+
name: (name) @call.name) @call
|
|
611
|
+
|
|
612
|
+
; Nullsafe method call: $obj?->method()
|
|
613
|
+
(nullsafe_member_call_expression
|
|
614
|
+
name: (name) @call.name) @call
|
|
615
|
+
|
|
616
|
+
; Static call: Foo::bar() (php_only uses scoped_call_expression)
|
|
617
|
+
(scoped_call_expression
|
|
618
|
+
name: (name) @call.name) @call
|
|
619
|
+
|
|
620
|
+
; Constructor call: new User()
|
|
621
|
+
(object_creation_expression (name) @call.name) @call
|
|
622
|
+
|
|
623
|
+
; ── Heritage: extends ────────────────────────────────────────────────────────
|
|
624
|
+
(class_declaration
|
|
625
|
+
name: (name) @heritage.class
|
|
626
|
+
(base_clause
|
|
627
|
+
[(name) (qualified_name)] @heritage.extends)) @heritage
|
|
628
|
+
|
|
629
|
+
; ── Heritage: implements ─────────────────────────────────────────────────────
|
|
630
|
+
(class_declaration
|
|
631
|
+
name: (name) @heritage.class
|
|
632
|
+
(class_interface_clause
|
|
633
|
+
[(name) (qualified_name)] @heritage.implements)) @heritage.impl
|
|
634
|
+
|
|
635
|
+
; ── Heritage: use trait (must capture enclosing class name) ──────────────────
|
|
636
|
+
(class_declaration
|
|
637
|
+
name: (name) @heritage.class
|
|
638
|
+
body: (declaration_list
|
|
639
|
+
(use_declaration
|
|
640
|
+
[(name) (qualified_name)] @heritage.trait))) @heritage
|
|
641
|
+
|
|
642
|
+
; Write access: $obj->field = value
|
|
643
|
+
(assignment_expression
|
|
644
|
+
left: (member_access_expression
|
|
645
|
+
object: (_) @assignment.receiver
|
|
646
|
+
name: (name) @assignment.property)
|
|
647
|
+
right: (_)) @assignment
|
|
648
|
+
|
|
649
|
+
; Write access: ClassName::$field = value (static property)
|
|
650
|
+
(assignment_expression
|
|
651
|
+
left: (scoped_property_access_expression
|
|
652
|
+
scope: (_) @assignment.receiver
|
|
653
|
+
name: (variable_name (name) @assignment.property))
|
|
654
|
+
right: (_)) @assignment
|
|
655
|
+
`;
|
|
656
|
+
// Ruby queries - works with tree-sitter-ruby
|
|
657
|
+
// NOTE: Ruby uses `call` for require, include, extend, prepend, attr_* etc.
|
|
658
|
+
// These are all captured as @call and routed in JS post-processing:
|
|
659
|
+
// - require/require_relative → import extraction
|
|
660
|
+
// - include/extend/prepend → heritage (mixin) extraction
|
|
661
|
+
// - attr_accessor/attr_reader/attr_writer → property definition extraction
|
|
662
|
+
// - everything else → regular call extraction
|
|
663
|
+
export const RUBY_QUERIES = `
|
|
664
|
+
; ── Modules ──────────────────────────────────────────────────────────────────
|
|
665
|
+
(module
|
|
666
|
+
name: (constant) @name) @definition.module
|
|
667
|
+
|
|
668
|
+
; ── Classes ──────────────────────────────────────────────────────────────────
|
|
669
|
+
(class
|
|
670
|
+
name: (constant) @name) @definition.class
|
|
671
|
+
|
|
672
|
+
; ── Instance methods ─────────────────────────────────────────────────────────
|
|
673
|
+
(method
|
|
674
|
+
name: (identifier) @name) @definition.method
|
|
675
|
+
|
|
676
|
+
; ── Singleton (class-level) methods ──────────────────────────────────────────
|
|
677
|
+
(singleton_method
|
|
678
|
+
name: (identifier) @name) @definition.method
|
|
679
|
+
|
|
680
|
+
; ── All calls (require, include, attr_*, and regular calls routed in JS) ─────
|
|
681
|
+
(call
|
|
682
|
+
method: (identifier) @call.name) @call
|
|
683
|
+
|
|
684
|
+
; ── Bare calls without parens (identifiers at statement level are method calls) ─
|
|
685
|
+
; NOTE: This may over-capture variable reads as calls (e.g. 'result' at
|
|
686
|
+
; statement level). Ruby's grammar makes bare identifiers ambiguous — they
|
|
687
|
+
; could be local variables or zero-arity method calls. Post-processing via
|
|
688
|
+
; isBuiltInOrNoise and symbol resolution filtering suppresses most false
|
|
689
|
+
; positives, but a variable name that coincidentally matches a method name
|
|
690
|
+
; elsewhere may produce a false CALLS edge.
|
|
691
|
+
(body_statement
|
|
692
|
+
(identifier) @call.name @call)
|
|
693
|
+
|
|
694
|
+
; ── Heritage: class < SuperClass ─────────────────────────────────────────────
|
|
695
|
+
(class
|
|
696
|
+
name: (constant) @heritage.class
|
|
697
|
+
superclass: (superclass
|
|
698
|
+
(constant) @heritage.extends)) @heritage
|
|
699
|
+
|
|
700
|
+
; Write access: obj.field = value (Ruby setter — syntactically a method call to field=)
|
|
701
|
+
(assignment
|
|
702
|
+
left: (call
|
|
703
|
+
receiver: (_) @assignment.receiver
|
|
704
|
+
method: (identifier) @assignment.property)
|
|
705
|
+
right: (_)) @assignment
|
|
706
|
+
|
|
707
|
+
; Write access: obj.field += value (compound assignment — operator_assignment node, not assignment)
|
|
708
|
+
(operator_assignment
|
|
709
|
+
left: (call
|
|
710
|
+
receiver: (_) @assignment.receiver
|
|
711
|
+
method: (identifier) @assignment.property)
|
|
712
|
+
right: (_)) @assignment
|
|
713
|
+
`;
|
|
714
|
+
// Kotlin queries - works with tree-sitter-kotlin (fwcd/tree-sitter-kotlin)
|
|
715
|
+
// Based on official tags.scm; functions use simple_identifier, classes use type_identifier
|
|
716
|
+
export const KOTLIN_QUERIES = `
|
|
717
|
+
; ── Interfaces ─────────────────────────────────────────────────────────────
|
|
718
|
+
; tree-sitter-kotlin (fwcd) has no interface_declaration node type.
|
|
719
|
+
; Interfaces are class_declaration nodes with an anonymous "interface" keyword child.
|
|
720
|
+
(class_declaration
|
|
721
|
+
"interface"
|
|
722
|
+
(type_identifier) @name) @definition.interface
|
|
723
|
+
|
|
724
|
+
; ── Classes (regular, data, sealed, enum) ────────────────────────────────
|
|
725
|
+
; All have the anonymous "class" keyword child. enum class has both
|
|
726
|
+
; "enum" and "class" children — the "class" child still matches.
|
|
727
|
+
(class_declaration
|
|
728
|
+
"class"
|
|
729
|
+
(type_identifier) @name) @definition.class
|
|
730
|
+
|
|
731
|
+
; ── Object declarations (Kotlin singletons) ──────────────────────────────
|
|
732
|
+
(object_declaration
|
|
733
|
+
(type_identifier) @name) @definition.class
|
|
734
|
+
|
|
735
|
+
; ── Companion objects (named only) ───────────────────────────────────────
|
|
736
|
+
(companion_object
|
|
737
|
+
(type_identifier) @name) @definition.class
|
|
738
|
+
|
|
739
|
+
; ── Functions (top-level, member, extension) ──────────────────────────────
|
|
740
|
+
(function_declaration
|
|
741
|
+
(simple_identifier) @name) @definition.function
|
|
742
|
+
|
|
743
|
+
; ── Properties ───────────────────────────────────────────────────────────
|
|
744
|
+
(property_declaration
|
|
745
|
+
(variable_declaration
|
|
746
|
+
(simple_identifier) @name)) @definition.property
|
|
747
|
+
|
|
748
|
+
; Primary constructor val/var parameters (data class, value class, regular class)
|
|
749
|
+
; binding_pattern_kind contains "val" or "var" — without it, the param is not a property
|
|
750
|
+
(class_parameter
|
|
751
|
+
(binding_pattern_kind)
|
|
752
|
+
(simple_identifier) @name) @definition.property
|
|
753
|
+
|
|
754
|
+
; ── Enum entries ─────────────────────────────────────────────────────────
|
|
755
|
+
(enum_entry
|
|
756
|
+
(simple_identifier) @name) @definition.enum
|
|
757
|
+
|
|
758
|
+
; ── Type aliases ─────────────────────────────────────────────────────────
|
|
759
|
+
(type_alias
|
|
760
|
+
(type_identifier) @name) @definition.type
|
|
761
|
+
|
|
762
|
+
; ── Imports ──────────────────────────────────────────────────────────────
|
|
763
|
+
(import_header
|
|
764
|
+
(identifier) @import.source) @import
|
|
765
|
+
|
|
766
|
+
; ── Function calls (direct) ──────────────────────────────────────────────
|
|
767
|
+
(call_expression
|
|
768
|
+
(simple_identifier) @call.name) @call
|
|
769
|
+
|
|
770
|
+
; ── Method calls (via navigation: obj.method()) ──────────────────────────
|
|
771
|
+
(call_expression
|
|
772
|
+
(navigation_expression
|
|
773
|
+
(navigation_suffix
|
|
774
|
+
(simple_identifier) @call.name))) @call
|
|
775
|
+
|
|
776
|
+
; ── Constructor invocations ──────────────────────────────────────────────
|
|
777
|
+
(constructor_invocation
|
|
778
|
+
(user_type
|
|
779
|
+
(type_identifier) @call.name)) @call
|
|
780
|
+
|
|
781
|
+
; ── Infix function calls (e.g., a to b, x until y) ──────────────────────
|
|
782
|
+
(infix_expression
|
|
783
|
+
(simple_identifier) @call.name) @call
|
|
784
|
+
|
|
785
|
+
; ── Heritage: extends / implements via delegation_specifier ──────────────
|
|
786
|
+
; Interface implementation (bare user_type): class Foo : Bar
|
|
787
|
+
(class_declaration
|
|
788
|
+
(type_identifier) @heritage.class
|
|
789
|
+
(delegation_specifier
|
|
790
|
+
(user_type (type_identifier) @heritage.extends))) @heritage
|
|
791
|
+
|
|
792
|
+
; Class extension (constructor_invocation): class Foo : Bar()
|
|
793
|
+
(class_declaration
|
|
794
|
+
(type_identifier) @heritage.class
|
|
795
|
+
(delegation_specifier
|
|
796
|
+
(constructor_invocation
|
|
797
|
+
(user_type (type_identifier) @heritage.extends)))) @heritage
|
|
798
|
+
|
|
799
|
+
; Write access: obj.field = value
|
|
800
|
+
(assignment
|
|
801
|
+
(directly_assignable_expression
|
|
802
|
+
(_) @assignment.receiver
|
|
803
|
+
(navigation_suffix
|
|
804
|
+
(simple_identifier) @assignment.property))
|
|
805
|
+
(_)) @assignment
|
|
806
|
+
|
|
807
|
+
`;
|
|
808
|
+
// Swift queries - works with tree-sitter-swift
|
|
809
|
+
export const SWIFT_QUERIES = `
|
|
810
|
+
; Classes
|
|
811
|
+
(class_declaration "class" name: (type_identifier) @name) @definition.class
|
|
812
|
+
|
|
813
|
+
; Structs
|
|
814
|
+
(class_declaration "struct" name: (type_identifier) @name) @definition.struct
|
|
815
|
+
|
|
816
|
+
; Enums
|
|
817
|
+
(class_declaration "enum" name: (type_identifier) @name) @definition.enum
|
|
818
|
+
|
|
819
|
+
; Extensions (mapped to class — no dedicated label in schema)
|
|
820
|
+
(class_declaration "extension" name: (user_type (type_identifier) @name)) @definition.class
|
|
821
|
+
|
|
822
|
+
; Actors
|
|
823
|
+
(class_declaration "actor" name: (type_identifier) @name) @definition.class
|
|
824
|
+
|
|
825
|
+
; Protocols (mapped to interface)
|
|
826
|
+
(protocol_declaration name: (type_identifier) @name) @definition.interface
|
|
827
|
+
|
|
828
|
+
; Type aliases
|
|
829
|
+
(typealias_declaration name: (type_identifier) @name) @definition.type
|
|
830
|
+
|
|
831
|
+
; Functions (top-level and methods)
|
|
832
|
+
(function_declaration name: (simple_identifier) @name) @definition.function
|
|
833
|
+
|
|
834
|
+
; Protocol method declarations
|
|
835
|
+
(protocol_function_declaration name: (simple_identifier) @name) @definition.method
|
|
836
|
+
|
|
837
|
+
; Initializers
|
|
838
|
+
(init_declaration) @definition.constructor
|
|
839
|
+
|
|
840
|
+
; Properties (stored and computed)
|
|
841
|
+
(property_declaration (pattern (simple_identifier) @name)) @definition.property
|
|
842
|
+
|
|
843
|
+
; Imports
|
|
844
|
+
(import_declaration (identifier (simple_identifier) @import.source)) @import
|
|
845
|
+
|
|
846
|
+
; Calls - direct function calls
|
|
847
|
+
(call_expression (simple_identifier) @call.name) @call
|
|
848
|
+
|
|
849
|
+
; Calls - member/navigation calls (obj.method())
|
|
850
|
+
(call_expression (navigation_expression (navigation_suffix (simple_identifier) @call.name))) @call
|
|
851
|
+
|
|
852
|
+
; Heritage - class/struct/enum inheritance and protocol conformance
|
|
853
|
+
(class_declaration name: (type_identifier) @heritage.class
|
|
854
|
+
(inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
|
|
855
|
+
|
|
856
|
+
; Heritage - protocol inheritance
|
|
857
|
+
(protocol_declaration name: (type_identifier) @heritage.class
|
|
858
|
+
(inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
|
|
859
|
+
|
|
860
|
+
; Heritage - extension protocol conformance (e.g. extension Foo: SomeProtocol)
|
|
861
|
+
; Extensions wrap the name in user_type unlike class/struct/enum declarations
|
|
862
|
+
(class_declaration "extension" name: (user_type (type_identifier) @heritage.class)
|
|
863
|
+
(inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
|
|
864
|
+
|
|
865
|
+
; Write access: obj.field = value
|
|
866
|
+
(assignment
|
|
867
|
+
(directly_assignable_expression
|
|
868
|
+
(_) @assignment.receiver
|
|
869
|
+
(navigation_suffix
|
|
870
|
+
(simple_identifier) @assignment.property))
|
|
871
|
+
(_)) @assignment
|
|
872
|
+
|
|
873
|
+
`;
|
|
874
|
+
export const LANGUAGE_QUERIES = {
|
|
875
|
+
[SupportedLanguages.TypeScript]: TYPESCRIPT_QUERIES,
|
|
876
|
+
[SupportedLanguages.JavaScript]: JAVASCRIPT_QUERIES,
|
|
877
|
+
[SupportedLanguages.Python]: PYTHON_QUERIES,
|
|
878
|
+
[SupportedLanguages.Java]: JAVA_QUERIES,
|
|
879
|
+
[SupportedLanguages.C]: C_QUERIES,
|
|
880
|
+
[SupportedLanguages.Go]: GO_QUERIES,
|
|
881
|
+
[SupportedLanguages.CPlusPlus]: CPP_QUERIES,
|
|
882
|
+
[SupportedLanguages.CSharp]: CSHARP_QUERIES,
|
|
883
|
+
[SupportedLanguages.Ruby]: RUBY_QUERIES,
|
|
884
|
+
[SupportedLanguages.Rust]: RUST_QUERIES,
|
|
885
|
+
[SupportedLanguages.PHP]: PHP_QUERIES,
|
|
886
|
+
[SupportedLanguages.Kotlin]: KOTLIN_QUERIES,
|
|
887
|
+
[SupportedLanguages.Swift]: SWIFT_QUERIES,
|
|
888
|
+
};
|