@colbymchenry/codegraph-win32-arm64 1.4.1 → 1.6.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/bin/codegraph.cmd +1 -1
- package/lib/dist/bin/codegraph.js +206 -44
- package/lib/dist/bin/codegraph.js.map +1 -1
- package/lib/dist/context/formatter.d.ts +7 -1
- package/lib/dist/context/formatter.d.ts.map +1 -1
- package/lib/dist/context/formatter.js +12 -6
- package/lib/dist/context/formatter.js.map +1 -1
- package/lib/dist/context/index.d.ts +12 -0
- package/lib/dist/context/index.d.ts.map +1 -1
- package/lib/dist/context/index.js +101 -25
- package/lib/dist/context/index.js.map +1 -1
- package/lib/dist/db/index.d.ts +179 -0
- package/lib/dist/db/index.d.ts.map +1 -1
- package/lib/dist/db/index.js +368 -7
- package/lib/dist/db/index.js.map +1 -1
- package/lib/dist/db/migrations.d.ts +1 -1
- package/lib/dist/db/migrations.d.ts.map +1 -1
- package/lib/dist/db/migrations.js +25 -1
- package/lib/dist/db/migrations.js.map +1 -1
- package/lib/dist/db/queries.d.ts +234 -5
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +687 -53
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/db/schema.sql +16 -3
- package/lib/dist/db/sqlite-adapter.d.ts +3 -1
- package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/lib/dist/db/sqlite-adapter.js +22 -4
- package/lib/dist/db/sqlite-adapter.js.map +1 -1
- package/lib/dist/db/wal-valve.d.ts +15 -2
- package/lib/dist/db/wal-valve.d.ts.map +1 -1
- package/lib/dist/db/wal-valve.js +88 -6
- package/lib/dist/db/wal-valve.js.map +1 -1
- package/lib/dist/directory.d.ts +29 -0
- package/lib/dist/directory.d.ts.map +1 -1
- package/lib/dist/directory.js +52 -0
- package/lib/dist/directory.js.map +1 -1
- package/lib/dist/extraction/extraction-version.d.ts +1 -1
- package/lib/dist/extraction/extraction-version.js +1 -1
- package/lib/dist/extraction/function-ref.d.ts.map +1 -1
- package/lib/dist/extraction/function-ref.js +6 -0
- package/lib/dist/extraction/function-ref.js.map +1 -1
- package/lib/dist/extraction/generated-detection.d.ts +48 -12
- package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
- package/lib/dist/extraction/generated-detection.js +176 -11
- package/lib/dist/extraction/generated-detection.js.map +1 -1
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +101 -2
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/index.d.ts +138 -3
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +518 -94
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/kernel/decode.d.ts +9 -0
- package/lib/dist/extraction/kernel/decode.d.ts.map +1 -0
- package/lib/dist/extraction/kernel/decode.js +162 -0
- package/lib/dist/extraction/kernel/decode.js.map +1 -0
- package/lib/dist/extraction/kernel/index.d.ts +64 -0
- package/lib/dist/extraction/kernel/index.d.ts.map +1 -0
- package/lib/dist/extraction/kernel/index.js +279 -0
- package/lib/dist/extraction/kernel/index.js.map +1 -0
- package/lib/dist/extraction/kernel/layout.d.ts +101 -0
- package/lib/dist/extraction/kernel/layout.d.ts.map +1 -0
- package/lib/dist/extraction/kernel/layout.js +104 -0
- package/lib/dist/extraction/kernel/layout.js.map +1 -0
- package/lib/dist/extraction/kernel/loader.d.ts +103 -0
- package/lib/dist/extraction/kernel/loader.d.ts.map +1 -0
- package/lib/dist/extraction/kernel/loader.js +146 -0
- package/lib/dist/extraction/kernel/loader.js.map +1 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts +14 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.js +868 -16
- package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
- package/lib/dist/extraction/languages/erlang.d.ts.map +1 -1
- package/lib/dist/extraction/languages/erlang.js +58 -22
- package/lib/dist/extraction/languages/erlang.js.map +1 -1
- package/lib/dist/extraction/languages/objc.d.ts.map +1 -1
- package/lib/dist/extraction/languages/objc.js +4 -0
- package/lib/dist/extraction/languages/objc.js.map +1 -1
- package/lib/dist/extraction/languages/rust.d.ts +20 -0
- package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
- package/lib/dist/extraction/languages/rust.js +47 -20
- package/lib/dist/extraction/languages/rust.js.map +1 -1
- package/lib/dist/extraction/parse-pool.d.ts +15 -0
- package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
- package/lib/dist/extraction/parse-pool.js +35 -1
- package/lib/dist/extraction/parse-pool.js.map +1 -1
- package/lib/dist/extraction/parse-worker.js +35 -1
- package/lib/dist/extraction/parse-worker.js.map +1 -1
- package/lib/dist/extraction/store-worker.d.ts +24 -0
- package/lib/dist/extraction/store-worker.d.ts.map +1 -0
- package/lib/dist/extraction/store-worker.js +139 -0
- package/lib/dist/extraction/store-worker.js.map +1 -0
- package/lib/dist/extraction/store-writer.d.ts +63 -0
- package/lib/dist/extraction/store-writer.d.ts.map +1 -0
- package/lib/dist/extraction/store-writer.js +174 -0
- package/lib/dist/extraction/store-writer.js.map +1 -0
- package/lib/dist/extraction/tree-sitter-types.d.ts +2 -0
- package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts +27 -5
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +257 -56
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
- package/lib/dist/extraction/wasm-runtime-flags.d.ts +15 -0
- package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
- package/lib/dist/extraction/wasm-runtime-flags.js +27 -3
- package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -1
- package/lib/dist/graph/queries.d.ts.map +1 -1
- package/lib/dist/graph/queries.js +2 -0
- package/lib/dist/graph/queries.js.map +1 -1
- package/lib/dist/graph/traversal.js +1 -1
- package/lib/dist/graph/traversal.js.map +1 -1
- package/lib/dist/index.d.ts +36 -2
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +305 -11
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/installer/beta-signup.d.ts +54 -0
- package/lib/dist/installer/beta-signup.d.ts.map +1 -0
- package/lib/dist/installer/beta-signup.js +178 -0
- package/lib/dist/installer/beta-signup.js.map +1 -0
- package/lib/dist/installer/index.d.ts +4 -3
- package/lib/dist/installer/index.d.ts.map +1 -1
- package/lib/dist/installer/index.js +19 -6
- package/lib/dist/installer/index.js.map +1 -1
- package/lib/dist/installer/targets/claude.d.ts.map +1 -1
- package/lib/dist/installer/targets/claude.js +37 -5
- package/lib/dist/installer/targets/claude.js.map +1 -1
- package/lib/dist/installer/targets/codex.d.ts +22 -8
- package/lib/dist/installer/targets/codex.d.ts.map +1 -1
- package/lib/dist/installer/targets/codex.js +65 -48
- package/lib/dist/installer/targets/codex.js.map +1 -1
- package/lib/dist/installer/targets/copilot-cli.d.ts +32 -0
- package/lib/dist/installer/targets/copilot-cli.d.ts.map +1 -0
- package/lib/dist/installer/targets/copilot-cli.js +209 -0
- package/lib/dist/installer/targets/copilot-cli.js.map +1 -0
- package/lib/dist/installer/targets/copilot-jetbrains.d.ts +42 -0
- package/lib/dist/installer/targets/copilot-jetbrains.d.ts.map +1 -0
- package/lib/dist/installer/targets/copilot-jetbrains.js +238 -0
- package/lib/dist/installer/targets/copilot-jetbrains.js.map +1 -0
- package/lib/dist/installer/targets/copilot-vscode.d.ts +47 -0
- package/lib/dist/installer/targets/copilot-vscode.d.ts.map +1 -0
- package/lib/dist/installer/targets/copilot-vscode.js +219 -0
- package/lib/dist/installer/targets/copilot-vscode.js.map +1 -0
- package/lib/dist/installer/targets/registry.d.ts.map +1 -1
- package/lib/dist/installer/targets/registry.js +6 -0
- package/lib/dist/installer/targets/registry.js.map +1 -1
- package/lib/dist/installer/targets/toml.d.ts +6 -5
- package/lib/dist/installer/targets/toml.d.ts.map +1 -1
- package/lib/dist/installer/targets/toml.js +99 -20
- package/lib/dist/installer/targets/toml.js.map +1 -1
- package/lib/dist/installer/targets/types.d.ts +5 -5
- package/lib/dist/installer/targets/types.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-manager.d.ts +1 -1
- package/lib/dist/mcp/daemon-manager.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-manager.js +1 -1
- package/lib/dist/mcp/daemon-manager.js.map +1 -1
- package/lib/dist/mcp/daemon-paths.d.ts +6 -0
- package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-paths.js +54 -0
- package/lib/dist/mcp/daemon-paths.js.map +1 -1
- package/lib/dist/mcp/daemon-registry.d.ts +10 -0
- package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-registry.js +51 -3
- package/lib/dist/mcp/daemon-registry.js.map +1 -1
- package/lib/dist/mcp/daemon.d.ts +9 -6
- package/lib/dist/mcp/daemon.d.ts.map +1 -1
- package/lib/dist/mcp/daemon.js +10 -8
- package/lib/dist/mcp/daemon.js.map +1 -1
- package/lib/dist/mcp/engine.d.ts +3 -0
- package/lib/dist/mcp/engine.d.ts.map +1 -1
- package/lib/dist/mcp/engine.js +45 -3
- package/lib/dist/mcp/engine.js.map +1 -1
- package/lib/dist/mcp/explore-dedup.d.ts +137 -0
- package/lib/dist/mcp/explore-dedup.d.ts.map +1 -0
- package/lib/dist/mcp/explore-dedup.js +236 -0
- package/lib/dist/mcp/explore-dedup.js.map +1 -0
- package/lib/dist/mcp/explore-diagnostics.d.ts +289 -0
- package/lib/dist/mcp/explore-diagnostics.d.ts.map +1 -0
- package/lib/dist/mcp/explore-diagnostics.js +558 -0
- package/lib/dist/mcp/explore-diagnostics.js.map +1 -0
- package/lib/dist/mcp/explore-session-state.d.ts +217 -0
- package/lib/dist/mcp/explore-session-state.d.ts.map +1 -0
- package/lib/dist/mcp/explore-session-state.js +322 -0
- package/lib/dist/mcp/explore-session-state.js.map +1 -0
- package/lib/dist/mcp/index.d.ts +24 -0
- package/lib/dist/mcp/index.d.ts.map +1 -1
- package/lib/dist/mcp/index.js +67 -6
- package/lib/dist/mcp/index.js.map +1 -1
- package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
- package/lib/dist/mcp/liveness-watchdog.js +3 -1
- package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
- package/lib/dist/mcp/proxy.d.ts.map +1 -1
- package/lib/dist/mcp/proxy.js +6 -1
- package/lib/dist/mcp/proxy.js.map +1 -1
- package/lib/dist/mcp/server-instructions.d.ts +2 -2
- package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
- package/lib/dist/mcp/server-instructions.js +8 -3
- package/lib/dist/mcp/server-instructions.js.map +1 -1
- package/lib/dist/mcp/session.d.ts +16 -0
- package/lib/dist/mcp/session.d.ts.map +1 -1
- package/lib/dist/mcp/session.js +36 -13
- package/lib/dist/mcp/session.js.map +1 -1
- package/lib/dist/mcp/tools.d.ts +276 -10
- package/lib/dist/mcp/tools.d.ts.map +1 -1
- package/lib/dist/mcp/tools.js +2425 -237
- package/lib/dist/mcp/tools.js.map +1 -1
- package/lib/dist/project-config.d.ts +23 -0
- package/lib/dist/project-config.d.ts.map +1 -1
- package/lib/dist/project-config.js +39 -2
- package/lib/dist/project-config.js.map +1 -1
- package/lib/dist/resolution/c-fnptr-synthesizer.d.ts +1 -1
- package/lib/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/c-fnptr-synthesizer.js +582 -138
- package/lib/dist/resolution/c-fnptr-synthesizer.js.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.d.ts +54 -10
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.js +287 -167
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
- package/lib/dist/resolution/cooperative-yield.d.ts +10 -2
- package/lib/dist/resolution/cooperative-yield.d.ts.map +1 -1
- package/lib/dist/resolution/cooperative-yield.js +6 -4
- package/lib/dist/resolution/cooperative-yield.js.map +1 -1
- package/lib/dist/resolution/frameworks/go.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/go.js +29 -6
- package/lib/dist/resolution/frameworks/go.js.map +1 -1
- package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/swift.js +11 -1
- package/lib/dist/resolution/frameworks/swift.js.map +1 -1
- package/lib/dist/resolution/import-resolver.d.ts +2 -3
- package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
- package/lib/dist/resolution/import-resolver.js +184 -9
- package/lib/dist/resolution/import-resolver.js.map +1 -1
- package/lib/dist/resolution/index.d.ts +87 -2
- package/lib/dist/resolution/index.d.ts.map +1 -1
- package/lib/dist/resolution/index.js +731 -134
- package/lib/dist/resolution/index.js.map +1 -1
- package/lib/dist/resolution/memory-budget.d.ts +48 -0
- package/lib/dist/resolution/memory-budget.d.ts.map +1 -0
- package/lib/dist/resolution/memory-budget.js +162 -0
- package/lib/dist/resolution/memory-budget.js.map +1 -0
- package/lib/dist/resolution/name-matcher.d.ts +42 -1
- package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
- package/lib/dist/resolution/name-matcher.js +681 -99
- package/lib/dist/resolution/name-matcher.js.map +1 -1
- package/lib/dist/resolution/path-aliases.d.ts +6 -4
- package/lib/dist/resolution/path-aliases.d.ts.map +1 -1
- package/lib/dist/resolution/path-aliases.js +125 -17
- package/lib/dist/resolution/path-aliases.js.map +1 -1
- package/lib/dist/resolution/resolver-pool.d.ts +106 -0
- package/lib/dist/resolution/resolver-pool.d.ts.map +1 -0
- package/lib/dist/resolution/resolver-pool.js +344 -0
- package/lib/dist/resolution/resolver-pool.js.map +1 -0
- package/lib/dist/resolution/resolver-worker.d.ts +17 -0
- package/lib/dist/resolution/resolver-worker.d.ts.map +1 -0
- package/lib/dist/resolution/resolver-worker.js +141 -0
- package/lib/dist/resolution/resolver-worker.js.map +1 -0
- package/lib/dist/resolution/types.d.ts +3 -0
- package/lib/dist/resolution/types.d.ts.map +1 -1
- package/lib/dist/search/identifier-segments.d.ts +10 -0
- package/lib/dist/search/identifier-segments.d.ts.map +1 -1
- package/lib/dist/search/identifier-segments.js +29 -0
- package/lib/dist/search/identifier-segments.js.map +1 -1
- package/lib/dist/search/query-paths.d.ts +57 -0
- package/lib/dist/search/query-paths.d.ts.map +1 -0
- package/lib/dist/search/query-paths.js +298 -0
- package/lib/dist/search/query-paths.js.map +1 -0
- package/lib/dist/search/query-utils.d.ts +1 -1
- package/lib/dist/search/query-utils.d.ts.map +1 -1
- package/lib/dist/search/query-utils.js +13 -3
- package/lib/dist/search/query-utils.js.map +1 -1
- package/lib/dist/sync/watcher.d.ts +47 -1
- package/lib/dist/sync/watcher.d.ts.map +1 -1
- package/lib/dist/sync/watcher.js +127 -8
- package/lib/dist/sync/watcher.js.map +1 -1
- package/lib/dist/types.d.ts +61 -3
- package/lib/dist/types.d.ts.map +1 -1
- package/lib/dist/types.js +27 -1
- package/lib/dist/types.js.map +1 -1
- package/lib/dist/ui/color.d.ts +21 -0
- package/lib/dist/ui/color.d.ts.map +1 -0
- package/lib/dist/ui/color.js +42 -0
- package/lib/dist/ui/color.js.map +1 -0
- package/lib/dist/ui/glyphs.d.ts +35 -10
- package/lib/dist/ui/glyphs.d.ts.map +1 -1
- package/lib/dist/ui/glyphs.js +59 -12
- package/lib/dist/ui/glyphs.js.map +1 -1
- package/lib/dist/ui/shimmer-progress.d.ts.map +1 -1
- package/lib/dist/ui/shimmer-progress.js +78 -4
- package/lib/dist/ui/shimmer-progress.js.map +1 -1
- package/lib/dist/ui/shimmer-worker.js +25 -17
- package/lib/dist/ui/shimmer-worker.js.map +1 -1
- package/lib/dist/ui/types.d.ts +0 -2
- package/lib/dist/ui/types.d.ts.map +1 -1
- package/lib/dist/upgrade/index.d.ts +7 -0
- package/lib/dist/upgrade/index.d.ts.map +1 -1
- package/lib/dist/upgrade/index.js +18 -5
- package/lib/dist/upgrade/index.js.map +1 -1
- package/lib/kernel/codegraph-kernel.node +0 -0
- package/lib/node_modules/.package-lock.json +1 -1
- package/lib/package.json +6 -1
- package/package.json +6 -2
|
@@ -47,6 +47,7 @@ const function_ref_1 = require("./function-ref");
|
|
|
47
47
|
const generated_detection_1 = require("./generated-detection");
|
|
48
48
|
const languages_1 = require("./languages");
|
|
49
49
|
const c_cpp_1 = require("./languages/c-cpp");
|
|
50
|
+
const rust_1 = require("./languages/rust");
|
|
50
51
|
const liquid_extractor_1 = require("./liquid-extractor");
|
|
51
52
|
const razor_extractor_1 = require("./razor-extractor");
|
|
52
53
|
const svelte_extractor_1 = require("./svelte-extractor");
|
|
@@ -55,6 +56,7 @@ const dfm_extractor_1 = require("./dfm-extractor");
|
|
|
55
56
|
const vue_extractor_1 = require("./vue-extractor");
|
|
56
57
|
const mybatis_extractor_1 = require("./mybatis-extractor");
|
|
57
58
|
const cfml_extractor_1 = require("./cfml-extractor");
|
|
59
|
+
const kernel_1 = require("./kernel");
|
|
58
60
|
const frameworks_1 = require("../resolution/frameworks");
|
|
59
61
|
// Re-export for backward compatibility
|
|
60
62
|
var tree_sitter_helpers_2 = require("./tree-sitter-helpers");
|
|
@@ -358,6 +360,29 @@ const INSTANTIATION_KINDS = new Set([
|
|
|
358
360
|
/**
|
|
359
361
|
* TreeSitterExtractor - Main extraction class
|
|
360
362
|
*/
|
|
363
|
+
/**
|
|
364
|
+
* tree-sitter node types (across grammars) for literal expressions in method-
|
|
365
|
+
* call RECEIVER position. A literal's methods are the language's builtins —
|
|
366
|
+
* `", ".join`, `"x".toUpperCase()`, `5.times`, `[].concat` — never project
|
|
367
|
+
* symbols, so a member call on one must not emit a `calls` ref that bare-name
|
|
368
|
+
* matching could bind to an unrelated same-named project function (#1230).
|
|
369
|
+
*/
|
|
370
|
+
const LITERAL_RECEIVER_TYPES = new Set([
|
|
371
|
+
// strings
|
|
372
|
+
'string', 'string_literal', 'interpreted_string_literal', 'raw_string_literal',
|
|
373
|
+
'template_string', 'concatenated_string', 'formatted_string', 'f_string',
|
|
374
|
+
'line_string_literal', 'string_content', 'heredoc_body',
|
|
375
|
+
// numbers
|
|
376
|
+
'number', 'number_literal', 'integer', 'integer_literal', 'float',
|
|
377
|
+
'float_literal', 'int_literal', 'decimal_integer_literal', 'real_literal',
|
|
378
|
+
// chars / runes / regex / booleans / null-likes
|
|
379
|
+
'char_literal', 'character_literal', 'rune_literal', 'regex', 'regex_literal',
|
|
380
|
+
'true', 'false', 'boolean_literal', 'bool_literal', 'none', 'null', 'nil',
|
|
381
|
+
'null_literal', 'undefined',
|
|
382
|
+
// collection literals
|
|
383
|
+
'list', 'list_literal', 'array', 'array_literal', 'array_creation_expression',
|
|
384
|
+
'dictionary', 'dict_literal', 'object', 'tuple', 'set',
|
|
385
|
+
]);
|
|
361
386
|
class TreeSitterExtractor {
|
|
362
387
|
filePath;
|
|
363
388
|
language;
|
|
@@ -400,12 +425,17 @@ class TreeSitterExtractor {
|
|
|
400
425
|
fnRefCandidates = [];
|
|
401
426
|
// Memoized "is this a Vue store file" verdict (per-extractor = per-file).
|
|
402
427
|
vueStoreFile = null;
|
|
403
|
-
|
|
428
|
+
// Source already went through the extractor's preParse at the kernel route
|
|
429
|
+
// point (this instance is the wasm fallback for a kernel-deferred file) —
|
|
430
|
+
// don't blank it a second time.
|
|
431
|
+
sourceIsPreParsed = false;
|
|
432
|
+
constructor(filePath, source, language, options) {
|
|
404
433
|
this.filePath = filePath;
|
|
405
434
|
this.source = source;
|
|
406
435
|
this.language = language || (0, grammars_1.detectLanguage)(filePath, source);
|
|
407
436
|
this.extractor = languages_1.EXTRACTORS[this.language] || null;
|
|
408
437
|
this.fnRefSpec = function_ref_1.FN_REF_SPECS[this.language];
|
|
438
|
+
this.sourceIsPreParsed = options?.sourceIsPreParsed === true;
|
|
409
439
|
}
|
|
410
440
|
/**
|
|
411
441
|
* Parse and extract from the source code
|
|
@@ -450,8 +480,9 @@ class TreeSitterExtractor {
|
|
|
450
480
|
// grammar gaps — e.g. C# blanks conditional-compilation directive lines
|
|
451
481
|
// the grammar mis-parses inside enum bodies (#237). We reassign
|
|
452
482
|
// this.source so downstream getNodeText reads the same bytes the parser
|
|
453
|
-
// saw (identical outside the blanked directive lines).
|
|
454
|
-
|
|
483
|
+
// saw (identical outside the blanked directive lines). Skipped when the
|
|
484
|
+
// kernel route point already applied it (sourceIsPreParsed).
|
|
485
|
+
if (this.extractor?.preParse && !this.sourceIsPreParsed) {
|
|
455
486
|
this.source = this.extractor.preParse(this.source, this.filePath);
|
|
456
487
|
}
|
|
457
488
|
this.tree = parser.parse(this.source) ?? null;
|
|
@@ -600,6 +631,13 @@ class TreeSitterExtractor {
|
|
|
600
631
|
for (const n of this.nodes) {
|
|
601
632
|
if (n.kind === 'function' || n.kind === 'method')
|
|
602
633
|
definedHere.add(n.name);
|
|
634
|
+
// Python only (#1478): class-as-value is a first-class idiom (DRF
|
|
635
|
+
// get_serializer_class, Meta.model, registry dicts), so same-file CLASS
|
|
636
|
+
// names pass the gate too. Other languages keep the function/method
|
|
637
|
+
// gate — TS/JS recover class references through type annotations, and
|
|
638
|
+
// resolution's kind filter would drop their class candidates anyway.
|
|
639
|
+
else if (this.language === 'python' && n.kind === 'class')
|
|
640
|
+
definedHere.add(n.name);
|
|
603
641
|
}
|
|
604
642
|
// Import-binding names only (all binding emitters push kind 'imports').
|
|
605
643
|
// Deliberately NOT 'references': those carry type-annotation and
|
|
@@ -1016,6 +1054,11 @@ class TreeSitterExtractor {
|
|
|
1016
1054
|
this.extractStruct(node);
|
|
1017
1055
|
skipChildren = true; // extractStruct visits body children
|
|
1018
1056
|
}
|
|
1057
|
+
// Check for union declarations
|
|
1058
|
+
else if (this.extractor.unionTypes?.includes(nodeType)) {
|
|
1059
|
+
this.extractUnion(node);
|
|
1060
|
+
skipChildren = true; // extractUnion visits body children
|
|
1061
|
+
}
|
|
1019
1062
|
// Check for enum declarations
|
|
1020
1063
|
else if (this.extractor.enumTypes.includes(nodeType)) {
|
|
1021
1064
|
this.extractEnum(node);
|
|
@@ -1344,6 +1387,32 @@ class TreeSitterExtractor {
|
|
|
1344
1387
|
const ns = this.createNode('namespace', pkgName, pkgNode);
|
|
1345
1388
|
return ns?.id ?? null;
|
|
1346
1389
|
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Qualified name for a method defined out-of-line via a receiver qualifier
|
|
1392
|
+
* (`Type::method() {}`). The declarator spells the receiver RELATIVE to the
|
|
1393
|
+
* enclosing namespace, so the active C++ namespace prefix must be composed
|
|
1394
|
+
* in — `namespace sim { Output ManifestStartup::Apply() {} }` previously
|
|
1395
|
+
* indexed as `ManifestStartup::Apply` while the class node carried
|
|
1396
|
+
* `sim::ManifestStartup`, so qualified call sites
|
|
1397
|
+
* (`sim::ManifestStartup::Apply(...)`) never resolved (#1291).
|
|
1398
|
+
*
|
|
1399
|
+
* The source may also re-spell part or all of the namespace path
|
|
1400
|
+
* (`namespace sim { void sim::M::f() {} }` is legal), so the receiver is
|
|
1401
|
+
* anchored at the first prefix segment it names: everything before that
|
|
1402
|
+
* anchor is taken from the prefix, the receiver supplies the rest. A
|
|
1403
|
+
* receiver naming no prefix segment gets the whole prefix prepended.
|
|
1404
|
+
* `namespacePrefix` is only ever non-empty for C++, so every other
|
|
1405
|
+
* receiver language (Go, Rust, Kotlin, Lua) passes through unchanged.
|
|
1406
|
+
*/
|
|
1407
|
+
composeReceiverQualifiedName(receiverType, name) {
|
|
1408
|
+
const base = `${receiverType}::${name}`;
|
|
1409
|
+
if (this.namespacePrefix.length === 0)
|
|
1410
|
+
return base;
|
|
1411
|
+
const receiverHead = receiverType.split('::')[0];
|
|
1412
|
+
const anchor = this.namespacePrefix.indexOf(receiverHead);
|
|
1413
|
+
const prefix = anchor === -1 ? this.namespacePrefix : this.namespacePrefix.slice(0, anchor);
|
|
1414
|
+
return prefix.length > 0 ? `${prefix.join('::')}::${base}` : base;
|
|
1415
|
+
}
|
|
1347
1416
|
/**
|
|
1348
1417
|
* Build qualified name from node stack
|
|
1349
1418
|
*/
|
|
@@ -1382,7 +1451,7 @@ class TreeSitterExtractor {
|
|
|
1382
1451
|
}
|
|
1383
1452
|
/**
|
|
1384
1453
|
* Check if the current node stack indicates we are inside a class-like node
|
|
1385
|
-
* (class, struct, interface, trait). File nodes do not count as class-like.
|
|
1454
|
+
* (class, struct, union, interface, trait). File nodes do not count as class-like.
|
|
1386
1455
|
*/
|
|
1387
1456
|
isInsideClassLikeNode() {
|
|
1388
1457
|
if (this.nodeStack.length === 0)
|
|
@@ -1395,6 +1464,7 @@ class TreeSitterExtractor {
|
|
|
1395
1464
|
return false;
|
|
1396
1465
|
return (parentNode.kind === 'class' ||
|
|
1397
1466
|
parentNode.kind === 'struct' ||
|
|
1467
|
+
parentNode.kind === 'union' ||
|
|
1398
1468
|
parentNode.kind === 'interface' ||
|
|
1399
1469
|
parentNode.kind === 'trait' ||
|
|
1400
1470
|
parentNode.kind === 'enum' ||
|
|
@@ -1667,7 +1737,7 @@ class TreeSitterExtractor {
|
|
|
1667
1737
|
returnType,
|
|
1668
1738
|
};
|
|
1669
1739
|
if (receiverType) {
|
|
1670
|
-
extraProps.qualifiedName =
|
|
1740
|
+
extraProps.qualifiedName = this.composeReceiverQualifiedName(receiverType, name);
|
|
1671
1741
|
}
|
|
1672
1742
|
const methodNode = this.createNode('method', name, node, extraProps);
|
|
1673
1743
|
if (!methodNode)
|
|
@@ -1677,7 +1747,7 @@ class TreeSitterExtractor {
|
|
|
1677
1747
|
if (receiverType && !this.isInsideClassLikeNode()) {
|
|
1678
1748
|
const ownerNode = this.nodes.find((n) => n.name === receiverType &&
|
|
1679
1749
|
n.filePath === this.filePath &&
|
|
1680
|
-
(n.kind === 'struct' || n.kind === 'class' || n.kind === 'enum' || n.kind === 'trait'));
|
|
1750
|
+
(n.kind === 'struct' || n.kind === 'union' || n.kind === 'class' || n.kind === 'enum' || n.kind === 'trait'));
|
|
1681
1751
|
if (ownerNode) {
|
|
1682
1752
|
this.edges.push({
|
|
1683
1753
|
source: ownerNode.id,
|
|
@@ -1735,6 +1805,14 @@ class TreeSitterExtractor {
|
|
|
1735
1805
|
* Extract a struct
|
|
1736
1806
|
*/
|
|
1737
1807
|
extractStruct(node) {
|
|
1808
|
+
this.extractAggregate(node, 'struct');
|
|
1809
|
+
}
|
|
1810
|
+
/** Extract a union while sharing the member-walk behavior of aggregate types. */
|
|
1811
|
+
extractUnion(node) {
|
|
1812
|
+
this.extractAggregate(node, 'union');
|
|
1813
|
+
}
|
|
1814
|
+
/** Extract a struct-like declaration without conflating its semantic kind. */
|
|
1815
|
+
extractAggregate(node, kind) {
|
|
1738
1816
|
if (!this.extractor)
|
|
1739
1817
|
return;
|
|
1740
1818
|
// Skip forward declarations and type references (no body = not a definition)
|
|
@@ -1747,22 +1825,22 @@ class TreeSitterExtractor {
|
|
|
1747
1825
|
const docstring = (0, tree_sitter_helpers_1.getPrecedingDocstring)(node, this.source);
|
|
1748
1826
|
const visibility = this.extractor.getVisibility?.(node);
|
|
1749
1827
|
const isExported = this.extractor.isExported?.(node, this.source);
|
|
1750
|
-
const
|
|
1828
|
+
const aggregateNode = this.createNode(kind, name, node, {
|
|
1751
1829
|
docstring,
|
|
1752
1830
|
visibility,
|
|
1753
1831
|
isExported,
|
|
1754
1832
|
});
|
|
1755
|
-
if (!
|
|
1833
|
+
if (!aggregateNode)
|
|
1756
1834
|
return;
|
|
1757
1835
|
// Extract inheritance (e.g. Swift: struct HTTPMethod: RawRepresentable)
|
|
1758
|
-
this.extractInheritance(node,
|
|
1836
|
+
this.extractInheritance(node, aggregateNode.id);
|
|
1759
1837
|
// C# primary-constructor parameter dependencies (`struct P(int x)`, and
|
|
1760
1838
|
// `record struct M(decimal Amount)` which the grammar nests here).
|
|
1761
|
-
this.extractCsharpPrimaryCtorParamRefs(node,
|
|
1839
|
+
this.extractCsharpPrimaryCtorParamRefs(node, aggregateNode.id);
|
|
1762
1840
|
// Push to stack for field extraction (bodiless positional records have
|
|
1763
1841
|
// no members to visit)
|
|
1764
1842
|
if (body) {
|
|
1765
|
-
this.nodeStack.push(
|
|
1843
|
+
this.nodeStack.push(aggregateNode.id);
|
|
1766
1844
|
for (let i = 0; i < body.namedChildCount; i++) {
|
|
1767
1845
|
const child = body.namedChild(i);
|
|
1768
1846
|
if (child) {
|
|
@@ -2763,18 +2841,18 @@ class TreeSitterExtractor {
|
|
|
2763
2841
|
// Check if this type alias is actually a struct or interface definition
|
|
2764
2842
|
// (e.g. Go: `type Foo struct { ... }` is a type_spec wrapping struct_type)
|
|
2765
2843
|
const resolvedKind = this.extractor.resolveTypeAliasKind?.(node, this.source);
|
|
2766
|
-
if (resolvedKind === 'struct') {
|
|
2767
|
-
const
|
|
2768
|
-
if (!
|
|
2844
|
+
if (resolvedKind === 'struct' || resolvedKind === 'union') {
|
|
2845
|
+
const aggregateNode = this.createNode(resolvedKind, name, node, { docstring, isExported });
|
|
2846
|
+
if (!aggregateNode)
|
|
2769
2847
|
return true;
|
|
2770
2848
|
// Visit body children for field extraction
|
|
2771
|
-
this.nodeStack.push(
|
|
2772
|
-
// Try Go-style 'type' field first, then find inner
|
|
2849
|
+
this.nodeStack.push(aggregateNode.id);
|
|
2850
|
+
// Try Go-style 'type' field first, then find the matching inner aggregate child.
|
|
2773
2851
|
const typeChild = (0, tree_sitter_helpers_1.getChildByField)(node, 'type')
|
|
2774
|
-
|| this.findChildByTypes(node, this.extractor.structTypes);
|
|
2852
|
+
|| this.findChildByTypes(node, resolvedKind === 'union' ? (this.extractor.unionTypes ?? []) : this.extractor.structTypes);
|
|
2775
2853
|
if (typeChild) {
|
|
2776
2854
|
// Extract struct embedding (e.g. Go: `type DB struct { *Head; Queryable }`)
|
|
2777
|
-
this.extractInheritance(typeChild,
|
|
2855
|
+
this.extractInheritance(typeChild, aggregateNode.id);
|
|
2778
2856
|
const body = (0, tree_sitter_helpers_1.getChildByField)(typeChild, this.extractor.bodyField) || typeChild;
|
|
2779
2857
|
for (let i = 0; i < body.namedChildCount; i++) {
|
|
2780
2858
|
const child = body.namedChild(i);
|
|
@@ -3625,15 +3703,18 @@ class TreeSitterExtractor {
|
|
|
3625
3703
|
}
|
|
3626
3704
|
// Erlang: a local call is `call(expr: atom, args)`; a remote call nests it
|
|
3627
3705
|
// under `remote(module: remote_module, fun: call)` — the module qualifier
|
|
3628
|
-
// lives on the PARENT.
|
|
3629
|
-
//
|
|
3630
|
-
//
|
|
3631
|
-
//
|
|
3632
|
-
//
|
|
3633
|
-
//
|
|
3634
|
-
// `
|
|
3635
|
-
//
|
|
3636
|
-
//
|
|
3706
|
+
// lives on the PARENT. Arity is part of a function's identity (#1610), so
|
|
3707
|
+
// refs carry the call-site arity: remote calls are emitted as `mod::fn/2`,
|
|
3708
|
+
// byte-identical to the qualifiedName the module namespace + arity suffix
|
|
3709
|
+
// gives every function (see languages/erlang.ts), so they resolve via
|
|
3710
|
+
// matchByQualifiedName; local calls are emitted `fn/2` and resolved by the
|
|
3711
|
+
// erlang arity step in matchReference (same-file first). A var/macro callee
|
|
3712
|
+
// or module (`F(X)`, `?M(X)`, `Mod:handle(X)`) has no static target —
|
|
3713
|
+
// except `?MODULE:fn(X)`, which the bare-name-with-arity + same-file
|
|
3714
|
+
// preference resolves correctly. `fun name/1` / `fun mod:name/1` values
|
|
3715
|
+
// are function REFERENCES (callback registration) carrying their own
|
|
3716
|
+
// written arity, and record construction/update/index/field-access are
|
|
3717
|
+
// `references` to the record's struct node.
|
|
3637
3718
|
if (this.language === 'erlang') {
|
|
3638
3719
|
const line = node.startPosition.row + 1;
|
|
3639
3720
|
const column = node.startPosition.column;
|
|
@@ -3667,9 +3748,13 @@ class TreeSitterExtractor {
|
|
|
3667
3748
|
if (!macroName || (0, tree_sitter_helpers_1.getNodeText)(macroName, this.source) !== 'MODULE')
|
|
3668
3749
|
return;
|
|
3669
3750
|
}
|
|
3751
|
+
// Arity from the call site's own argument list — part of the callee's
|
|
3752
|
+
// identity, and what disambiguates `f/1` from `f/2` (#1610).
|
|
3753
|
+
const callArgsNode = (0, tree_sitter_helpers_1.getChildByField)(node, 'args');
|
|
3754
|
+
const callArity = callArgsNode ? callArgsNode.namedChildCount : 0;
|
|
3670
3755
|
this.unresolvedReferences.push({
|
|
3671
3756
|
fromNodeId: callerId,
|
|
3672
|
-
referenceName: calleeName
|
|
3757
|
+
referenceName: `${calleeName}/${callArity}`,
|
|
3673
3758
|
referenceKind: 'calls',
|
|
3674
3759
|
line,
|
|
3675
3760
|
column,
|
|
@@ -3690,9 +3775,10 @@ class TreeSitterExtractor {
|
|
|
3690
3775
|
const target = argsNode?.namedChild(0) ?? null;
|
|
3691
3776
|
const targetModule = target ? this.resolveErlangGenServerTarget(target) : null;
|
|
3692
3777
|
if (targetModule) {
|
|
3778
|
+
// OTP fixes the handler arities: handle_call/3, handle_cast/2.
|
|
3693
3779
|
this.unresolvedReferences.push({
|
|
3694
3780
|
fromNodeId: callerId,
|
|
3695
|
-
referenceName: `${targetModule}::${fnBare === 'cast' ? 'handle_cast' : 'handle_call'}`,
|
|
3781
|
+
referenceName: `${targetModule}::${fnBare === 'cast' ? 'handle_cast/2' : 'handle_call/3'}`,
|
|
3696
3782
|
referenceKind: 'calls',
|
|
3697
3783
|
line,
|
|
3698
3784
|
column,
|
|
@@ -3724,9 +3810,17 @@ class TreeSitterExtractor {
|
|
|
3724
3810
|
(0, tree_sitter_helpers_1.getNodeText)((0, tree_sitter_helpers_1.getChildByField)(m, 'name'), this.source) === 'MODULE';
|
|
3725
3811
|
if (m.type !== 'atom' && !isLocalModule)
|
|
3726
3812
|
continue;
|
|
3813
|
+
// Arity of the spawned/applied function = the length of the
|
|
3814
|
+
// static args-list literal directly after the (M, F) pair, when
|
|
3815
|
+
// present (`spawn_link(?MODULE, request_process, [Req, Env])` →
|
|
3816
|
+
// /2). A var/absent list leaves the ref arity-less; the
|
|
3817
|
+
// qualified matcher then resolves it only when the module
|
|
3818
|
+
// defines exactly one arity of that name.
|
|
3819
|
+
const mfaList = argExprs[i + 2];
|
|
3820
|
+
const arityTail = mfaList?.type === 'list' ? `/${mfaList.namedChildCount}` : '';
|
|
3727
3821
|
this.unresolvedReferences.push({
|
|
3728
3822
|
fromNodeId: callerId,
|
|
3729
|
-
referenceName: isLocalModule ? erlAtom(f) : `${erlAtom(m)}::${erlAtom(f)}
|
|
3823
|
+
referenceName: (isLocalModule ? erlAtom(f) : `${erlAtom(m)}::${erlAtom(f)}`) + arityTail,
|
|
3730
3824
|
referenceKind: 'calls',
|
|
3731
3825
|
line: f.startPosition.row + 1,
|
|
3732
3826
|
column: f.startPosition.column,
|
|
@@ -3749,6 +3843,12 @@ class TreeSitterExtractor {
|
|
|
3749
3843
|
return;
|
|
3750
3844
|
refName = `${erlAtom(moduleAtom)}::${refName}`;
|
|
3751
3845
|
}
|
|
3846
|
+
// `fun f/1` writes its arity — carry it so the ref lands on the
|
|
3847
|
+
// matching arity's node (#1610).
|
|
3848
|
+
const funArityNode = (0, tree_sitter_helpers_1.getChildByField)(node, 'arity');
|
|
3849
|
+
const funArityValue = funArityNode ? (0, tree_sitter_helpers_1.getChildByField)(funArityNode, 'value') : null;
|
|
3850
|
+
if (funArityValue)
|
|
3851
|
+
refName = `${refName}/${(0, tree_sitter_helpers_1.getNodeText)(funArityValue, this.source)}`;
|
|
3752
3852
|
this.unresolvedReferences.push({
|
|
3753
3853
|
fromNodeId: callerId,
|
|
3754
3854
|
referenceName: refName,
|
|
@@ -4217,6 +4317,59 @@ class TreeSitterExtractor {
|
|
|
4217
4317
|
}
|
|
4218
4318
|
else {
|
|
4219
4319
|
const func = (0, tree_sitter_helpers_1.getChildByField)(node, 'function') || node.namedChild(0);
|
|
4320
|
+
// C++ explicit operator call `a.operator+(b)` / `p->operator+(b)` (#1247):
|
|
4321
|
+
// tree-sitter-cpp can't parse an operator_name in field position, so the
|
|
4322
|
+
// callee is NOT a field_expression — the call_expression carries
|
|
4323
|
+
// `function: <receiver>` plus an ERROR child wrapping the operator_name.
|
|
4324
|
+
// Reading the function field alone yields just the receiver (`a`), an
|
|
4325
|
+
// unresolvable ref. Recover `<receiver>.operator+` so it resolves like any
|
|
4326
|
+
// other member call (matchMethodCall admits the operator method part).
|
|
4327
|
+
// The infix forms `a + b` / `a[i]` need receiver type inference and are
|
|
4328
|
+
// tracked separately (#1258).
|
|
4329
|
+
if (this.language === 'cpp' && func) {
|
|
4330
|
+
let operatorName = '';
|
|
4331
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
4332
|
+
const child = node.namedChild(i);
|
|
4333
|
+
if (child?.type !== 'ERROR')
|
|
4334
|
+
continue;
|
|
4335
|
+
const op = child.namedChildren.find((c) => c.type === 'operator_name');
|
|
4336
|
+
if (op) {
|
|
4337
|
+
operatorName = (0, tree_sitter_helpers_1.getNodeText)(op, this.source);
|
|
4338
|
+
break;
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
if (operatorName) {
|
|
4342
|
+
// Call sites may space the symbolic name (nlohmann/json's
|
|
4343
|
+
// `it.operator * ()`, `other.operator < (*this)`) while definitions
|
|
4344
|
+
// index compact (`operator*`) — normalize so they match. The word
|
|
4345
|
+
// forms (`operator new`) keep their space.
|
|
4346
|
+
const sym = operatorName.slice('operator'.length).trim();
|
|
4347
|
+
if (/^[^\w\s]/.test(sym))
|
|
4348
|
+
operatorName = `operator${sym.replace(/\s+/g, '')}`;
|
|
4349
|
+
// `->` receivers resolve identically to `.` ones. A receiver that
|
|
4350
|
+
// isn't a simple identifier/member chain (`(*it)`, a call result, …)
|
|
4351
|
+
// can't aid type inference, and a bare operator name would fall
|
|
4352
|
+
// through to exact-name matching — which GUESSES among the many
|
|
4353
|
+
// same-named operators (on nlohmann/json it linked a std::map
|
|
4354
|
+
// `object->operator[]` call to an unrelated in-repo operator[]).
|
|
4355
|
+
// Drop the ref: a silent miss, never a wrong edge. `this->` keeps
|
|
4356
|
+
// the bare name, matching how `this.method()` calls are emitted —
|
|
4357
|
+
// the target is on the enclosing class, where exact-name's same-file
|
|
4358
|
+
// preference is reliable.
|
|
4359
|
+
const receiver = (0, tree_sitter_helpers_1.getNodeText)(func, this.source).replace(/->/g, '.').replace(/\s+/g, '');
|
|
4360
|
+
if (receiver !== 'this' && !/^[A-Za-z_][\w.]*$/.test(receiver))
|
|
4361
|
+
return;
|
|
4362
|
+
const calleeName = receiver === 'this' ? operatorName : `${receiver}.${operatorName}`;
|
|
4363
|
+
this.unresolvedReferences.push({
|
|
4364
|
+
fromNodeId: callerId,
|
|
4365
|
+
referenceName: calleeName,
|
|
4366
|
+
referenceKind: 'calls',
|
|
4367
|
+
line: node.startPosition.row + 1,
|
|
4368
|
+
column: node.startPosition.column,
|
|
4369
|
+
});
|
|
4370
|
+
return;
|
|
4371
|
+
}
|
|
4372
|
+
}
|
|
4220
4373
|
if (func) {
|
|
4221
4374
|
if (func.type === 'member_expression' || func.type === 'attribute' || func.type === 'selector_expression' || func.type === 'navigation_expression' || func.type === 'field_expression') {
|
|
4222
4375
|
// Method call: obj.method() or obj.field.method()
|
|
@@ -4244,6 +4397,16 @@ class TreeSitterExtractor {
|
|
|
4244
4397
|
(0, tree_sitter_helpers_1.getChildByField)(func, 'operand') ||
|
|
4245
4398
|
(0, tree_sitter_helpers_1.getChildByField)(func, 'argument') ||
|
|
4246
4399
|
func.namedChild(0);
|
|
4400
|
+
// A LITERAL receiver — `", ".join(...)`, `"x".toUpperCase()`,
|
|
4401
|
+
// `5.times`, `[].concat(...)` — calls a builtin of the literal's
|
|
4402
|
+
// type, never a project symbol. The bare-name fallback below let
|
|
4403
|
+
// these exact-match an unrelated same-named project function
|
|
4404
|
+
// (`", ".join` bound to a local `join` defined inside a DIFFERENT
|
|
4405
|
+
// function, #1230). Emit nothing: a silent miss, never a wrong
|
|
4406
|
+
// edge. Nested calls in the arguments are visited independently.
|
|
4407
|
+
if (receiver && LITERAL_RECEIVER_TYPES.has(receiver.type)) {
|
|
4408
|
+
return;
|
|
4409
|
+
}
|
|
4247
4410
|
const SKIP_RECEIVERS = new Set(['self', 'this', 'cls', 'super']);
|
|
4248
4411
|
if (receiver && (receiver.type === 'identifier' || receiver.type === 'simple_identifier' || receiver.type === 'field_identifier')) {
|
|
4249
4412
|
const receiverName = (0, tree_sitter_helpers_1.getNodeText)(receiver, this.source);
|
|
@@ -4254,6 +4417,25 @@ class TreeSitterExtractor {
|
|
|
4254
4417
|
calleeName = methodName;
|
|
4255
4418
|
}
|
|
4256
4419
|
}
|
|
4420
|
+
else if (this.language === 'rust' &&
|
|
4421
|
+
receiver &&
|
|
4422
|
+
receiver.type === 'field_expression' &&
|
|
4423
|
+
(0, tree_sitter_helpers_1.getChildByField)(receiver, 'value')?.type === 'self' &&
|
|
4424
|
+
(0, tree_sitter_helpers_1.getChildByField)(receiver, 'field')?.type === 'field_identifier') {
|
|
4425
|
+
// Rust `self.<field>.<method>()` — a call through a field of the
|
|
4426
|
+
// enclosing type (#1585). Keep the `self.` prefix: the resolver
|
|
4427
|
+
// recognizes the shape, reads the field's declared type off the
|
|
4428
|
+
// owner struct's declaration, and resolves the method on THAT
|
|
4429
|
+
// type — or leaves the ref unresolved when the type is external
|
|
4430
|
+
// or unknown. Previously this collapsed to the bare method name,
|
|
4431
|
+
// which exact-matched whichever same-named method was nearest —
|
|
4432
|
+
// often the calling method itself, a self-edge not in the source.
|
|
4433
|
+
// Deeper chains (`self.a.b.m()`), `self.f().m()` and parenthesized
|
|
4434
|
+
// receivers keep the bare name. Mirrored in the kernel's
|
|
4435
|
+
// extract_call (rustlang.rs).
|
|
4436
|
+
const fieldName = (0, tree_sitter_helpers_1.getNodeText)((0, tree_sitter_helpers_1.getChildByField)(receiver, 'field'), this.source);
|
|
4437
|
+
calleeName = `self.${fieldName}.${methodName}`;
|
|
4438
|
+
}
|
|
4257
4439
|
else if ((this.language === 'cpp' ||
|
|
4258
4440
|
this.language === 'c' ||
|
|
4259
4441
|
this.language === 'kotlin' ||
|
|
@@ -4329,6 +4511,20 @@ class TreeSitterExtractor {
|
|
|
4329
4511
|
// name, which either failed to resolve or resolved ambiguously.
|
|
4330
4512
|
calleeName = `${(0, tree_sitter_helpers_1.getNodeText)(receiver, this.source)}.${methodName}`;
|
|
4331
4513
|
}
|
|
4514
|
+
else if (this.language === 'go' &&
|
|
4515
|
+
receiver &&
|
|
4516
|
+
receiver.type === 'selector_expression' &&
|
|
4517
|
+
/^[A-Za-z_]\w*\.[A-Za-z_]\w*$/.test((0, tree_sitter_helpers_1.getNodeText)(receiver, this.source).replace(/\s+/g, ''))) {
|
|
4518
|
+
// Go 2-hop field chain `target.conn.Exec(...)`: keep the
|
|
4519
|
+
// receiver chain so resolution can infer `conn`'s declared type
|
|
4520
|
+
// from the Target struct. Previously this emitted the bare
|
|
4521
|
+
// method name, and when the field's type is EXTERNAL (sql.DB)
|
|
4522
|
+
// the bare name exact-matched an unrelated same-named local
|
|
4523
|
+
// method — a fabricated internal dependency (#1276). Chained
|
|
4524
|
+
// Go receivers resolve strictly via validated field-hop
|
|
4525
|
+
// inference (see matchGoFieldChainCall) or stay unresolved.
|
|
4526
|
+
calleeName = `${(0, tree_sitter_helpers_1.getNodeText)(receiver, this.source).replace(/\s+/g, '')}.${methodName}`;
|
|
4527
|
+
}
|
|
4332
4528
|
else {
|
|
4333
4529
|
calleeName = methodName;
|
|
4334
4530
|
}
|
|
@@ -5098,6 +5294,10 @@ class TreeSitterExtractor {
|
|
|
5098
5294
|
this.extractStruct(node);
|
|
5099
5295
|
return;
|
|
5100
5296
|
}
|
|
5297
|
+
if (this.extractor.unionTypes?.includes(nodeType)) {
|
|
5298
|
+
this.extractUnion(node);
|
|
5299
|
+
return;
|
|
5300
|
+
}
|
|
5101
5301
|
if (this.extractor.enumTypes.includes(nodeType)) {
|
|
5102
5302
|
this.extractEnum(node);
|
|
5103
5303
|
return;
|
|
@@ -5506,31 +5706,20 @@ class TreeSitterExtractor {
|
|
|
5506
5706
|
* For plain `impl Type { ... }` (no trait), no inheritance edge is needed.
|
|
5507
5707
|
*/
|
|
5508
5708
|
extractRustImplItem(node) {
|
|
5509
|
-
//
|
|
5510
|
-
|
|
5511
|
-
|
|
5709
|
+
// `impl Trait for Type` carries the trait in the grammar's `trait` field;
|
|
5710
|
+
// an inherent `impl Type { … }` has none and needs no inheritance edge.
|
|
5711
|
+
const traitNode = (0, tree_sitter_helpers_1.getChildByField)(node, 'trait');
|
|
5712
|
+
if (!traitNode)
|
|
5512
5713
|
return;
|
|
5513
|
-
//
|
|
5514
|
-
//
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5714
|
+
// Full text, so a scoped path (`std::fmt::Display`) and a generic trait
|
|
5715
|
+
// (`From<u32>`) keep their spelling.
|
|
5716
|
+
const traitName = (0, tree_sitter_helpers_1.getNodeText)(traitNode, this.source);
|
|
5717
|
+
// The implementing type from the `type` field (#1588). The old positional
|
|
5718
|
+
// scan took the LAST type-shaped child, which for a parameterized
|
|
5719
|
+
// implementing type (`BufSource<T>`, `Parents<'a>`, `&Foo`) was the trait.
|
|
5720
|
+
const typeName = (0, rust_1.rustImplTypeName)((0, tree_sitter_helpers_1.getChildByField)(node, 'type'), this.source);
|
|
5721
|
+
if (!typeName)
|
|
5518
5722
|
return;
|
|
5519
|
-
const traitNode = typeIdents[0];
|
|
5520
|
-
const typeNode = typeIdents[typeIdents.length - 1];
|
|
5521
|
-
// Get the trait name (handle scoped paths like std::fmt::Display)
|
|
5522
|
-
const traitName = traitNode.type === 'scoped_type_identifier'
|
|
5523
|
-
? this.source.substring(traitNode.startIndex, traitNode.endIndex)
|
|
5524
|
-
: (0, tree_sitter_helpers_1.getNodeText)(traitNode, this.source);
|
|
5525
|
-
// Get the implementing type name (extract inner type_identifier for generics)
|
|
5526
|
-
let typeName;
|
|
5527
|
-
if (typeNode.type === 'generic_type') {
|
|
5528
|
-
const inner = typeNode.namedChildren.find((c) => c.type === 'type_identifier');
|
|
5529
|
-
typeName = inner ? (0, tree_sitter_helpers_1.getNodeText)(inner, this.source) : (0, tree_sitter_helpers_1.getNodeText)(typeNode, this.source);
|
|
5530
|
-
}
|
|
5531
|
-
else {
|
|
5532
|
-
typeName = (0, tree_sitter_helpers_1.getNodeText)(typeNode, this.source);
|
|
5533
|
-
}
|
|
5534
5723
|
// Find the struct/type node for the implementing type
|
|
5535
5724
|
const typeNodeId = this.findNodeByName(typeName);
|
|
5536
5725
|
if (typeNodeId) {
|
|
@@ -5548,7 +5737,7 @@ class TreeSitterExtractor {
|
|
|
5548
5737
|
*/
|
|
5549
5738
|
findNodeByName(name) {
|
|
5550
5739
|
for (const node of this.nodes) {
|
|
5551
|
-
if (node.name === name && (node.kind === 'struct' || node.kind === 'enum' || node.kind === 'class')) {
|
|
5740
|
+
if (node.name === name && (node.kind === 'struct' || node.kind === 'union' || node.kind === 'enum' || node.kind === 'class')) {
|
|
5552
5741
|
return node.id;
|
|
5553
5742
|
}
|
|
5554
5743
|
}
|
|
@@ -6477,8 +6666,20 @@ function extractFromSource(filePath, source, language, frameworkNames) {
|
|
|
6477
6666
|
result = extractor.extract();
|
|
6478
6667
|
}
|
|
6479
6668
|
else {
|
|
6480
|
-
|
|
6481
|
-
|
|
6669
|
+
// Native-kernel route (docs/design/rust-kernel-migration-plan.md): gated
|
|
6670
|
+
// per language, null when not routed/available or on a kernel error —
|
|
6671
|
+
// the wasm TreeSitterExtractor below stays the fallback either way.
|
|
6672
|
+
const kernelResult = (0, kernel_1.tryKernelExtract)(filePath, source, detectedLanguage);
|
|
6673
|
+
if (kernelResult) {
|
|
6674
|
+
result = kernelResult;
|
|
6675
|
+
}
|
|
6676
|
+
else {
|
|
6677
|
+
// A kernel-deferred file already paid the (offset-preserving) preParse
|
|
6678
|
+
// at the route point — reuse those bytes instead of blanking again.
|
|
6679
|
+
const deferredPre = (0, kernel_1.takeDeferredPreParse)(filePath, source, detectedLanguage);
|
|
6680
|
+
const extractor = new TreeSitterExtractor(filePath, deferredPre ?? source, detectedLanguage, { sourceIsPreParsed: deferredPre != null });
|
|
6681
|
+
result = extractor.extract();
|
|
6682
|
+
}
|
|
6482
6683
|
}
|
|
6483
6684
|
// Framework-specific extraction (routes, middleware, etc.)
|
|
6484
6685
|
if (frameworkNames && frameworkNames.length > 0) {
|