gitnexus 1.4.7 → 1.4.9
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/README.md +29 -1
- package/dist/cli/ai-context.d.ts +1 -1
- package/dist/cli/ai-context.js +1 -1
- package/dist/cli/analyze.d.ts +2 -0
- package/dist/cli/analyze.js +54 -21
- package/dist/cli/index-repo.d.ts +15 -0
- package/dist/cli/index-repo.js +115 -0
- package/dist/cli/index.js +13 -3
- package/dist/cli/setup.js +90 -10
- package/dist/cli/wiki.d.ts +4 -0
- package/dist/cli/wiki.js +174 -53
- package/dist/config/supported-languages.d.ts +33 -1
- package/dist/config/supported-languages.js +32 -0
- package/dist/core/embeddings/embedder.d.ts +6 -1
- package/dist/core/embeddings/embedder.js +65 -5
- package/dist/core/embeddings/embedding-pipeline.js +11 -9
- package/dist/core/embeddings/http-client.d.ts +31 -0
- package/dist/core/embeddings/http-client.js +179 -0
- package/dist/core/embeddings/index.d.ts +1 -0
- package/dist/core/embeddings/index.js +1 -0
- package/dist/core/embeddings/types.d.ts +1 -1
- package/dist/core/graph/graph.js +9 -1
- package/dist/core/graph/types.d.ts +11 -2
- package/dist/core/ingestion/call-processor.d.ts +66 -2
- package/dist/core/ingestion/call-processor.js +650 -30
- package/dist/core/ingestion/call-routing.d.ts +9 -18
- package/dist/core/ingestion/call-routing.js +0 -19
- package/dist/core/ingestion/cobol/cobol-copy-expander.d.ts +57 -0
- package/dist/core/ingestion/cobol/cobol-copy-expander.js +385 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.d.ts +210 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.js +1509 -0
- package/dist/core/ingestion/cobol/jcl-parser.d.ts +68 -0
- package/dist/core/ingestion/cobol/jcl-parser.js +217 -0
- package/dist/core/ingestion/cobol/jcl-processor.d.ts +33 -0
- package/dist/core/ingestion/cobol/jcl-processor.js +229 -0
- package/dist/core/ingestion/cobol-processor.d.ts +54 -0
- package/dist/core/ingestion/cobol-processor.js +1186 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +17 -0
- package/dist/core/ingestion/entry-point-scoring.js +52 -28
- package/dist/core/ingestion/export-detection.d.ts +47 -8
- package/dist/core/ingestion/export-detection.js +29 -50
- package/dist/core/ingestion/field-extractor.d.ts +29 -0
- package/dist/core/ingestion/field-extractor.js +25 -0
- package/dist/core/ingestion/field-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/c-cpp.js +108 -0
- package/dist/core/ingestion/field-extractors/configs/csharp.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/csharp.js +73 -0
- package/dist/core/ingestion/field-extractors/configs/dart.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/dart.js +76 -0
- package/dist/core/ingestion/field-extractors/configs/go.d.ts +11 -0
- package/dist/core/ingestion/field-extractors/configs/go.js +64 -0
- package/dist/core/ingestion/field-extractors/configs/helpers.d.ts +44 -0
- package/dist/core/ingestion/field-extractors/configs/helpers.js +134 -0
- package/dist/core/ingestion/field-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/jvm.js +118 -0
- package/dist/core/ingestion/field-extractors/configs/php.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/php.js +67 -0
- package/dist/core/ingestion/field-extractors/configs/python.d.ts +12 -0
- package/dist/core/ingestion/field-extractors/configs/python.js +91 -0
- package/dist/core/ingestion/field-extractors/configs/ruby.d.ts +16 -0
- package/dist/core/ingestion/field-extractors/configs/ruby.js +75 -0
- package/dist/core/ingestion/field-extractors/configs/rust.d.ts +9 -0
- package/dist/core/ingestion/field-extractors/configs/rust.js +55 -0
- package/dist/core/ingestion/field-extractors/configs/swift.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/swift.js +63 -0
- package/dist/core/ingestion/field-extractors/configs/typescript-javascript.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/typescript-javascript.js +60 -0
- package/dist/core/ingestion/field-extractors/generic.d.ts +46 -0
- package/dist/core/ingestion/field-extractors/generic.js +111 -0
- package/dist/core/ingestion/field-extractors/typescript.d.ts +77 -0
- package/dist/core/ingestion/field-extractors/typescript.js +291 -0
- package/dist/core/ingestion/field-types.d.ts +59 -0
- package/dist/core/ingestion/field-types.js +2 -0
- package/dist/core/ingestion/framework-detection.d.ts +97 -2
- package/dist/core/ingestion/framework-detection.js +114 -14
- package/dist/core/ingestion/heritage-processor.js +62 -66
- package/dist/core/ingestion/import-processor.d.ts +9 -10
- package/dist/core/ingestion/import-processor.js +150 -196
- package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.d.ts +6 -9
- package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.js +20 -2
- package/dist/core/ingestion/import-resolvers/dart.d.ts +7 -0
- package/dist/core/ingestion/import-resolvers/dart.js +44 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/go.d.ts +4 -5
- package/dist/core/ingestion/{resolvers → import-resolvers}/go.js +17 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/jvm.d.ts +10 -1
- package/dist/core/ingestion/import-resolvers/jvm.js +159 -0
- package/dist/core/ingestion/import-resolvers/php.d.ts +25 -0
- package/dist/core/ingestion/import-resolvers/php.js +80 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/python.d.ts +9 -3
- package/dist/core/ingestion/{resolvers → import-resolvers}/python.js +35 -3
- package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.d.ts +5 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.js +7 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/rust.d.ts +5 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/rust.js +41 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/standard.d.ts +15 -7
- package/dist/core/ingestion/{resolvers → import-resolvers}/standard.js +22 -3
- package/dist/core/ingestion/import-resolvers/swift.d.ts +7 -0
- package/dist/core/ingestion/import-resolvers/swift.js +23 -0
- package/dist/core/ingestion/import-resolvers/types.d.ts +44 -0
- package/dist/core/ingestion/import-resolvers/types.js +6 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/utils.d.ts +2 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/utils.js +7 -0
- package/dist/core/ingestion/language-config.d.ts +6 -0
- package/dist/core/ingestion/language-config.js +13 -0
- package/dist/core/ingestion/language-provider.d.ts +121 -0
- package/dist/core/ingestion/language-provider.js +24 -0
- package/dist/core/ingestion/languages/c-cpp.d.ts +12 -0
- package/dist/core/ingestion/languages/c-cpp.js +71 -0
- package/dist/core/ingestion/languages/cobol.d.ts +1 -0
- package/dist/core/ingestion/languages/cobol.js +26 -0
- package/dist/core/ingestion/languages/csharp.d.ts +8 -0
- package/dist/core/ingestion/languages/csharp.js +49 -0
- package/dist/core/ingestion/languages/dart.d.ts +12 -0
- package/dist/core/ingestion/languages/dart.js +58 -0
- package/dist/core/ingestion/languages/go.d.ts +11 -0
- package/dist/core/ingestion/languages/go.js +28 -0
- package/dist/core/ingestion/languages/index.d.ts +38 -0
- package/dist/core/ingestion/languages/index.js +63 -0
- package/dist/core/ingestion/languages/java.d.ts +9 -0
- package/dist/core/ingestion/languages/java.js +29 -0
- package/dist/core/ingestion/languages/kotlin.d.ts +9 -0
- package/dist/core/ingestion/languages/kotlin.js +53 -0
- package/dist/core/ingestion/languages/php.d.ts +8 -0
- package/dist/core/ingestion/languages/php.js +145 -0
- package/dist/core/ingestion/languages/python.d.ts +12 -0
- package/dist/core/ingestion/languages/python.js +39 -0
- package/dist/core/ingestion/languages/ruby.d.ts +9 -0
- package/dist/core/ingestion/languages/ruby.js +44 -0
- package/dist/core/ingestion/languages/rust.d.ts +12 -0
- package/dist/core/ingestion/languages/rust.js +44 -0
- package/dist/core/ingestion/languages/swift.d.ts +12 -0
- package/dist/core/ingestion/languages/swift.js +133 -0
- package/dist/core/ingestion/languages/typescript.d.ts +10 -0
- package/dist/core/ingestion/languages/typescript.js +60 -0
- package/dist/core/ingestion/markdown-processor.d.ts +17 -0
- package/dist/core/ingestion/markdown-processor.js +124 -0
- package/dist/core/ingestion/mro-processor.js +22 -18
- package/dist/core/ingestion/named-binding-processor.d.ts +18 -0
- package/dist/core/ingestion/named-binding-processor.js +42 -0
- package/dist/core/ingestion/named-bindings/csharp.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/csharp.js +37 -0
- package/dist/core/ingestion/named-bindings/java.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/java.js +29 -0
- package/dist/core/ingestion/named-bindings/kotlin.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/kotlin.js +36 -0
- package/dist/core/ingestion/named-bindings/php.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/php.js +61 -0
- package/dist/core/ingestion/named-bindings/python.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/python.js +49 -0
- package/dist/core/ingestion/named-bindings/rust.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/rust.js +64 -0
- package/dist/core/ingestion/named-bindings/types.d.ts +16 -0
- package/dist/core/ingestion/named-bindings/types.js +6 -0
- package/dist/core/ingestion/named-bindings/typescript.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/typescript.js +58 -0
- package/dist/core/ingestion/parsing-processor.d.ts +6 -2
- package/dist/core/ingestion/parsing-processor.js +125 -85
- package/dist/core/ingestion/pipeline.d.ts +10 -0
- package/dist/core/ingestion/pipeline.js +1235 -317
- package/dist/core/ingestion/resolution-context.d.ts +5 -0
- package/dist/core/ingestion/resolution-context.js +8 -5
- package/dist/core/ingestion/route-extractors/expo.d.ts +1 -0
- package/dist/core/ingestion/route-extractors/expo.js +36 -0
- package/dist/core/ingestion/route-extractors/middleware.d.ts +47 -0
- package/dist/core/ingestion/route-extractors/middleware.js +143 -0
- package/dist/core/ingestion/route-extractors/nextjs.d.ts +3 -0
- package/dist/core/ingestion/route-extractors/nextjs.js +76 -0
- package/dist/core/ingestion/route-extractors/php.d.ts +7 -0
- package/dist/core/ingestion/route-extractors/php.js +21 -0
- package/dist/core/ingestion/route-extractors/response-shapes.d.ts +20 -0
- package/dist/core/ingestion/route-extractors/response-shapes.js +290 -0
- package/dist/core/ingestion/symbol-table.d.ts +16 -0
- package/dist/core/ingestion/symbol-table.js +20 -6
- package/dist/core/ingestion/tree-sitter-queries.d.ts +10 -9
- package/dist/core/ingestion/tree-sitter-queries.js +274 -11
- package/dist/core/ingestion/type-env.d.ts +42 -18
- package/dist/core/ingestion/type-env.js +481 -106
- package/dist/core/ingestion/type-extractors/c-cpp.d.ts +5 -0
- package/dist/core/ingestion/type-extractors/c-cpp.js +119 -0
- package/dist/core/ingestion/type-extractors/csharp.js +149 -16
- package/dist/core/ingestion/type-extractors/dart.d.ts +15 -0
- package/dist/core/ingestion/type-extractors/dart.js +371 -0
- package/dist/core/ingestion/type-extractors/jvm.js +169 -66
- package/dist/core/ingestion/type-extractors/rust.js +35 -1
- package/dist/core/ingestion/type-extractors/shared.d.ts +1 -15
- package/dist/core/ingestion/type-extractors/shared.js +14 -112
- package/dist/core/ingestion/type-extractors/swift.js +338 -7
- package/dist/core/ingestion/type-extractors/types.d.ts +40 -8
- package/dist/core/ingestion/type-extractors/typescript.js +141 -9
- package/dist/core/ingestion/utils/ast-helpers.d.ts +83 -0
- package/dist/core/ingestion/utils/ast-helpers.js +817 -0
- package/dist/core/ingestion/utils/call-analysis.d.ts +73 -0
- package/dist/core/ingestion/utils/call-analysis.js +527 -0
- package/dist/core/ingestion/utils/event-loop.d.ts +5 -0
- package/dist/core/ingestion/utils/event-loop.js +5 -0
- package/dist/core/ingestion/utils/language-detection.d.ts +9 -0
- package/dist/core/ingestion/utils/language-detection.js +70 -0
- package/dist/core/ingestion/utils/verbose.d.ts +1 -0
- package/dist/core/ingestion/utils/verbose.js +7 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +55 -5
- package/dist/core/ingestion/workers/parse-worker.js +415 -225
- package/dist/core/lbug/csv-generator.js +51 -1
- package/dist/core/lbug/lbug-adapter.d.ts +10 -0
- package/dist/core/lbug/lbug-adapter.js +75 -4
- package/dist/core/lbug/schema.d.ts +8 -4
- package/dist/core/lbug/schema.js +65 -4
- package/dist/core/tree-sitter/parser-loader.js +7 -1
- package/dist/core/wiki/cursor-client.d.ts +31 -0
- package/dist/core/wiki/cursor-client.js +127 -0
- package/dist/core/wiki/generator.d.ts +28 -9
- package/dist/core/wiki/generator.js +115 -18
- package/dist/core/wiki/graph-queries.d.ts +4 -0
- package/dist/core/wiki/graph-queries.js +7 -1
- package/dist/core/wiki/llm-client.d.ts +2 -0
- package/dist/core/wiki/llm-client.js +8 -4
- package/dist/core/wiki/prompts.d.ts +3 -3
- package/dist/core/wiki/prompts.js +6 -0
- package/dist/mcp/core/embedder.js +11 -3
- package/dist/mcp/core/lbug-adapter.d.ts +5 -0
- package/dist/mcp/core/lbug-adapter.js +23 -2
- package/dist/mcp/local/local-backend.d.ts +38 -5
- package/dist/mcp/local/local-backend.js +804 -63
- package/dist/mcp/resources.js +2 -0
- package/dist/mcp/tools.js +73 -4
- package/dist/server/api.d.ts +19 -1
- package/dist/server/api.js +66 -6
- package/dist/storage/git.d.ts +12 -0
- package/dist/storage/git.js +21 -0
- package/dist/storage/repo-manager.d.ts +3 -0
- package/package.json +25 -16
- package/dist/core/ingestion/named-binding-extraction.d.ts +0 -61
- package/dist/core/ingestion/named-binding-extraction.js +0 -363
- package/dist/core/ingestion/resolvers/index.d.ts +0 -18
- package/dist/core/ingestion/resolvers/index.js +0 -13
- package/dist/core/ingestion/resolvers/jvm.js +0 -87
- package/dist/core/ingestion/resolvers/php.d.ts +0 -15
- package/dist/core/ingestion/resolvers/php.js +0 -35
- package/dist/core/ingestion/type-extractors/index.d.ts +0 -22
- package/dist/core/ingestion/type-extractors/index.js +0 -31
- package/dist/core/ingestion/utils.d.ts +0 -138
- package/dist/core/ingestion/utils.js +0 -1290
- package/scripts/patch-tree-sitter-swift.cjs +0 -74
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SupportedLanguages } from '../../config/supported-languages.js';
|
|
2
1
|
/*
|
|
3
2
|
* Tree-sitter queries for extracting code definitions.
|
|
4
3
|
*
|
|
@@ -17,6 +16,10 @@ export const TYPESCRIPT_QUERIES = `
|
|
|
17
16
|
(function_declaration
|
|
18
17
|
name: (identifier) @name) @definition.function
|
|
19
18
|
|
|
19
|
+
; TypeScript overload signatures (function_signature is a separate node type from function_declaration)
|
|
20
|
+
(function_signature
|
|
21
|
+
name: (identifier) @name) @definition.function
|
|
22
|
+
|
|
20
23
|
(method_definition
|
|
21
24
|
name: (property_identifier) @name) @definition.method
|
|
22
25
|
|
|
@@ -100,6 +103,34 @@ export const TYPESCRIPT_QUERIES = `
|
|
|
100
103
|
object: (_) @assignment.receiver
|
|
101
104
|
property: (property_identifier) @assignment.property)
|
|
102
105
|
right: (_)) @assignment
|
|
106
|
+
|
|
107
|
+
; HTTP consumers: fetch('/path'), axios.get('/path'), $.get('/path'), etc.
|
|
108
|
+
; fetch() — global function
|
|
109
|
+
(call_expression
|
|
110
|
+
function: (identifier) @_fetch_fn (#eq? @_fetch_fn "fetch")
|
|
111
|
+
arguments: (arguments
|
|
112
|
+
[(string (string_fragment) @route.url)
|
|
113
|
+
(template_string) @route.template_url])) @route.fetch
|
|
114
|
+
|
|
115
|
+
; axios.get/post/put/delete/patch('/path'), $.get/post/ajax({url:'/path'})
|
|
116
|
+
(call_expression
|
|
117
|
+
function: (member_expression
|
|
118
|
+
property: (property_identifier) @http_client.method)
|
|
119
|
+
arguments: (arguments
|
|
120
|
+
(string (string_fragment) @http_client.url))) @http_client
|
|
121
|
+
|
|
122
|
+
; Decorators: @Controller, @Get, @Post, etc.
|
|
123
|
+
(decorator
|
|
124
|
+
(call_expression
|
|
125
|
+
function: (identifier) @decorator.name
|
|
126
|
+
arguments: (arguments (string (string_fragment) @decorator.arg)?))) @decorator
|
|
127
|
+
|
|
128
|
+
; Express/Hono route registration: app.get('/path', handler), router.post('/path', fn)
|
|
129
|
+
(call_expression
|
|
130
|
+
function: (member_expression
|
|
131
|
+
property: (property_identifier) @express_route.method)
|
|
132
|
+
arguments: (arguments
|
|
133
|
+
(string (string_fragment) @express_route.path))) @express_route
|
|
103
134
|
`;
|
|
104
135
|
// JavaScript queries - works with tree-sitter-javascript
|
|
105
136
|
export const JAVASCRIPT_QUERIES = `
|
|
@@ -176,6 +207,27 @@ export const JAVASCRIPT_QUERIES = `
|
|
|
176
207
|
object: (_) @assignment.receiver
|
|
177
208
|
property: (property_identifier) @assignment.property)
|
|
178
209
|
right: (_)) @assignment
|
|
210
|
+
|
|
211
|
+
; HTTP consumers: fetch('/path'), axios.get('/path'), $.get('/path'), etc.
|
|
212
|
+
(call_expression
|
|
213
|
+
function: (identifier) @_fetch_fn (#eq? @_fetch_fn "fetch")
|
|
214
|
+
arguments: (arguments
|
|
215
|
+
[(string (string_fragment) @route.url)
|
|
216
|
+
(template_string) @route.template_url])) @route.fetch
|
|
217
|
+
|
|
218
|
+
; axios.get/post, $.get/post/ajax
|
|
219
|
+
(call_expression
|
|
220
|
+
function: (member_expression
|
|
221
|
+
property: (property_identifier) @http_client.method)
|
|
222
|
+
arguments: (arguments
|
|
223
|
+
(string (string_fragment) @http_client.url))) @http_client
|
|
224
|
+
|
|
225
|
+
; Express/Hono route registration
|
|
226
|
+
(call_expression
|
|
227
|
+
function: (member_expression
|
|
228
|
+
property: (property_identifier) @express_route.method)
|
|
229
|
+
arguments: (arguments
|
|
230
|
+
(string (string_fragment) @express_route.path))) @express_route
|
|
179
231
|
`;
|
|
180
232
|
// Python queries - works with tree-sitter-python
|
|
181
233
|
export const PYTHON_QUERIES = `
|
|
@@ -188,6 +240,12 @@ export const PYTHON_QUERIES = `
|
|
|
188
240
|
(import_statement
|
|
189
241
|
name: (dotted_name) @import.source) @import
|
|
190
242
|
|
|
243
|
+
; import numpy as np → aliased_import captures the module name so the
|
|
244
|
+
; import path is resolved and named-binding extraction stores "np" → "numpy".
|
|
245
|
+
(import_statement
|
|
246
|
+
name: (aliased_import
|
|
247
|
+
name: (dotted_name) @import.source)) @import
|
|
248
|
+
|
|
191
249
|
(import_from_statement
|
|
192
250
|
module_name: (dotted_name) @import.source) @import
|
|
193
251
|
|
|
@@ -228,6 +286,22 @@ export const PYTHON_QUERIES = `
|
|
|
228
286
|
object: (_) @assignment.receiver
|
|
229
287
|
attribute: (identifier) @assignment.property)
|
|
230
288
|
right: (_)) @assignment
|
|
289
|
+
|
|
290
|
+
; Python HTTP clients: requests.get('/path'), httpx.post('/path'), session.get('/path')
|
|
291
|
+
(call
|
|
292
|
+
function: (attribute
|
|
293
|
+
attribute: (identifier) @http_client.method)
|
|
294
|
+
arguments: (argument_list
|
|
295
|
+
(string (string_content) @http_client.url))) @http_client
|
|
296
|
+
|
|
297
|
+
; Python decorators: @app.route, @router.get, etc.
|
|
298
|
+
(decorator
|
|
299
|
+
(call
|
|
300
|
+
function: (attribute
|
|
301
|
+
object: (identifier) @decorator.receiver
|
|
302
|
+
attribute: (identifier) @decorator.name)
|
|
303
|
+
arguments: (argument_list
|
|
304
|
+
(string (string_content) @decorator.arg)?))) @decorator
|
|
231
305
|
`;
|
|
232
306
|
// Java queries - works with tree-sitter-java
|
|
233
307
|
export const JAVA_QUERIES = `
|
|
@@ -343,6 +417,16 @@ export const GO_QUERIES = `
|
|
|
343
417
|
operand: (_) @assignment.receiver
|
|
344
418
|
field: (field_identifier) @assignment.property))
|
|
345
419
|
right: (_)) @assignment
|
|
420
|
+
|
|
421
|
+
; Write access: obj.field++ / obj.field--
|
|
422
|
+
(inc_statement
|
|
423
|
+
(selector_expression
|
|
424
|
+
operand: (_) @assignment.receiver
|
|
425
|
+
field: (field_identifier) @assignment.property)) @assignment
|
|
426
|
+
(dec_statement
|
|
427
|
+
(selector_expression
|
|
428
|
+
operand: (_) @assignment.receiver
|
|
429
|
+
field: (field_identifier) @assignment.property)) @assignment
|
|
346
430
|
`;
|
|
347
431
|
// C++ queries - works with tree-sitter-cpp
|
|
348
432
|
export const CPP_QUERIES = `
|
|
@@ -398,8 +482,15 @@ export const CPP_QUERIES = `
|
|
|
398
482
|
declarator: (reference_declarator
|
|
399
483
|
(field_identifier) @name)) @definition.property
|
|
400
484
|
|
|
401
|
-
; Inline class method declarations (inside class body, no body: void
|
|
402
|
-
|
|
485
|
+
; Inline class method declarations (inside class body, no body: void save();)
|
|
486
|
+
; tree-sitter-cpp uses field_identifier (not identifier) for names inside class bodies
|
|
487
|
+
(field_declaration declarator: (function_declarator declarator: [(field_identifier) (identifier)] @name)) @definition.method
|
|
488
|
+
|
|
489
|
+
; Inline class method declarations returning a pointer (User* lookup();)
|
|
490
|
+
(field_declaration declarator: (pointer_declarator declarator: (function_declarator declarator: [(field_identifier) (identifier)] @name))) @definition.method
|
|
491
|
+
|
|
492
|
+
; Inline class method declarations returning a reference (User& lookup();)
|
|
493
|
+
(field_declaration declarator: (reference_declarator (function_declarator declarator: [(field_identifier) (identifier)] @name))) @definition.method
|
|
403
494
|
|
|
404
495
|
; Inline class method definitions (inside class body, with body: void Foo() { ... })
|
|
405
496
|
(field_declaration_list
|
|
@@ -407,6 +498,20 @@ export const CPP_QUERIES = `
|
|
|
407
498
|
declarator: (function_declarator
|
|
408
499
|
declarator: [(field_identifier) (identifier) (operator_name) (destructor_name)] @name)) @definition.method)
|
|
409
500
|
|
|
501
|
+
; Inline class methods returning a pointer type (User* lookup(int id) { ... })
|
|
502
|
+
(field_declaration_list
|
|
503
|
+
(function_definition
|
|
504
|
+
declarator: (pointer_declarator
|
|
505
|
+
declarator: (function_declarator
|
|
506
|
+
declarator: [(field_identifier) (identifier) (operator_name)] @name))) @definition.method)
|
|
507
|
+
|
|
508
|
+
; Inline class methods returning a reference type (User& lookup(int id) { ... })
|
|
509
|
+
(field_declaration_list
|
|
510
|
+
(function_definition
|
|
511
|
+
declarator: (reference_declarator
|
|
512
|
+
(function_declarator
|
|
513
|
+
declarator: [(field_identifier) (identifier) (operator_name)] @name))) @definition.method)
|
|
514
|
+
|
|
410
515
|
; Templates
|
|
411
516
|
(template_declaration (class_specifier name: (type_identifier) @name)) @definition.template
|
|
412
517
|
(template_declaration (function_definition declarator: (function_declarator declarator: (identifier) @name))) @definition.template
|
|
@@ -639,6 +744,12 @@ export const PHP_QUERIES = `
|
|
|
639
744
|
(use_declaration
|
|
640
745
|
[(name) (qualified_name)] @heritage.trait))) @heritage
|
|
641
746
|
|
|
747
|
+
; PHP HTTP consumers: file_get_contents('/path'), curl_init('/path')
|
|
748
|
+
(function_call_expression
|
|
749
|
+
function: (name) @_php_http (#match? @_php_http "^(file_get_contents|curl_init)$")
|
|
750
|
+
arguments: (arguments
|
|
751
|
+
(argument (string (string_content) @http_client.url)))) @http_client
|
|
752
|
+
|
|
642
753
|
; Write access: $obj->field = value
|
|
643
754
|
(assignment_expression
|
|
644
755
|
left: (member_access_expression
|
|
@@ -685,7 +796,7 @@ export const RUBY_QUERIES = `
|
|
|
685
796
|
; NOTE: This may over-capture variable reads as calls (e.g. 'result' at
|
|
686
797
|
; statement level). Ruby's grammar makes bare identifiers ambiguous — they
|
|
687
798
|
; could be local variables or zero-arity method calls. Post-processing via
|
|
688
|
-
;
|
|
799
|
+
; provider.isBuiltInName and symbol resolution filtering suppresses most false
|
|
689
800
|
; positives, but a variable name that coincidentally matches a method name
|
|
690
801
|
; elsewhere may produce a false CALLS edge.
|
|
691
802
|
(body_statement
|
|
@@ -840,6 +951,9 @@ export const SWIFT_QUERIES = `
|
|
|
840
951
|
; Properties (stored and computed)
|
|
841
952
|
(property_declaration (pattern (simple_identifier) @name)) @definition.property
|
|
842
953
|
|
|
954
|
+
; Enum cases
|
|
955
|
+
(enum_entry (simple_identifier) @name) @definition.property
|
|
956
|
+
|
|
843
957
|
; Imports
|
|
844
958
|
(import_declaration (identifier (simple_identifier) @import.source)) @import
|
|
845
959
|
|
|
@@ -862,15 +976,162 @@ export const SWIFT_QUERIES = `
|
|
|
862
976
|
(class_declaration "extension" name: (user_type (type_identifier) @heritage.class)
|
|
863
977
|
(inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
|
|
864
978
|
|
|
865
|
-
; Write access: obj.field = value
|
|
979
|
+
; Write access: obj.field = value (tree-sitter-swift 0.7.1 uses named fields)
|
|
866
980
|
(assignment
|
|
867
|
-
(directly_assignable_expression
|
|
868
|
-
(
|
|
869
|
-
|
|
870
|
-
(
|
|
871
|
-
|
|
981
|
+
target: (directly_assignable_expression
|
|
982
|
+
(navigation_expression
|
|
983
|
+
target: (_) @assignment.receiver
|
|
984
|
+
suffix: (navigation_suffix
|
|
985
|
+
suffix: (simple_identifier) @assignment.property)))
|
|
986
|
+
result: (_)) @assignment
|
|
987
|
+
|
|
988
|
+
`;
|
|
989
|
+
// Dart queries - works with tree-sitter-dart (UserNobody14/tree-sitter-dart, ABI 14)
|
|
990
|
+
// Note: Dart grammar has function_signature/method_signature as wrappers;
|
|
991
|
+
// top-level functions are (program > function_signature),
|
|
992
|
+
// methods inside classes are (method_signature > function_signature).
|
|
993
|
+
// We match top-level functions via (program (function_signature ...)) to avoid
|
|
994
|
+
// double-counting methods that also contain function_signature.
|
|
995
|
+
export const DART_QUERIES = `
|
|
996
|
+
; ── Classes ──────────────────────────────────────────────────────────────────
|
|
997
|
+
(class_definition
|
|
998
|
+
name: (identifier) @name) @definition.class
|
|
999
|
+
|
|
1000
|
+
; ── Mixins ───────────────────────────────────────────────────────────────────
|
|
1001
|
+
(mixin_declaration
|
|
1002
|
+
(identifier) @name) @definition.trait
|
|
1003
|
+
|
|
1004
|
+
; ── Extensions ───────────────────────────────────────────────────────────────
|
|
1005
|
+
(extension_declaration
|
|
1006
|
+
name: (identifier) @name) @definition.class
|
|
1007
|
+
|
|
1008
|
+
; ── Enums ────────────────────────────────────────────────────────────────────
|
|
1009
|
+
(enum_declaration
|
|
1010
|
+
name: (identifier) @name) @definition.enum
|
|
1011
|
+
|
|
1012
|
+
; ── Type aliases ─────────────────────────────────────────────────────────────
|
|
1013
|
+
; Anchor "=" after the name to avoid capturing the RHS type
|
|
1014
|
+
(type_alias
|
|
1015
|
+
(type_identifier) @name
|
|
1016
|
+
"=") @definition.type
|
|
1017
|
+
|
|
1018
|
+
; ── Top-level functions (parent is program, not method_signature) ────────────
|
|
1019
|
+
(program
|
|
1020
|
+
(function_signature
|
|
1021
|
+
name: (identifier) @name) @definition.function)
|
|
1022
|
+
|
|
1023
|
+
; ── Abstract method declarations (function_signature inside class body declaration) ──
|
|
1024
|
+
(declaration
|
|
1025
|
+
(function_signature
|
|
1026
|
+
name: (identifier) @name)) @definition.method
|
|
1027
|
+
|
|
1028
|
+
; ── Methods (inside class/mixin/extension bodies) ────────────────────────────
|
|
1029
|
+
(method_signature
|
|
1030
|
+
(function_signature
|
|
1031
|
+
name: (identifier) @name)) @definition.method
|
|
1032
|
+
|
|
1033
|
+
; ── Constructors ─────────────────────────────────────────────────────────────
|
|
1034
|
+
(constructor_signature
|
|
1035
|
+
name: (identifier) @name) @definition.constructor
|
|
1036
|
+
|
|
1037
|
+
; ── Factory constructors (anchor before param list to capture variant name, not class) ──
|
|
1038
|
+
(method_signature
|
|
1039
|
+
(factory_constructor_signature
|
|
1040
|
+
(identifier) @name . (formal_parameter_list))) @definition.constructor
|
|
1041
|
+
|
|
1042
|
+
; ── Field declarations (String name = '', Address address = Address()) ──────
|
|
1043
|
+
(declaration
|
|
1044
|
+
(type_identifier)
|
|
1045
|
+
(initialized_identifier_list
|
|
1046
|
+
(initialized_identifier
|
|
1047
|
+
(identifier) @name))) @definition.property
|
|
1048
|
+
|
|
1049
|
+
; ── Nullable field declarations (String? name) ──────────────────────────────
|
|
1050
|
+
(declaration
|
|
1051
|
+
(nullable_type)
|
|
1052
|
+
(initialized_identifier_list
|
|
1053
|
+
(initialized_identifier
|
|
1054
|
+
(identifier) @name))) @definition.property
|
|
1055
|
+
|
|
1056
|
+
; ── Getters ──────────────────────────────────────────────────────────────────
|
|
1057
|
+
(method_signature
|
|
1058
|
+
(getter_signature
|
|
1059
|
+
name: (identifier) @name)) @definition.property
|
|
1060
|
+
|
|
1061
|
+
; ── Setters ──────────────────────────────────────────────────────────────────
|
|
1062
|
+
(method_signature
|
|
1063
|
+
(setter_signature
|
|
1064
|
+
name: (identifier) @name)) @definition.property
|
|
1065
|
+
|
|
1066
|
+
; ── Imports ──────────────────────────────────────────────────────────────────
|
|
1067
|
+
(import_or_export
|
|
1068
|
+
(library_import
|
|
1069
|
+
(import_specification
|
|
1070
|
+
(configurable_uri) @import.source))) @import
|
|
1071
|
+
|
|
1072
|
+
; ── Calls: direct function/constructor calls (identifier immediately before argument_part) ──
|
|
1073
|
+
(expression_statement
|
|
1074
|
+
(identifier) @call.name
|
|
1075
|
+
.
|
|
1076
|
+
(selector (argument_part))) @call
|
|
1077
|
+
|
|
1078
|
+
; ── Calls: method calls (obj.method()) ───────────────────────────────────────
|
|
1079
|
+
(expression_statement
|
|
1080
|
+
(selector
|
|
1081
|
+
(unconditional_assignable_selector
|
|
1082
|
+
(identifier) @call.name))) @call
|
|
1083
|
+
|
|
1084
|
+
; ── Calls: in return statements (return User()) ─────────────────────────────
|
|
1085
|
+
(return_statement
|
|
1086
|
+
(identifier) @call.name
|
|
1087
|
+
(selector (argument_part))) @call
|
|
1088
|
+
|
|
1089
|
+
; ── Calls: in variable assignments (var x = getUser()) ──────────────────────
|
|
1090
|
+
(initialized_variable_definition
|
|
1091
|
+
value: (identifier) @call.name
|
|
1092
|
+
(selector (argument_part))) @call
|
|
872
1093
|
|
|
1094
|
+
; ── Re-exports (export 'foo.dart') ───────────────────────────────────────────
|
|
1095
|
+
(import_or_export
|
|
1096
|
+
(library_export
|
|
1097
|
+
(configurable_uri) @import.source)) @import
|
|
1098
|
+
|
|
1099
|
+
; ── Write access: obj.field = value ──────────────────────────────────────────
|
|
1100
|
+
(assignment_expression
|
|
1101
|
+
left: (assignable_expression
|
|
1102
|
+
(identifier) @assignment.receiver
|
|
1103
|
+
(unconditional_assignable_selector
|
|
1104
|
+
(identifier) @assignment.property))
|
|
1105
|
+
right: (_)) @assignment
|
|
1106
|
+
|
|
1107
|
+
; ── Write access: this.field = value ─────────────────────────────────────────
|
|
1108
|
+
(assignment_expression
|
|
1109
|
+
left: (assignable_expression
|
|
1110
|
+
(this) @assignment.receiver
|
|
1111
|
+
(unconditional_assignable_selector
|
|
1112
|
+
(identifier) @assignment.property))
|
|
1113
|
+
right: (_)) @assignment
|
|
1114
|
+
|
|
1115
|
+
; ── Heritage: extends ────────────────────────────────────────────────────────
|
|
1116
|
+
(class_definition
|
|
1117
|
+
name: (identifier) @heritage.class
|
|
1118
|
+
superclass: (superclass
|
|
1119
|
+
(type_identifier) @heritage.extends)) @heritage
|
|
1120
|
+
|
|
1121
|
+
; ── Heritage: implements ─────────────────────────────────────────────────────
|
|
1122
|
+
(class_definition
|
|
1123
|
+
name: (identifier) @heritage.class
|
|
1124
|
+
interfaces: (interfaces
|
|
1125
|
+
(type_identifier) @heritage.implements)) @heritage.impl
|
|
1126
|
+
|
|
1127
|
+
; ── Heritage: with (mixins) ──────────────────────────────────────────────────
|
|
1128
|
+
(class_definition
|
|
1129
|
+
name: (identifier) @heritage.class
|
|
1130
|
+
superclass: (superclass
|
|
1131
|
+
(mixins
|
|
1132
|
+
(type_identifier) @heritage.trait))) @heritage
|
|
873
1133
|
`;
|
|
1134
|
+
import { SupportedLanguages } from '../../config/supported-languages.js';
|
|
874
1135
|
export const LANGUAGE_QUERIES = {
|
|
875
1136
|
[SupportedLanguages.TypeScript]: TYPESCRIPT_QUERIES,
|
|
876
1137
|
[SupportedLanguages.JavaScript]: JAVASCRIPT_QUERIES,
|
|
@@ -880,9 +1141,11 @@ export const LANGUAGE_QUERIES = {
|
|
|
880
1141
|
[SupportedLanguages.Go]: GO_QUERIES,
|
|
881
1142
|
[SupportedLanguages.CPlusPlus]: CPP_QUERIES,
|
|
882
1143
|
[SupportedLanguages.CSharp]: CSHARP_QUERIES,
|
|
883
|
-
[SupportedLanguages.Ruby]: RUBY_QUERIES,
|
|
884
1144
|
[SupportedLanguages.Rust]: RUST_QUERIES,
|
|
885
1145
|
[SupportedLanguages.PHP]: PHP_QUERIES,
|
|
886
1146
|
[SupportedLanguages.Kotlin]: KOTLIN_QUERIES,
|
|
1147
|
+
[SupportedLanguages.Ruby]: RUBY_QUERIES,
|
|
887
1148
|
[SupportedLanguages.Swift]: SWIFT_QUERIES,
|
|
1149
|
+
[SupportedLanguages.Dart]: DART_QUERIES,
|
|
1150
|
+
[SupportedLanguages.Cobol]: '', // Standalone regex processor — no tree-sitter queries
|
|
888
1151
|
};
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SyntaxNode } from './utils/ast-helpers.js';
|
|
2
2
|
import { SupportedLanguages } from '../../config/supported-languages.js';
|
|
3
3
|
import type { SymbolTable } from './symbol-table.js';
|
|
4
|
-
|
|
5
|
-
* Per-file scoped type environment: maps (scope, variableName) → typeName.
|
|
6
|
-
* Scope-aware: variables inside functions are keyed by function name,
|
|
7
|
-
* file-level variables use the '' (empty string) scope.
|
|
8
|
-
*
|
|
9
|
-
* Design constraints:
|
|
10
|
-
* - Explicit-only: Tier 0 uses type annotations; Tier 1 infers from constructors
|
|
11
|
-
* - Tier 2: single-pass assignment chain propagation in source order — resolves
|
|
12
|
-
* `const b = a` when `a` already has a type from Tier 0/1
|
|
13
|
-
* - Scope-aware: function-local variables don't collide across functions
|
|
14
|
-
* - Conservative: complex/generic types extract the base name only
|
|
15
|
-
* - Per-file: built once, used for receiver resolution, then discarded
|
|
16
|
-
*/
|
|
17
|
-
export type TypeEnv = Map<string, Map<string, string>>;
|
|
4
|
+
import type { NodeLabel } from '../graph/types.js';
|
|
18
5
|
/**
|
|
19
6
|
* Per-file type environment with receiver resolution.
|
|
20
7
|
* Built once per file via `buildTypeEnv`, used for receiver-type filtering,
|
|
@@ -26,12 +13,49 @@ export interface TypeEnvironment {
|
|
|
26
13
|
lookup(varName: string, callNode: SyntaxNode): string | undefined;
|
|
27
14
|
/** Unverified cross-file constructor bindings for SymbolTable verification. */
|
|
28
15
|
readonly constructorBindings: readonly ConstructorBinding[];
|
|
29
|
-
/**
|
|
30
|
-
|
|
16
|
+
/** Get all file-scope bindings (scope key = '') as a read-only map. */
|
|
17
|
+
fileScope(): ReadonlyMap<string, string>;
|
|
18
|
+
/** All scoped bindings as a read-only nested map (scope → varName → type).
|
|
19
|
+
* Use for diagnostics/testing. Prefer lookup() for production call resolution. */
|
|
20
|
+
allScopes(): ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
21
|
+
/** Maps `scope\0varName` → constructor type for virtual dispatch override.
|
|
22
|
+
* Populated when a variable has BOTH a declared base type AND a more specific
|
|
23
|
+
* constructor type (e.g., `Animal a = new Dog()` → key maps to 'Dog'). */
|
|
24
|
+
readonly constructorTypeMap: ReadonlyMap<string, string>;
|
|
25
|
+
}
|
|
26
|
+
/** Check if `child` is a subclass of `parent` using the parentMap.
|
|
27
|
+
* BFS up from child, depth-limited (5), cycle-safe. */
|
|
28
|
+
export declare const isSubclassOf: (child: string, parent: string, parentMap: ReadonlyMap<string, readonly string[]> | undefined) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Options for buildTypeEnv.
|
|
31
|
+
* Uses an options object to allow future extensions without positional parameter sprawl.
|
|
32
|
+
*/
|
|
33
|
+
export interface BuildTypeEnvOptions {
|
|
34
|
+
symbolTable?: SymbolTable;
|
|
35
|
+
parentMap?: ReadonlyMap<string, readonly string[]>;
|
|
36
|
+
/** Pre-resolved bindings from upstream files (Phase 14).
|
|
37
|
+
* Seeded into FILE_SCOPE after walk() for names with no local binding.
|
|
38
|
+
* Local declarations always take precedence (first-writer-wins). */
|
|
39
|
+
importedBindings?: ReadonlyMap<string, string>;
|
|
40
|
+
/** Cross-file return type fallback for imported callables (Phase 14 E3).
|
|
41
|
+
* Consulted ONLY when SymbolTable has no unambiguous match.
|
|
42
|
+
* Local definitions always take precedence (local-first principle). */
|
|
43
|
+
importedReturnTypes?: ReadonlyMap<string, string>;
|
|
44
|
+
/** Cross-file RAW return types for imported callables (Phase 14 E3).
|
|
45
|
+
* Stores raw declared return type strings (e.g., 'User[]', 'List<User>').
|
|
46
|
+
* Used by lookupRawReturnType for for-loop element extraction. */
|
|
47
|
+
importedRawReturnTypes?: ReadonlyMap<string, string>;
|
|
48
|
+
/** Language-specific enclosing function resolver for scope key lookup.
|
|
49
|
+
* Same hook as LanguageProvider.enclosingFunctionFinder — handles languages
|
|
50
|
+
* where function_body is a sibling of the signature (e.g., Dart). */
|
|
51
|
+
enclosingFunctionFinder?: (ancestorNode: SyntaxNode) => {
|
|
52
|
+
funcName: string;
|
|
53
|
+
label: NodeLabel;
|
|
54
|
+
} | null;
|
|
31
55
|
}
|
|
32
56
|
export declare const buildTypeEnv: (tree: {
|
|
33
57
|
rootNode: SyntaxNode;
|
|
34
|
-
}, language: SupportedLanguages,
|
|
58
|
+
}, language: SupportedLanguages, options?: BuildTypeEnvOptions) => TypeEnvironment;
|
|
35
59
|
/**
|
|
36
60
|
* Unverified constructor binding: a `val x = Callee()` pattern where we
|
|
37
61
|
* couldn't confirm the callee is a class (because it's defined in another file).
|