@colbymchenry/codegraph-win32-arm64 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/codegraph +5 -0
- package/lib/dist/.test-build-engine.json +1 -0
- package/lib/dist/.test-build-viewer.json +1 -0
- package/lib/dist/bin/codegraph.d.ts +1 -0
- package/lib/dist/bin/codegraph.d.ts.map +1 -1
- package/lib/dist/bin/codegraph.js +599 -291
- package/lib/dist/bin/codegraph.js.map +1 -1
- package/lib/dist/bin/viewer-gate.d.ts +17 -0
- package/lib/dist/bin/viewer-gate.d.ts.map +1 -0
- package/lib/dist/bin/viewer-gate.js +31 -0
- package/lib/dist/bin/viewer-gate.js.map +1 -0
- package/lib/dist/context/index.d.ts.map +1 -1
- package/lib/dist/context/index.js +43 -2
- package/lib/dist/context/index.js.map +1 -1
- package/lib/dist/db/index.d.ts +21 -2
- package/lib/dist/db/index.d.ts.map +1 -1
- package/lib/dist/db/index.js +86 -31
- 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 +40 -1
- package/lib/dist/db/migrations.js.map +1 -1
- package/lib/dist/db/queries.d.ts +423 -3
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +1026 -33
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/db/schema.sql +11 -1
- package/lib/dist/db/sqlite-adapter.d.ts +2 -0
- package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/lib/dist/db/sqlite-adapter.js +56 -7
- package/lib/dist/db/sqlite-adapter.js.map +1 -1
- package/lib/dist/db/synthesis-stage.d.ts +12 -0
- package/lib/dist/db/synthesis-stage.d.ts.map +1 -0
- package/lib/dist/db/synthesis-stage.js +89 -0
- package/lib/dist/db/synthesis-stage.js.map +1 -0
- package/lib/dist/db/wal-valve.d.ts +32 -12
- package/lib/dist/db/wal-valve.d.ts.map +1 -1
- package/lib/dist/db/wal-valve.js +65 -22
- package/lib/dist/db/wal-valve.js.map +1 -1
- package/lib/dist/db/wsl-shared-index.d.ts +53 -0
- package/lib/dist/db/wsl-shared-index.d.ts.map +1 -0
- package/lib/dist/db/wsl-shared-index.js +121 -0
- package/lib/dist/db/wsl-shared-index.js.map +1 -0
- package/lib/dist/directory.d.ts +101 -2
- package/lib/dist/directory.d.ts.map +1 -1
- package/lib/dist/directory.js +254 -23
- package/lib/dist/directory.js.map +1 -1
- package/lib/dist/errors.d.ts +14 -0
- package/lib/dist/errors.d.ts.map +1 -1
- package/lib/dist/errors.js +16 -1
- package/lib/dist/errors.js.map +1 -1
- package/lib/dist/extraction/cfml-extractor.d.ts +1 -0
- package/lib/dist/extraction/cfml-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/cfml-extractor.js +15 -3
- package/lib/dist/extraction/cfml-extractor.js.map +1 -1
- package/lib/dist/extraction/dfm-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/dfm-extractor.js +14 -10
- package/lib/dist/extraction/dfm-extractor.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 +6 -4
- package/lib/dist/extraction/function-ref.d.ts.map +1 -1
- package/lib/dist/extraction/function-ref.js +35 -14
- package/lib/dist/extraction/function-ref.js.map +1 -1
- package/lib/dist/extraction/grammars.d.ts +38 -0
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +77 -1
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/index.d.ts +113 -15
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +599 -132
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.d.ts +58 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.js +291 -15
- package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
- package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
- package/lib/dist/extraction/languages/dart.js +8 -3
- package/lib/dist/extraction/languages/dart.js.map +1 -1
- package/lib/dist/extraction/languages/javascript.js +1 -1
- package/lib/dist/extraction/languages/javascript.js.map +1 -1
- package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
- package/lib/dist/extraction/languages/kotlin.js +169 -36
- package/lib/dist/extraction/languages/kotlin.js.map +1 -1
- package/lib/dist/extraction/languages/lua.d.ts.map +1 -1
- package/lib/dist/extraction/languages/lua.js +4 -1
- package/lib/dist/extraction/languages/lua.js.map +1 -1
- package/lib/dist/extraction/languages/python.d.ts.map +1 -1
- package/lib/dist/extraction/languages/python.js +71 -0
- package/lib/dist/extraction/languages/python.js.map +1 -1
- package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
- package/lib/dist/extraction/languages/rust.js +3 -0
- package/lib/dist/extraction/languages/rust.js.map +1 -1
- package/lib/dist/extraction/languages/scala.d.ts.map +1 -1
- package/lib/dist/extraction/languages/scala.js +18 -3
- package/lib/dist/extraction/languages/scala.js.map +1 -1
- package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
- package/lib/dist/extraction/languages/typescript.js +9 -2
- package/lib/dist/extraction/languages/typescript.js.map +1 -1
- package/lib/dist/extraction/liquid-extractor.d.ts +18 -0
- package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/liquid-extractor.js +98 -22
- package/lib/dist/extraction/liquid-extractor.js.map +1 -1
- package/lib/dist/extraction/mybatis-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/mybatis-extractor.js +6 -4
- package/lib/dist/extraction/mybatis-extractor.js.map +1 -1
- package/lib/dist/extraction/syntax-tokens.d.ts +103 -0
- package/lib/dist/extraction/syntax-tokens.d.ts.map +1 -0
- package/lib/dist/extraction/syntax-tokens.js +381 -0
- package/lib/dist/extraction/syntax-tokens.js.map +1 -0
- package/lib/dist/extraction/tree-sitter-helpers.d.ts +5 -0
- package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter-helpers.js +17 -0
- package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
- package/lib/dist/extraction/tree-sitter-types.d.ts +29 -3
- package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts +96 -17
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +820 -82
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
- package/lib/dist/file-limits.d.ts +40 -0
- package/lib/dist/file-limits.d.ts.map +1 -0
- package/lib/dist/file-limits.js +147 -0
- package/lib/dist/file-limits.js.map +1 -0
- package/lib/dist/graph/branch-guards.d.ts +248 -0
- package/lib/dist/graph/branch-guards.d.ts.map +1 -0
- package/lib/dist/graph/branch-guards.js +2231 -0
- package/lib/dist/graph/branch-guards.js.map +1 -0
- package/lib/dist/graph/dead-code.d.ts +251 -0
- package/lib/dist/graph/dead-code.d.ts.map +1 -0
- package/lib/dist/graph/dead-code.js +776 -0
- package/lib/dist/graph/dead-code.js.map +1 -0
- package/lib/dist/graph/dynamic-boundary-report.d.ts +121 -0
- package/lib/dist/graph/dynamic-boundary-report.d.ts.map +1 -0
- package/lib/dist/graph/dynamic-boundary-report.js +283 -0
- package/lib/dist/graph/dynamic-boundary-report.js.map +1 -0
- package/lib/dist/graph/index.d.ts +4 -0
- package/lib/dist/graph/index.d.ts.map +1 -1
- package/lib/dist/graph/index.js +16 -1
- package/lib/dist/graph/index.js.map +1 -1
- package/lib/dist/graph/named-symbol-flow.d.ts +125 -0
- package/lib/dist/graph/named-symbol-flow.d.ts.map +1 -0
- package/lib/dist/graph/named-symbol-flow.js +552 -0
- package/lib/dist/graph/named-symbol-flow.js.map +1 -0
- package/lib/dist/graph/symbol-lookup.d.ts +83 -0
- package/lib/dist/graph/symbol-lookup.d.ts.map +1 -0
- package/lib/dist/graph/symbol-lookup.js +181 -0
- package/lib/dist/graph/symbol-lookup.js.map +1 -0
- package/lib/dist/graph/traversal.d.ts +9 -0
- package/lib/dist/graph/traversal.d.ts.map +1 -1
- package/lib/dist/graph/traversal.js +61 -35
- package/lib/dist/graph/traversal.js.map +1 -1
- package/lib/dist/graph/type-hierarchy.d.ts +155 -0
- package/lib/dist/graph/type-hierarchy.d.ts.map +1 -0
- package/lib/dist/graph/type-hierarchy.js +382 -0
- package/lib/dist/graph/type-hierarchy.js.map +1 -0
- package/lib/dist/index.d.ts +251 -11
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +395 -34
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/installer/index.d.ts.map +1 -1
- package/lib/dist/installer/index.js +3 -2
- package/lib/dist/installer/index.js.map +1 -1
- package/lib/dist/installer/targets/antigravity.d.ts.map +1 -1
- package/lib/dist/installer/targets/antigravity.js +14 -2
- package/lib/dist/installer/targets/antigravity.js.map +1 -1
- package/lib/dist/installer/targets/claude.d.ts +3 -0
- package/lib/dist/installer/targets/claude.d.ts.map +1 -1
- package/lib/dist/installer/targets/claude.js +35 -7
- package/lib/dist/installer/targets/claude.js.map +1 -1
- package/lib/dist/installer/targets/codex.d.ts +2 -1
- package/lib/dist/installer/targets/codex.d.ts.map +1 -1
- package/lib/dist/installer/targets/codex.js +14 -4
- package/lib/dist/installer/targets/codex.js.map +1 -1
- package/lib/dist/installer/targets/copilot-cli.d.ts.map +1 -1
- package/lib/dist/installer/targets/copilot-cli.js +7 -1
- package/lib/dist/installer/targets/copilot-cli.js.map +1 -1
- package/lib/dist/installer/targets/opencode.d.ts +16 -5
- package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
- package/lib/dist/installer/targets/opencode.js +73 -22
- package/lib/dist/installer/targets/opencode.js.map +1 -1
- package/lib/dist/installer/targets/shared.d.ts +14 -3
- package/lib/dist/installer/targets/shared.d.ts.map +1 -1
- package/lib/dist/installer/targets/shared.js +39 -11
- package/lib/dist/installer/targets/shared.js.map +1 -1
- package/lib/dist/installer/targets/types.d.ts +7 -0
- package/lib/dist/installer/targets/types.d.ts.map +1 -1
- package/lib/dist/mcp/answer-freshness.d.ts +10 -0
- package/lib/dist/mcp/answer-freshness.d.ts.map +1 -0
- package/lib/dist/mcp/answer-freshness.js +68 -0
- package/lib/dist/mcp/answer-freshness.js.map +1 -0
- package/lib/dist/mcp/daemon-manager.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-manager.js +16 -0
- package/lib/dist/mcp/daemon-manager.js.map +1 -1
- package/lib/dist/mcp/daemon-paths.d.ts +2 -0
- package/lib/dist/mcp/daemon-paths.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-paths.js +12 -3
- package/lib/dist/mcp/daemon-paths.js.map +1 -1
- package/lib/dist/mcp/daemon-registry.d.ts +7 -4
- package/lib/dist/mcp/daemon-registry.d.ts.map +1 -1
- package/lib/dist/mcp/daemon-registry.js +91 -29
- package/lib/dist/mcp/daemon-registry.js.map +1 -1
- package/lib/dist/mcp/daemon.d.ts +17 -7
- package/lib/dist/mcp/daemon.d.ts.map +1 -1
- package/lib/dist/mcp/daemon.js +116 -24
- package/lib/dist/mcp/daemon.js.map +1 -1
- package/lib/dist/mcp/dynamic-boundaries.d.ts +1 -10
- package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -1
- package/lib/dist/mcp/dynamic-boundaries.js +46 -42
- package/lib/dist/mcp/dynamic-boundaries.js.map +1 -1
- package/lib/dist/mcp/engine.d.ts +28 -9
- package/lib/dist/mcp/engine.d.ts.map +1 -1
- package/lib/dist/mcp/engine.js +146 -62
- package/lib/dist/mcp/engine.js.map +1 -1
- package/lib/dist/mcp/explore-dedup.d.ts +5 -2
- package/lib/dist/mcp/explore-dedup.d.ts.map +1 -1
- package/lib/dist/mcp/explore-dedup.js +8 -5
- package/lib/dist/mcp/explore-dedup.js.map +1 -1
- package/lib/dist/mcp/index-freshness-worker.d.ts +2 -0
- package/lib/dist/mcp/index-freshness-worker.d.ts.map +1 -0
- package/lib/dist/mcp/index-freshness-worker.js +30 -0
- package/lib/dist/mcp/index-freshness-worker.js.map +1 -0
- package/lib/dist/mcp/index-freshness.d.ts +7 -0
- package/lib/dist/mcp/index-freshness.d.ts.map +1 -0
- package/lib/dist/mcp/index-freshness.js +94 -0
- package/lib/dist/mcp/index-freshness.js.map +1 -0
- package/lib/dist/mcp/index.d.ts +3 -1
- package/lib/dist/mcp/index.d.ts.map +1 -1
- package/lib/dist/mcp/index.js +95 -11
- package/lib/dist/mcp/index.js.map +1 -1
- package/lib/dist/mcp/liveness-watchdog.d.ts +4 -1
- package/lib/dist/mcp/liveness-watchdog.d.ts.map +1 -1
- package/lib/dist/mcp/liveness-watchdog.js +11 -2
- package/lib/dist/mcp/liveness-watchdog.js.map +1 -1
- package/lib/dist/mcp/project-lifecycle.d.ts +9 -0
- package/lib/dist/mcp/project-lifecycle.d.ts.map +1 -0
- package/lib/dist/mcp/project-lifecycle.js +181 -0
- package/lib/dist/mcp/project-lifecycle.js.map +1 -0
- package/lib/dist/mcp/proxy.d.ts.map +1 -1
- package/lib/dist/mcp/proxy.js +9 -0
- package/lib/dist/mcp/proxy.js.map +1 -1
- package/lib/dist/mcp/query-pool.d.ts +2 -2
- package/lib/dist/mcp/query-pool.d.ts.map +1 -1
- package/lib/dist/mcp/query-pool.js +9 -7
- package/lib/dist/mcp/query-pool.js.map +1 -1
- package/lib/dist/mcp/query-worker.js +2 -2
- package/lib/dist/mcp/query-worker.js.map +1 -1
- package/lib/dist/mcp/server-instructions.d.ts +1 -1
- package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
- package/lib/dist/mcp/server-instructions.js +6 -3
- package/lib/dist/mcp/server-instructions.js.map +1 -1
- package/lib/dist/mcp/startup-handshake.d.ts +3 -1
- package/lib/dist/mcp/startup-handshake.d.ts.map +1 -1
- package/lib/dist/mcp/startup-handshake.js +10 -2
- package/lib/dist/mcp/startup-handshake.js.map +1 -1
- package/lib/dist/mcp/tools.d.ts +276 -36
- package/lib/dist/mcp/tools.d.ts.map +1 -1
- package/lib/dist/mcp/tools.js +2295 -980
- package/lib/dist/mcp/tools.js.map +1 -1
- package/lib/dist/mcp/writer-lock.d.ts +61 -0
- package/lib/dist/mcp/writer-lock.d.ts.map +1 -0
- package/lib/dist/mcp/writer-lock.js +260 -0
- package/lib/dist/mcp/writer-lock.js.map +1 -0
- package/lib/dist/resolution/alias-binding.d.ts +56 -0
- package/lib/dist/resolution/alias-binding.d.ts.map +1 -0
- package/lib/dist/resolution/alias-binding.js +127 -0
- package/lib/dist/resolution/alias-binding.js.map +1 -0
- package/lib/dist/resolution/callback-synthesizer.d.ts +23 -1
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.js +291 -143
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
- package/lib/dist/resolution/cpp-constructor.d.ts +4 -0
- package/lib/dist/resolution/cpp-constructor.d.ts.map +1 -0
- package/lib/dist/resolution/cpp-constructor.js +123 -0
- package/lib/dist/resolution/cpp-constructor.js.map +1 -0
- package/lib/dist/resolution/cpp-macro-visibility.d.ts +12 -0
- package/lib/dist/resolution/cpp-macro-visibility.d.ts.map +1 -0
- package/lib/dist/resolution/cpp-macro-visibility.js +342 -0
- package/lib/dist/resolution/cpp-macro-visibility.js.map +1 -0
- package/lib/dist/resolution/expo-router-synthesizer.d.ts +32 -0
- package/lib/dist/resolution/expo-router-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/expo-router-synthesizer.js +189 -0
- package/lib/dist/resolution/expo-router-synthesizer.js.map +1 -0
- package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/csharp.js +96 -2
- package/lib/dist/resolution/frameworks/csharp.js.map +1 -1
- package/lib/dist/resolution/frameworks/expo-router.d.ts +189 -0
- package/lib/dist/resolution/frameworks/expo-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/expo-router.js +785 -0
- package/lib/dist/resolution/frameworks/expo-router.js.map +1 -0
- package/lib/dist/resolution/frameworks/express.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/express.js +251 -16
- package/lib/dist/resolution/frameworks/express.js.map +1 -1
- package/lib/dist/resolution/frameworks/index.d.ts +5 -0
- package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/index.js +29 -1
- package/lib/dist/resolution/frameworks/index.js.map +1 -1
- package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/java.js +79 -47
- package/lib/dist/resolution/frameworks/java.js.map +1 -1
- package/lib/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/nestjs.js +6 -14
- package/lib/dist/resolution/frameworks/nestjs.js.map +1 -1
- package/lib/dist/resolution/frameworks/nextjs.d.ts +76 -0
- package/lib/dist/resolution/frameworks/nextjs.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/nextjs.js +328 -0
- package/lib/dist/resolution/frameworks/nextjs.js.map +1 -0
- package/lib/dist/resolution/frameworks/object-literal.d.ts +32 -0
- package/lib/dist/resolution/frameworks/object-literal.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/object-literal.js +139 -0
- package/lib/dist/resolution/frameworks/object-literal.js.map +1 -0
- package/lib/dist/resolution/frameworks/package-deps.d.ts +14 -0
- package/lib/dist/resolution/frameworks/package-deps.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/package-deps.js +78 -0
- package/lib/dist/resolution/frameworks/package-deps.js.map +1 -0
- package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/python.js +166 -0
- package/lib/dist/resolution/frameworks/python.js.map +1 -1
- package/lib/dist/resolution/frameworks/react-native.d.ts +26 -0
- package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react-native.js +153 -14
- package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
- package/lib/dist/resolution/frameworks/react-router.d.ts +46 -0
- package/lib/dist/resolution/frameworks/react-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/react-router.js +187 -0
- package/lib/dist/resolution/frameworks/react-router.js.map +1 -0
- package/lib/dist/resolution/frameworks/react.d.ts +2 -1
- package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react.js +188 -139
- package/lib/dist/resolution/frameworks/react.js.map +1 -1
- package/lib/dist/resolution/frameworks/svelte.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/svelte.js +6 -1
- package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
- package/lib/dist/resolution/frameworks/sveltekit-router.d.ts +36 -0
- package/lib/dist/resolution/frameworks/sveltekit-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/sveltekit-router.js +156 -0
- package/lib/dist/resolution/frameworks/sveltekit-router.js.map +1 -0
- package/lib/dist/resolution/frameworks/tanstack-router.d.ts +84 -0
- package/lib/dist/resolution/frameworks/tanstack-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/tanstack-router.js +437 -0
- package/lib/dist/resolution/frameworks/tanstack-router.js.map +1 -0
- package/lib/dist/resolution/frameworks/vue-router.d.ts +82 -0
- package/lib/dist/resolution/frameworks/vue-router.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/vue-router.js +377 -0
- package/lib/dist/resolution/frameworks/vue-router.js.map +1 -0
- package/lib/dist/resolution/import-resolver.d.ts +38 -0
- package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
- package/lib/dist/resolution/import-resolver.js +376 -26
- package/lib/dist/resolution/import-resolver.js.map +1 -1
- package/lib/dist/resolution/index.d.ts +89 -25
- package/lib/dist/resolution/index.d.ts.map +1 -1
- package/lib/dist/resolution/index.js +552 -145
- package/lib/dist/resolution/index.js.map +1 -1
- package/lib/dist/resolution/js-builtins.d.ts +13 -0
- package/lib/dist/resolution/js-builtins.d.ts.map +1 -0
- package/lib/dist/resolution/js-builtins.js +46 -0
- package/lib/dist/resolution/js-builtins.js.map +1 -0
- package/lib/dist/resolution/name-matcher.d.ts +69 -22
- package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
- package/lib/dist/resolution/name-matcher.js +1902 -87
- package/lib/dist/resolution/name-matcher.js.map +1 -1
- package/lib/dist/resolution/next-router-synthesizer.d.ts +27 -0
- package/lib/dist/resolution/next-router-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/next-router-synthesizer.js +113 -0
- package/lib/dist/resolution/next-router-synthesizer.js.map +1 -0
- package/lib/dist/resolution/react-router-synthesizer.d.ts +33 -0
- package/lib/dist/resolution/react-router-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/react-router-synthesizer.js +126 -0
- package/lib/dist/resolution/react-router-synthesizer.js.map +1 -0
- package/lib/dist/resolution/resolver-pool.d.ts +2 -0
- package/lib/dist/resolution/resolver-pool.d.ts.map +1 -1
- package/lib/dist/resolution/resolver-pool.js +4 -0
- package/lib/dist/resolution/resolver-pool.js.map +1 -1
- package/lib/dist/resolution/strip-comments.d.ts +6 -0
- package/lib/dist/resolution/strip-comments.d.ts.map +1 -1
- package/lib/dist/resolution/strip-comments.js +58 -0
- package/lib/dist/resolution/strip-comments.js.map +1 -1
- package/lib/dist/resolution/sveltekit-synthesizer.d.ts +58 -0
- package/lib/dist/resolution/sveltekit-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/sveltekit-synthesizer.js +173 -0
- package/lib/dist/resolution/sveltekit-synthesizer.js.map +1 -0
- package/lib/dist/resolution/synth-utils.d.ts +26 -0
- package/lib/dist/resolution/synth-utils.d.ts.map +1 -0
- package/lib/dist/resolution/synth-utils.js +75 -0
- package/lib/dist/resolution/synth-utils.js.map +1 -0
- package/lib/dist/resolution/tanstack-router-synthesizer.d.ts +31 -0
- package/lib/dist/resolution/tanstack-router-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/tanstack-router-synthesizer.js +114 -0
- package/lib/dist/resolution/tanstack-router-synthesizer.js.map +1 -0
- package/lib/dist/resolution/tier-synthesizer.d.ts +49 -0
- package/lib/dist/resolution/tier-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/tier-synthesizer.js +931 -0
- package/lib/dist/resolution/tier-synthesizer.js.map +1 -0
- package/lib/dist/resolution/types.d.ts +78 -2
- package/lib/dist/resolution/types.d.ts.map +1 -1
- package/lib/dist/resolution/types.js +64 -0
- package/lib/dist/resolution/types.js.map +1 -1
- package/lib/dist/resolution/vue-router-synthesizer.d.ts +30 -0
- package/lib/dist/resolution/vue-router-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/vue-router-synthesizer.js +115 -0
- package/lib/dist/resolution/vue-router-synthesizer.js.map +1 -0
- package/lib/dist/search/query-paths.d.ts +50 -1
- package/lib/dist/search/query-paths.d.ts.map +1 -1
- package/lib/dist/search/query-paths.js +227 -12
- package/lib/dist/search/query-paths.js.map +1 -1
- package/lib/dist/search/query-utils.d.ts +15 -0
- package/lib/dist/search/query-utils.d.ts.map +1 -1
- package/lib/dist/search/query-utils.js +35 -7
- package/lib/dist/search/query-utils.js.map +1 -1
- package/lib/dist/sync/watch-policy.d.ts +14 -0
- package/lib/dist/sync/watch-policy.d.ts.map +1 -1
- package/lib/dist/sync/watch-policy.js +19 -0
- package/lib/dist/sync/watch-policy.js.map +1 -1
- package/lib/dist/sync/watcher.d.ts +52 -35
- package/lib/dist/sync/watcher.d.ts.map +1 -1
- package/lib/dist/sync/watcher.js +236 -100
- package/lib/dist/sync/watcher.js.map +1 -1
- package/lib/dist/telemetry/index.d.ts +4 -2
- package/lib/dist/telemetry/index.d.ts.map +1 -1
- package/lib/dist/telemetry/index.js +92 -41
- package/lib/dist/telemetry/index.js.map +1 -1
- package/lib/dist/types.d.ts +1 -1
- package/lib/dist/types.d.ts.map +1 -1
- package/lib/dist/types.js +1 -0
- package/lib/dist/types.js.map +1 -1
- package/lib/dist/ui-server/api/deadcode.d.ts +84 -0
- package/lib/dist/ui-server/api/deadcode.d.ts.map +1 -0
- package/lib/dist/ui-server/api/deadcode.js +136 -0
- package/lib/dist/ui-server/api/deadcode.js.map +1 -0
- package/lib/dist/ui-server/api/effects.d.ts +87 -0
- package/lib/dist/ui-server/api/effects.d.ts.map +1 -0
- package/lib/dist/ui-server/api/effects.js +499 -0
- package/lib/dist/ui-server/api/effects.js.map +1 -0
- package/lib/dist/ui-server/api/entrypoints.d.ts +86 -0
- package/lib/dist/ui-server/api/entrypoints.d.ts.map +1 -0
- package/lib/dist/ui-server/api/entrypoints.js +279 -0
- package/lib/dist/ui-server/api/entrypoints.js.map +1 -0
- package/lib/dist/ui-server/api/events.d.ts +183 -0
- package/lib/dist/ui-server/api/events.d.ts.map +1 -0
- package/lib/dist/ui-server/api/events.js +430 -0
- package/lib/dist/ui-server/api/events.js.map +1 -0
- package/lib/dist/ui-server/api/file.d.ts +66 -0
- package/lib/dist/ui-server/api/file.d.ts.map +1 -0
- package/lib/dist/ui-server/api/file.js +235 -0
- package/lib/dist/ui-server/api/file.js.map +1 -0
- package/lib/dist/ui-server/api/filecode.d.ts +126 -0
- package/lib/dist/ui-server/api/filecode.d.ts.map +1 -0
- package/lib/dist/ui-server/api/filecode.js +205 -0
- package/lib/dist/ui-server/api/filecode.js.map +1 -0
- package/lib/dist/ui-server/api/flow.d.ts +226 -0
- package/lib/dist/ui-server/api/flow.d.ts.map +1 -0
- package/lib/dist/ui-server/api/flow.js +612 -0
- package/lib/dist/ui-server/api/flow.js.map +1 -0
- package/lib/dist/ui-server/api/hierarchy.d.ts +81 -0
- package/lib/dist/ui-server/api/hierarchy.d.ts.map +1 -0
- package/lib/dist/ui-server/api/hierarchy.js +92 -0
- package/lib/dist/ui-server/api/hierarchy.js.map +1 -0
- package/lib/dist/ui-server/api/index.d.ts +90 -0
- package/lib/dist/ui-server/api/index.d.ts.map +1 -0
- package/lib/dist/ui-server/api/index.js +332 -0
- package/lib/dist/ui-server/api/index.js.map +1 -0
- package/lib/dist/ui-server/api/map.d.ts +238 -0
- package/lib/dist/ui-server/api/map.d.ts.map +1 -0
- package/lib/dist/ui-server/api/map.js +681 -0
- package/lib/dist/ui-server/api/map.js.map +1 -0
- package/lib/dist/ui-server/api/node.d.ts +81 -0
- package/lib/dist/ui-server/api/node.d.ts.map +1 -0
- package/lib/dist/ui-server/api/node.js +388 -0
- package/lib/dist/ui-server/api/node.js.map +1 -0
- package/lib/dist/ui-server/api/nodes.d.ts +25 -0
- package/lib/dist/ui-server/api/nodes.d.ts.map +1 -0
- package/lib/dist/ui-server/api/nodes.js +45 -0
- package/lib/dist/ui-server/api/nodes.js.map +1 -0
- package/lib/dist/ui-server/api/program.d.ts +139 -0
- package/lib/dist/ui-server/api/program.d.ts.map +1 -0
- package/lib/dist/ui-server/api/program.js +315 -0
- package/lib/dist/ui-server/api/program.js.map +1 -0
- package/lib/dist/ui-server/api/respond.d.ts +76 -0
- package/lib/dist/ui-server/api/respond.d.ts.map +1 -0
- package/lib/dist/ui-server/api/respond.js +186 -0
- package/lib/dist/ui-server/api/respond.js.map +1 -0
- package/lib/dist/ui-server/api/route-roots.d.ts +39 -0
- package/lib/dist/ui-server/api/route-roots.d.ts.map +1 -0
- package/lib/dist/ui-server/api/route-roots.js +96 -0
- package/lib/dist/ui-server/api/route-roots.js.map +1 -0
- package/lib/dist/ui-server/api/routes.d.ts +59 -0
- package/lib/dist/ui-server/api/routes.d.ts.map +1 -0
- package/lib/dist/ui-server/api/routes.js +108 -0
- package/lib/dist/ui-server/api/routes.js.map +1 -0
- package/lib/dist/ui-server/api/screens.d.ts +117 -0
- package/lib/dist/ui-server/api/screens.d.ts.map +1 -0
- package/lib/dist/ui-server/api/screens.js +611 -0
- package/lib/dist/ui-server/api/screens.js.map +1 -0
- package/lib/dist/ui-server/api/search.d.ts +29 -0
- package/lib/dist/ui-server/api/search.d.ts.map +1 -0
- package/lib/dist/ui-server/api/search.js +232 -0
- package/lib/dist/ui-server/api/search.js.map +1 -0
- package/lib/dist/ui-server/api/session.d.ts +52 -0
- package/lib/dist/ui-server/api/session.d.ts.map +1 -0
- package/lib/dist/ui-server/api/session.js +196 -0
- package/lib/dist/ui-server/api/session.js.map +1 -0
- package/lib/dist/ui-server/api/source.d.ts +200 -0
- package/lib/dist/ui-server/api/source.d.ts.map +1 -0
- package/lib/dist/ui-server/api/source.js +422 -0
- package/lib/dist/ui-server/api/source.js.map +1 -0
- package/lib/dist/ui-server/api/stats.d.ts +27 -0
- package/lib/dist/ui-server/api/stats.d.ts.map +1 -0
- package/lib/dist/ui-server/api/stats.js +164 -0
- package/lib/dist/ui-server/api/stats.js.map +1 -0
- package/lib/dist/ui-server/api/steps.d.ts +274 -0
- package/lib/dist/ui-server/api/steps.d.ts.map +1 -0
- package/lib/dist/ui-server/api/steps.js +1446 -0
- package/lib/dist/ui-server/api/steps.js.map +1 -0
- package/lib/dist/ui-server/api/trail-store.d.ts +142 -0
- package/lib/dist/ui-server/api/trail-store.d.ts.map +1 -0
- package/lib/dist/ui-server/api/trail-store.js +323 -0
- package/lib/dist/ui-server/api/trail-store.js.map +1 -0
- package/lib/dist/ui-server/api/trails.d.ts +163 -0
- package/lib/dist/ui-server/api/trails.d.ts.map +1 -0
- package/lib/dist/ui-server/api/trails.js +369 -0
- package/lib/dist/ui-server/api/trails.js.map +1 -0
- package/lib/dist/ui-server/api/when.d.ts +125 -0
- package/lib/dist/ui-server/api/when.d.ts.map +1 -0
- package/lib/dist/ui-server/api/when.js +251 -0
- package/lib/dist/ui-server/api/when.js.map +1 -0
- package/lib/dist/ui-server/api/wire.d.ts +179 -0
- package/lib/dist/ui-server/api/wire.d.ts.map +1 -0
- package/lib/dist/ui-server/api/wire.js +231 -0
- package/lib/dist/ui-server/api/wire.js.map +1 -0
- package/lib/dist/ui-server/assets.d.ts +40 -0
- package/lib/dist/ui-server/assets.d.ts.map +1 -0
- package/lib/dist/ui-server/assets.js +110 -0
- package/lib/dist/ui-server/assets.js.map +1 -0
- package/lib/dist/ui-server/constants.d.ts +32 -0
- package/lib/dist/ui-server/constants.d.ts.map +1 -0
- package/lib/dist/ui-server/constants.js +35 -0
- package/lib/dist/ui-server/constants.js.map +1 -0
- package/lib/dist/ui-server/highlight/index.d.ts +113 -0
- package/lib/dist/ui-server/highlight/index.d.ts.map +1 -0
- package/lib/dist/ui-server/highlight/index.js +307 -0
- package/lib/dist/ui-server/highlight/index.js.map +1 -0
- package/lib/dist/ui-server/highlight/languages.d.ts +36 -0
- package/lib/dist/ui-server/highlight/languages.d.ts.map +1 -0
- package/lib/dist/ui-server/highlight/languages.js +50 -0
- package/lib/dist/ui-server/highlight/languages.js.map +1 -0
- package/lib/dist/ui-server/index.d.ts +92 -0
- package/lib/dist/ui-server/index.d.ts.map +1 -0
- package/lib/dist/ui-server/index.js +399 -0
- package/lib/dist/ui-server/index.js.map +1 -0
- package/lib/dist/ui-server/open-browser.d.ts +31 -0
- package/lib/dist/ui-server/open-browser.d.ts.map +1 -0
- package/lib/dist/ui-server/open-browser.js +79 -0
- package/lib/dist/ui-server/open-browser.js.map +1 -0
- package/lib/dist/ui-server/security.d.ts +127 -0
- package/lib/dist/ui-server/security.d.ts.map +1 -0
- package/lib/dist/ui-server/security.js +332 -0
- package/lib/dist/ui-server/security.js.map +1 -0
- package/lib/dist/ui-server/static.d.ts +45 -0
- package/lib/dist/ui-server/static.d.ts.map +1 -0
- package/lib/dist/ui-server/static.js +165 -0
- package/lib/dist/ui-server/static.js.map +1 -0
- package/lib/dist/utils.d.ts +14 -2
- package/lib/dist/utils.d.ts.map +1 -1
- package/lib/dist/utils.js +25 -10
- package/lib/dist/utils.js.map +1 -1
- package/lib/dist/viewer/assets/archivo-latin-ext-wght-normal-C4zznr8T.woff2 +0 -0
- package/lib/dist/viewer/assets/archivo-latin-wght-normal-E0tuGl4L.woff2 +0 -0
- package/lib/dist/viewer/assets/archivo-vietnamese-wght-normal-XAtsl5Q_.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-2syK4fUT.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-italic-CBJ8pzag.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-B4oTjJdl.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-italic-CBjNughH.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-italic-66oory27.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-italic-BqAiT5Ww.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-B7_fu1kp.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-italic-Bg0ZHwF4.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-D6eaYXMU.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-italic-DRuN92E5.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
- package/lib/dist/viewer/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
- package/lib/dist/viewer/assets/index-CF9yvio6.css +1 -0
- package/lib/dist/viewer/assets/index-D4S7YUPf.js +97 -0
- package/lib/dist/viewer/index.html +16 -0
- package/lib/kernel/codegraph-kernel.node +2 -2
- package/lib/node_modules/.package-lock.json +4 -4
- package/lib/node_modules/picomatch/README.md +56 -51
- package/lib/node_modules/picomatch/lib/constants.js +4 -0
- package/lib/node_modules/picomatch/lib/parse.js +341 -1
- package/lib/node_modules/picomatch/lib/picomatch.js +25 -5
- package/lib/node_modules/picomatch/lib/scan.js +30 -18
- package/lib/node_modules/picomatch/package.json +4 -4
- package/lib/package.json +9 -2
- package/package.json +1 -1
|
@@ -71,6 +71,19 @@ const RTK_HOOK_NAME_RE = /^use[A-Z][A-Za-z0-9]*(?:Query|Mutation)$/;
|
|
|
71
71
|
/** React HOC callees whose result is itself a component — a PascalCase const
|
|
72
72
|
* initialized with one of these is a component, not a constant (#841). */
|
|
73
73
|
const REACT_COMPONENT_HOCS = new Set(['forwardRef', 'memo', 'React.forwardRef', 'React.memo']);
|
|
74
|
+
/**
|
|
75
|
+
* Method node types that spell a SIGNATURE — a declaration with no body (#1638).
|
|
76
|
+
*
|
|
77
|
+
* They are a method of whatever type declares them and nothing on their own, so
|
|
78
|
+
* they must not take `extractMethod`'s "no class-like parent, so treat it as a
|
|
79
|
+
* free function" fallback. The other `methodTypes` can: a `method_definition`
|
|
80
|
+
* outside a class really is a function. This one appears outside a class only
|
|
81
|
+
* inside a type literal (`type Handle = { stop(): void }`), whose members
|
|
82
|
+
* `extractTypeAlias` already extracts and attaches to the alias (#359) — take
|
|
83
|
+
* the fallback and the file gains a phantom top-level `function stop` beside
|
|
84
|
+
* the real `Handle::stop`.
|
|
85
|
+
*/
|
|
86
|
+
const SIGNATURE_METHOD_NODE_TYPES = new Set(['method_signature']);
|
|
74
87
|
/** Vue store collections whose object-literal members are the symbols an agent
|
|
75
88
|
* looks for. Extracted as function nodes so `actions`/`mutations`/`getters` are
|
|
76
89
|
* findable + readable (the foundation under any later dispatch-bridge synth). */
|
|
@@ -185,7 +198,7 @@ function extractNameRaw(node, source, extractor) {
|
|
|
185
198
|
// not from identifiers in their body. Without this, single-expression arrow
|
|
186
199
|
// functions like `const fn = () => someIdentifier` get named "someIdentifier"
|
|
187
200
|
// instead of "fn", because the fallback below finds the body identifier.
|
|
188
|
-
if (node.type === 'arrow_function' || node.type === 'function_expression') {
|
|
201
|
+
if (node.type === 'arrow_function' || node.type === 'function_expression' || node.type === 'generator_function') {
|
|
189
202
|
return '<anonymous>';
|
|
190
203
|
}
|
|
191
204
|
// Fall back to first identifier child
|
|
@@ -383,12 +396,107 @@ const LITERAL_RECEIVER_TYPES = new Set([
|
|
|
383
396
|
'list', 'list_literal', 'array', 'array_literal', 'array_creation_expression',
|
|
384
397
|
'dictionary', 'dict_literal', 'object', 'tuple', 'set',
|
|
385
398
|
]);
|
|
399
|
+
/**
|
|
400
|
+
* Languages whose member calls go through the TS/JS grammars.
|
|
401
|
+
*/
|
|
402
|
+
const TS_JS_CHAIN_LANGUAGES = new Set(['typescript', 'tsx', 'javascript', 'jsx']);
|
|
403
|
+
/** Receiver node types (TS/JS grammars) that continue a member chain downward. */
|
|
404
|
+
const TS_JS_CHAIN_RECEIVER_TYPES = new Set(['member_expression', 'subscript_expression']);
|
|
405
|
+
/** The field of a `this.<field>.<method>()` receiver: public or ES private (#1496, #1987). */
|
|
406
|
+
const THIS_FIELD_PROPERTY_TYPES = new Set(['property_identifier', 'private_property_identifier']);
|
|
407
|
+
/**
|
|
408
|
+
* Identifier-rooted member chains have no inferred property type (#1566),
|
|
409
|
+
* including host API chains (#1707). Keep the existing `window.MyNamespace`
|
|
410
|
+
* escape for project globals; call-result and `this` receivers have their own
|
|
411
|
+
* paths and are outside this guard.
|
|
412
|
+
*/
|
|
413
|
+
function isUnresolvedTsJsChain(node, source) {
|
|
414
|
+
let cur = node;
|
|
415
|
+
while (cur && TS_JS_CHAIN_RECEIVER_TYPES.has(cur.type)) {
|
|
416
|
+
cur = (0, tree_sitter_helpers_1.getChildByField)(cur, 'object');
|
|
417
|
+
}
|
|
418
|
+
return !!cur && cur.type === 'identifier' && (0, tree_sitter_helpers_1.getNodeText)(cur, source) !== 'window';
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* TS/JS wrappers that leave a member call's receiver the same object:
|
|
422
|
+
* `(x).m()`, `x!.m()`, `(x as T).m()`, `(x satisfies T).m()`, `(<T>x).m()`
|
|
423
|
+
* and `(await x).m()` all call `m` on what `x` holds.
|
|
424
|
+
*/
|
|
425
|
+
const TS_JS_TRANSPARENT_RECEIVER_TYPES = new Set([
|
|
426
|
+
'parenthesized_expression', 'non_null_expression', 'as_expression',
|
|
427
|
+
'satisfies_expression', 'type_assertion', 'await_expression',
|
|
428
|
+
]);
|
|
429
|
+
/**
|
|
430
|
+
* Strip {@link TS_JS_TRANSPARENT_RECEIVER_TYPES} wrappers off a receiver.
|
|
431
|
+
* tree-sitter-typescript parses `a && b!.c()` as `(a && b)!.c()`; the `!`
|
|
432
|
+
* belongs to the right operand, so a non-null over a binary expression peels
|
|
433
|
+
* to that operand.
|
|
434
|
+
*/
|
|
435
|
+
function peelTsJsReceiver(node) {
|
|
436
|
+
let cur = node;
|
|
437
|
+
while (TS_JS_TRANSPARENT_RECEIVER_TYPES.has(cur.type)) {
|
|
438
|
+
let inner = cur.type === 'type_assertion'
|
|
439
|
+
? cur.namedChild(cur.namedChildCount - 1)
|
|
440
|
+
: cur.namedChild(0);
|
|
441
|
+
if (cur.type === 'non_null_expression') {
|
|
442
|
+
while (inner?.type === 'binary_expression')
|
|
443
|
+
inner = (0, tree_sitter_helpers_1.getChildByField)(inner, 'right');
|
|
444
|
+
}
|
|
445
|
+
if (!inner)
|
|
446
|
+
break;
|
|
447
|
+
cur = inner;
|
|
448
|
+
}
|
|
449
|
+
return cur;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Whether a TS/JS receiver still collapses to the bare method name: `this` /
|
|
453
|
+
* `super` (the resolver reads the owner off the enclosing class), a member
|
|
454
|
+
* chain rooted at either or at `window` (the project-global escape of
|
|
455
|
+
* {@link isUnresolvedTsJsChain}), and `new C()` (its class is written at the
|
|
456
|
+
* call).
|
|
457
|
+
*/
|
|
458
|
+
function keepsBareTsJsReceiver(node, source) {
|
|
459
|
+
let cur = node;
|
|
460
|
+
while (cur && TS_JS_CHAIN_RECEIVER_TYPES.has(cur.type)) {
|
|
461
|
+
const object = (0, tree_sitter_helpers_1.getChildByField)(cur, 'object');
|
|
462
|
+
cur = object ? peelTsJsReceiver(object) : null;
|
|
463
|
+
}
|
|
464
|
+
if (!cur)
|
|
465
|
+
return false;
|
|
466
|
+
if (cur.type === 'this' || cur.type === 'super')
|
|
467
|
+
return true;
|
|
468
|
+
if (cur.type === 'identifier')
|
|
469
|
+
return (0, tree_sitter_helpers_1.getNodeText)(cur, source) === 'window';
|
|
470
|
+
return cur === node && cur.type === 'new_expression';
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* React hooks that bind a NAME to a handler function (`const onPress =
|
|
474
|
+
* useCallback(() => {…}, [])`). The arrow inside is extracted as a function
|
|
475
|
+
* node named by the declarator — see `reactHookBoundName`.
|
|
476
|
+
*/
|
|
477
|
+
const REACT_HANDLER_HOOKS = /^(?:React\.)?use(?:Callback|EffectEvent|Event)$/;
|
|
386
478
|
class TreeSitterExtractor {
|
|
479
|
+
/**
|
|
480
|
+
* The node's prose, from either place it can live: a preceding comment
|
|
481
|
+
* sibling (every language) or a docstring inside the body (Python's bare
|
|
482
|
+
* first-statement string, and the same shape in other languages that opt in
|
|
483
|
+
* via `getBodyDocstring`). When a node carries both, they are joined rather
|
|
484
|
+
* than one winning — they are two separate things the author wrote about the
|
|
485
|
+
* same symbol, and the column holds free text (#1905).
|
|
486
|
+
*/
|
|
487
|
+
docstringFor(node) {
|
|
488
|
+
const preceding = (0, tree_sitter_helpers_1.getPrecedingDocstring)(node, this.source);
|
|
489
|
+
const body = this.extractor?.getBodyDocstring?.(node, this.source);
|
|
490
|
+
if (preceding && body)
|
|
491
|
+
return `${preceding}\n\n${body}`;
|
|
492
|
+
return body || preceding;
|
|
493
|
+
}
|
|
387
494
|
filePath;
|
|
388
495
|
language;
|
|
389
496
|
source;
|
|
390
497
|
tree = null;
|
|
391
498
|
nodes = [];
|
|
499
|
+
nodeIds = new tree_sitter_helpers_1.NodeIdAllocator();
|
|
392
500
|
edges = [];
|
|
393
501
|
unresolvedReferences = [];
|
|
394
502
|
// Value-reference edges (default ON; set CODEGRAPH_VALUE_REFS=0 to disable; see flushValueRefs).
|
|
@@ -504,6 +612,9 @@ class TreeSitterExtractor {
|
|
|
504
612
|
isExported: false,
|
|
505
613
|
updatedAt: Date.now(),
|
|
506
614
|
};
|
|
615
|
+
const fileDocstring = this.extractor?.getBodyDocstring?.(this.tree.rootNode, this.source);
|
|
616
|
+
if (fileDocstring)
|
|
617
|
+
fileNode.docstring = fileDocstring;
|
|
507
618
|
this.nodes.push(fileNode);
|
|
508
619
|
// Push file node onto stack so top-level declarations get contains edges
|
|
509
620
|
this.nodeStack.push(fileNode.id);
|
|
@@ -522,6 +633,16 @@ class TreeSitterExtractor {
|
|
|
522
633
|
if (packageNodeId)
|
|
523
634
|
this.nodeStack.pop();
|
|
524
635
|
this.nodeStack.pop();
|
|
636
|
+
// hasError is routine for several grammars; warn only when no symbols survived.
|
|
637
|
+
const symbolCount = this.nodes.filter((n) => n.kind !== 'file').length;
|
|
638
|
+
if (this.tree?.rootNode.hasError && symbolCount === 0) {
|
|
639
|
+
this.errors.push({
|
|
640
|
+
message: `${this.filePath}: parse produced no symbols (tree has errors) — ` +
|
|
641
|
+
`the file is indexed but contributes nothing to the graph`,
|
|
642
|
+
severity: 'warning',
|
|
643
|
+
code: 'parse_error',
|
|
644
|
+
});
|
|
645
|
+
}
|
|
525
646
|
}
|
|
526
647
|
catch (error) {
|
|
527
648
|
const msg = error instanceof Error ? error.message : String(error);
|
|
@@ -587,6 +708,7 @@ class TreeSitterExtractor {
|
|
|
587
708
|
return;
|
|
588
709
|
const nodeType = node.type;
|
|
589
710
|
if (depth > 0 && (this.extractor?.functionTypes.includes(nodeType) ||
|
|
711
|
+
((this.language === 'lua' || this.language === 'luau') && nodeType === 'function_definition') ||
|
|
590
712
|
nodeType === 'arrow_function' ||
|
|
591
713
|
nodeType === 'function_expression' ||
|
|
592
714
|
nodeType === 'lambda_literal' ||
|
|
@@ -948,6 +1070,25 @@ class TreeSitterExtractor {
|
|
|
948
1070
|
if (skipChildren)
|
|
949
1071
|
return;
|
|
950
1072
|
}
|
|
1073
|
+
if (this.language === 'cpp' && (0, c_cpp_1.isCppConstructorDeclaration)(node)) {
|
|
1074
|
+
this.extractMethod(node);
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
// C/C++ function-like macros (`#define TRACE(x) ...`) become `constant`
|
|
1078
|
+
// nodes carrying the directive as their signature. A macro is a value,
|
|
1079
|
+
// never an executable callee: the resolver reads these to recognize a
|
|
1080
|
+
// call whose name is a macro visible in the translation unit and refuses
|
|
1081
|
+
// to bind it to a same-named function elsewhere (#1838). Mirrored in the
|
|
1082
|
+
// kernel (ccpp/mod.rs visit_node).
|
|
1083
|
+
if ((this.language === 'c' || this.language === 'cpp') && nodeType === 'preproc_function_def') {
|
|
1084
|
+
const name = (0, tree_sitter_helpers_1.getChildByField)(node, 'name');
|
|
1085
|
+
if (name) {
|
|
1086
|
+
this.createNode('constant', (0, tree_sitter_helpers_1.getNodeText)(name, this.source), node, {
|
|
1087
|
+
signature: (0, tree_sitter_helpers_1.getNodeText)(node, this.source).trim(),
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
951
1092
|
// C++ namespace blocks: carry the namespace name as a qualifiedName prefix
|
|
952
1093
|
// while walking the body, so `namespace flash { void compute_attn(); }`
|
|
953
1094
|
// indexes compute_attn with qualifiedName `flash::compute_attn` and a
|
|
@@ -1006,6 +1147,9 @@ class TreeSitterExtractor {
|
|
|
1006
1147
|
else if (classification === 'trait') {
|
|
1007
1148
|
this.extractClass(node, 'trait');
|
|
1008
1149
|
}
|
|
1150
|
+
else if (classification === 'module') {
|
|
1151
|
+
this.extractClass(node, 'module');
|
|
1152
|
+
}
|
|
1009
1153
|
else {
|
|
1010
1154
|
this.extractClass(node);
|
|
1011
1155
|
}
|
|
@@ -1016,12 +1160,23 @@ class TreeSitterExtractor {
|
|
|
1016
1160
|
this.extractClass(node);
|
|
1017
1161
|
skipChildren = true;
|
|
1018
1162
|
}
|
|
1019
|
-
// Check for method declarations (only if not already handled by functionTypes)
|
|
1020
|
-
|
|
1163
|
+
// Check for method declarations (only if not already handled by functionTypes).
|
|
1164
|
+
// A bodiless SIGNATURE only counts as one where a type declares it — see
|
|
1165
|
+
// SIGNATURE_METHOD_NODE_TYPES for what falling through would otherwise mint.
|
|
1166
|
+
else if (this.extractor.methodTypes.includes(nodeType)
|
|
1167
|
+
&& (!(TS_JS_CHAIN_LANGUAGES.has(this.language) || this.language === 'arkts')
|
|
1168
|
+
|| !SIGNATURE_METHOD_NODE_TYPES.has(nodeType) || this.isInsideClassLikeNode())) {
|
|
1021
1169
|
// TS/JS class fields parse as a methodTypes node; only function-valued
|
|
1022
1170
|
// fields are methods — a plain field (`public fonts: Fonts;`) is a
|
|
1023
|
-
// property (#808).
|
|
1024
|
-
|
|
1171
|
+
// property (#808). C++ lists `field_declaration` so pure-virtual methods
|
|
1172
|
+
// mint nodes (#1727); non-callable ones return 'skip' and fall through to
|
|
1173
|
+
// the children walk. classifyMethodNode is absent for other languages.
|
|
1174
|
+
const methodClass = this.extractor.classifyMethodNode?.(node) ?? 'method';
|
|
1175
|
+
if (methodClass === 'skip') {
|
|
1176
|
+
// Not a method — leave skipChildren false so data-member initializers
|
|
1177
|
+
// still contribute call/instantiation edges under the enclosing class.
|
|
1178
|
+
}
|
|
1179
|
+
else if (methodClass === 'property') {
|
|
1025
1180
|
const propNode = this.extractProperty(node);
|
|
1026
1181
|
// Walk the initializer so its calls/instantiations attribute to the
|
|
1027
1182
|
// property (`history = createHistory()` → history calls
|
|
@@ -1264,20 +1419,16 @@ class TreeSitterExtractor {
|
|
|
1264
1419
|
else if (nodeType === 'impl_item') {
|
|
1265
1420
|
this.extractRustImplItem(node);
|
|
1266
1421
|
}
|
|
1267
|
-
//
|
|
1268
|
-
//
|
|
1269
|
-
//
|
|
1270
|
-
//
|
|
1271
|
-
//
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
this.extractTypeAnnotations(node, parentId);
|
|
1278
|
-
}
|
|
1279
|
-
// don't skipChildren — nested signatures still need traversal
|
|
1280
|
-
}
|
|
1422
|
+
// NOTE: `property_signature` / `method_signature` used to be handled here,
|
|
1423
|
+
// hanging their type annotations off the ENCLOSING INTERFACE — the only
|
|
1424
|
+
// anchor available while the members themselves went unextracted. Since
|
|
1425
|
+
// #1638 they are in the TS extractor's `methodTypes` / `propertyTypes`, so
|
|
1426
|
+
// the branches above claim them first (under the same `isInsideClassLikeNode`
|
|
1427
|
+
// guard this branch had, so nothing it used to reach is now missed) and this
|
|
1428
|
+
// one was dead. The `references` edges survive — `extractMethod` and
|
|
1429
|
+
// `extractProperty` each call `extractTypeAnnotations` — but now hang off
|
|
1430
|
+
// the member, which is the more precise anchor: `Api::fetch → PageId` says
|
|
1431
|
+
// which member wants the type, where `Api → PageId` only said the file did.
|
|
1281
1432
|
// Visit children (unless the extract method already visited them)
|
|
1282
1433
|
if (!skipChildren) {
|
|
1283
1434
|
for (let i = 0; i < node.namedChildCount; i++) {
|
|
@@ -1297,7 +1448,7 @@ class TreeSitterExtractor {
|
|
|
1297
1448
|
if (!name) {
|
|
1298
1449
|
return null;
|
|
1299
1450
|
}
|
|
1300
|
-
const id =
|
|
1451
|
+
const id = this.nodeIds.generate(this.filePath, kind, name, node.startPosition.row + 1, node.startPosition.column);
|
|
1301
1452
|
// Some grammars (e.g. Dart) model a function/method body as a *sibling* of
|
|
1302
1453
|
// the signature node, so the declaration node's own range is just the
|
|
1303
1454
|
// signature line. Extend endLine to the resolved body when it sits beyond
|
|
@@ -1499,13 +1650,15 @@ class TreeSitterExtractor {
|
|
|
1499
1650
|
// — SvelteKit actions). Inline-object arrows reached by the general walker
|
|
1500
1651
|
// get no override, so they still fall through to the <anonymous> skip below.
|
|
1501
1652
|
let name = nameOverride ?? extractName(node, this.source, this.extractor);
|
|
1653
|
+
// A CommonJS export assignment names the function it holds — see below.
|
|
1654
|
+
let commonJsExport = false;
|
|
1502
1655
|
// For arrow functions and function expressions assigned to variables,
|
|
1503
1656
|
// resolve the name from the parent variable_declarator.
|
|
1504
1657
|
// e.g. `export const useAuth = () => { ... }` — the arrow_function node
|
|
1505
1658
|
// has no `name` field; the name lives on the variable_declarator.
|
|
1506
1659
|
if (!nameOverride &&
|
|
1507
1660
|
name === '<anonymous>' &&
|
|
1508
|
-
(node.type === 'arrow_function' || node.type === 'function_expression')) {
|
|
1661
|
+
(node.type === 'arrow_function' || node.type === 'function_expression' || node.type === 'generator_function')) {
|
|
1509
1662
|
const parent = node.parent;
|
|
1510
1663
|
if (parent?.type === 'variable_declarator') {
|
|
1511
1664
|
const varName = (0, tree_sitter_helpers_1.getChildByField)(parent, 'name');
|
|
@@ -1513,6 +1666,19 @@ class TreeSitterExtractor {
|
|
|
1513
1666
|
name = (0, tree_sitter_helpers_1.getNodeText)(varName, this.source);
|
|
1514
1667
|
}
|
|
1515
1668
|
}
|
|
1669
|
+
else if (parent?.type === 'assignment_expression') {
|
|
1670
|
+
// `exports.getItems = async (req, res) => {…}` / `module.exports.x =
|
|
1671
|
+
// function () {…}` — the CommonJS controller style. The function is
|
|
1672
|
+
// anonymous only syntactically: the export property is the name every
|
|
1673
|
+
// `router.get('/items', getItems)` resolves. Without a node the handler
|
|
1674
|
+
// is invisible to callers/impact and its calls attribute to the file
|
|
1675
|
+
// (#1675). Same treatment `const X = () => {}` already gets.
|
|
1676
|
+
const exportName = this.commonJsExportName(parent, node);
|
|
1677
|
+
if (exportName) {
|
|
1678
|
+
name = exportName;
|
|
1679
|
+
commonJsExport = true;
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1516
1682
|
}
|
|
1517
1683
|
if (name === '<anonymous>') {
|
|
1518
1684
|
// Don't emit a node for the anonymous wrapper itself, but still visit its
|
|
@@ -1537,10 +1703,10 @@ class TreeSitterExtractor {
|
|
|
1537
1703
|
}
|
|
1538
1704
|
return;
|
|
1539
1705
|
}
|
|
1540
|
-
const docstring =
|
|
1706
|
+
const docstring = this.docstringFor(node);
|
|
1541
1707
|
const signature = this.extractor.getSignature?.(node, this.source);
|
|
1542
1708
|
const visibility = this.extractor.getVisibility?.(node);
|
|
1543
|
-
const isExported = this.extractor.isExported?.(node, this.source);
|
|
1709
|
+
const isExported = commonJsExport || this.extractor.isExported?.(node, this.source);
|
|
1544
1710
|
const isAsync = this.extractor.isAsync?.(node);
|
|
1545
1711
|
const isStatic = this.extractor.isStatic?.(node);
|
|
1546
1712
|
const returnType = this.extractor.getReturnType?.(node, this.source);
|
|
@@ -1650,7 +1816,7 @@ class TreeSitterExtractor {
|
|
|
1650
1816
|
if (this.extractor.skipBodilessClass && !resolvedBody)
|
|
1651
1817
|
return;
|
|
1652
1818
|
const name = extractName(node, this.source, this.extractor);
|
|
1653
|
-
const docstring =
|
|
1819
|
+
const docstring = this.docstringFor(node);
|
|
1654
1820
|
const visibility = this.extractor.getVisibility?.(node);
|
|
1655
1821
|
const isExported = this.extractor.isExported?.(node, this.source);
|
|
1656
1822
|
const classNode = this.createNode(kind, name, node, {
|
|
@@ -1722,11 +1888,14 @@ class TreeSitterExtractor {
|
|
|
1722
1888
|
}
|
|
1723
1889
|
return;
|
|
1724
1890
|
}
|
|
1725
|
-
const docstring =
|
|
1891
|
+
const docstring = this.docstringFor(node);
|
|
1726
1892
|
const signature = this.extractor.getSignature?.(node, this.source);
|
|
1727
1893
|
const visibility = this.extractor.getVisibility?.(node);
|
|
1728
1894
|
const isAsync = this.extractor.isAsync?.(node);
|
|
1729
1895
|
const isStatic = this.extractor.isStatic?.(node);
|
|
1896
|
+
// Only persist abstract when true — a false return must not mint `isAbstract: false`
|
|
1897
|
+
// on every ordinary method (breaks kernel↔wasm parity JSON equality).
|
|
1898
|
+
const isAbstract = this.extractor.isAbstract?.(node) ? true : undefined;
|
|
1730
1899
|
const returnType = this.extractor.getReturnType?.(node, this.source);
|
|
1731
1900
|
const extraProps = {
|
|
1732
1901
|
docstring,
|
|
@@ -1734,6 +1903,7 @@ class TreeSitterExtractor {
|
|
|
1734
1903
|
visibility,
|
|
1735
1904
|
isAsync,
|
|
1736
1905
|
isStatic,
|
|
1906
|
+
isAbstract,
|
|
1737
1907
|
returnType,
|
|
1738
1908
|
};
|
|
1739
1909
|
if (receiverType) {
|
|
@@ -1776,7 +1946,7 @@ class TreeSitterExtractor {
|
|
|
1776
1946
|
if (!this.extractor)
|
|
1777
1947
|
return;
|
|
1778
1948
|
const name = extractName(node, this.source, this.extractor);
|
|
1779
|
-
const docstring =
|
|
1949
|
+
const docstring = this.docstringFor(node);
|
|
1780
1950
|
const isExported = this.extractor.isExported?.(node, this.source);
|
|
1781
1951
|
const kind = this.extractor.interfaceKind ?? 'interface';
|
|
1782
1952
|
const interfaceNode = this.createNode(kind, name, node, {
|
|
@@ -1818,11 +1988,18 @@ class TreeSitterExtractor {
|
|
|
1818
1988
|
// Skip forward declarations and type references (no body = not a definition)
|
|
1819
1989
|
// — EXCEPT C# positional records (`record struct M(decimal Amount);`),
|
|
1820
1990
|
// complete definitions with no body block. (#831)
|
|
1991
|
+
//
|
|
1992
|
+
// `allowBodilessStruct` is the per-language escape hatch for the same
|
|
1993
|
+
// situation: a bodiless struct that IS a complete definition (Rust's unit
|
|
1994
|
+
// struct `struct Unit;`). Opposite polarity from `skipBodilessClass`
|
|
1995
|
+
// (#1093) because the two defaults differ — a bodiless CLASS is kept
|
|
1996
|
+
// unless a language opts into skipping, a bodiless STRUCT is skipped
|
|
1997
|
+
// unless a language opts into keeping.
|
|
1821
1998
|
const body = (0, tree_sitter_helpers_1.getChildByField)(node, this.extractor.bodyField);
|
|
1822
|
-
if (!body && node.type !== 'record_declaration')
|
|
1999
|
+
if (!body && node.type !== 'record_declaration' && !this.extractor.allowBodilessStruct)
|
|
1823
2000
|
return;
|
|
1824
2001
|
const name = extractName(node, this.source, this.extractor);
|
|
1825
|
-
const docstring =
|
|
2002
|
+
const docstring = this.docstringFor(node);
|
|
1826
2003
|
const visibility = this.extractor.getVisibility?.(node);
|
|
1827
2004
|
const isExported = this.extractor.isExported?.(node, this.source);
|
|
1828
2005
|
const aggregateNode = this.createNode(kind, name, node, {
|
|
@@ -1862,7 +2039,7 @@ class TreeSitterExtractor {
|
|
|
1862
2039
|
if (!body)
|
|
1863
2040
|
return;
|
|
1864
2041
|
const name = extractName(node, this.source, this.extractor);
|
|
1865
|
-
const docstring =
|
|
2042
|
+
const docstring = this.docstringFor(node);
|
|
1866
2043
|
const visibility = this.extractor.getVisibility?.(node);
|
|
1867
2044
|
const isExported = this.extractor.isExported?.(node, this.source);
|
|
1868
2045
|
const enumNode = this.createNode('enum', name, node, {
|
|
@@ -1922,7 +2099,7 @@ class TreeSitterExtractor {
|
|
|
1922
2099
|
extractProperty(node) {
|
|
1923
2100
|
if (!this.extractor)
|
|
1924
2101
|
return null;
|
|
1925
|
-
const docstring =
|
|
2102
|
+
const docstring = this.docstringFor(node);
|
|
1926
2103
|
const visibility = this.extractor.getVisibility?.(node);
|
|
1927
2104
|
const isStatic = this.extractor.isStatic?.(node) ?? false;
|
|
1928
2105
|
const hookName = this.extractor.extractPropertyName?.(node, this.source);
|
|
@@ -1941,7 +2118,17 @@ class TreeSitterExtractor {
|
|
|
1941
2118
|
// and the initializer VALUE, which the generic finder below would
|
|
1942
2119
|
// wrongly pick — so fields use the type field only (#808). Other
|
|
1943
2120
|
// languages (C# property_declaration) keep the generic scan.
|
|
1944
|
-
|
|
2121
|
+
//
|
|
2122
|
+
// A `property_signature` (an interface member, #1638) carries a `type`
|
|
2123
|
+
// field and no value, so it reads the type field too. It cannot take the
|
|
2124
|
+
// generic scan: that scan's exclusion list covers `identifier` but not the
|
|
2125
|
+
// `property_identifier` an interface member is named with, so it stops on
|
|
2126
|
+
// the name and `interface Stats { counts: Record<string, number> }` yields
|
|
2127
|
+
// `signature: "counts counts"` instead of the type. Named explicitly
|
|
2128
|
+
// rather than folded into the field test so no other language's
|
|
2129
|
+
// `property_declaration` moves off the generic scan.
|
|
2130
|
+
const isTsJsField = node.type === 'public_field_definition' || node.type === 'field_definition'
|
|
2131
|
+
|| node.type === 'property_signature';
|
|
1945
2132
|
const typeNode = isTsJsField
|
|
1946
2133
|
? (0, tree_sitter_helpers_1.getChildByField)(node, 'type')
|
|
1947
2134
|
: node.namedChildren.find(c => c.type !== 'modifier' && c.type !== 'modifiers'
|
|
@@ -1975,7 +2162,7 @@ class TreeSitterExtractor {
|
|
|
1975
2162
|
extractField(node) {
|
|
1976
2163
|
if (!this.extractor)
|
|
1977
2164
|
return;
|
|
1978
|
-
const docstring =
|
|
2165
|
+
const docstring = this.docstringFor(node);
|
|
1979
2166
|
const visibility = this.extractor.getVisibility?.(node);
|
|
1980
2167
|
const isStatic = this.extractor.isStatic?.(node) ?? false;
|
|
1981
2168
|
// A class field that is actually a CONSTANT (Java `static final`, C# `const`
|
|
@@ -2055,6 +2242,21 @@ class TreeSitterExtractor {
|
|
|
2055
2242
|
// and the language-aware path in `extractTypeAnnotations` descends
|
|
2056
2243
|
// into that wrapper (#381).
|
|
2057
2244
|
this.extractTypeAnnotations(node, fieldNode.id);
|
|
2245
|
+
// Walk the initializer ATTRIBUTED to the declared field (#693, the
|
|
2246
|
+
// Go fix; same shape as the TS/JS class-field walk above). The
|
|
2247
|
+
// dispatcher only scanned this subtree for function-as-value
|
|
2248
|
+
// candidates, so a lambda / method reference / anonymous class in
|
|
2249
|
+
// `private final Runnable r = () -> target();` contributed NO call
|
|
2250
|
+
// edge at all and `target` looked callerless. Keyed on the `value`
|
|
2251
|
+
// FIELD, which only Java's `variable_declarator` carries — C#,
|
|
2252
|
+
// VB.NET and PHP spell their initializer differently and are
|
|
2253
|
+
// deliberately untouched here.
|
|
2254
|
+
const valueNode = (0, tree_sitter_helpers_1.getChildByField)(decl, 'value');
|
|
2255
|
+
if (valueNode) {
|
|
2256
|
+
this.nodeStack.push(fieldNode.id);
|
|
2257
|
+
this.visitFunctionBody(valueNode, fieldNode.id);
|
|
2258
|
+
this.nodeStack.pop();
|
|
2259
|
+
}
|
|
2058
2260
|
}
|
|
2059
2261
|
}
|
|
2060
2262
|
}
|
|
@@ -2090,6 +2292,13 @@ class TreeSitterExtractor {
|
|
|
2090
2292
|
if (key && value && (value.type === 'arrow_function' || value.type === 'function_expression')) {
|
|
2091
2293
|
this.extractFunction(value, this.objectKeyName(key));
|
|
2092
2294
|
}
|
|
2295
|
+
else if (value?.type === 'call_expression') {
|
|
2296
|
+
// `key: Effect.fn("…")(function* () {…})` — see curriedWrapperBoundName.
|
|
2297
|
+
const fn = (0, tree_sitter_helpers_1.getChildByField)(value, 'arguments')?.namedChild(0);
|
|
2298
|
+
const bound = fn ? this.curriedWrapperBoundName(fn) : null;
|
|
2299
|
+
if (fn && bound)
|
|
2300
|
+
this.extractFunction(fn, bound);
|
|
2301
|
+
}
|
|
2093
2302
|
}
|
|
2094
2303
|
else if (member.type === 'method_definition') {
|
|
2095
2304
|
// Method shorthand: `{ fetchUser() {...} }`. extractMethod deliberately
|
|
@@ -2102,6 +2311,21 @@ class TreeSitterExtractor {
|
|
|
2102
2311
|
}
|
|
2103
2312
|
}
|
|
2104
2313
|
}
|
|
2314
|
+
/**
|
|
2315
|
+
* A top-level binding exported by a LATER statement rather than at its
|
|
2316
|
+
* declaration: `export default NAME`, `export { NAME }`, `export { NAME as
|
|
2317
|
+
* default }`. The declaration's own `isExported` (an `export_statement`
|
|
2318
|
+
* ancestor) cannot see these, so a store written as `const useStore =
|
|
2319
|
+
* create(…)` + `export default useStore` read as unexported and its actions
|
|
2320
|
+
* were never extracted. One anchored regex over the file source; JS-family
|
|
2321
|
+
* callers only.
|
|
2322
|
+
*/
|
|
2323
|
+
isExportedLater(name) {
|
|
2324
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(name))
|
|
2325
|
+
return false;
|
|
2326
|
+
const re = new RegExp(`^[ \\t]*export\\s+(?:default\\s+${name}\\s*;?[ \\t]*$|\\{[^}]*\\b${name}\\b[^}]*\\})`, 'm');
|
|
2327
|
+
return re.test(this.source);
|
|
2328
|
+
}
|
|
2105
2329
|
/** Property-key text with surrounding quotes stripped (`'foo'` → `foo`). */
|
|
2106
2330
|
objectKeyName(key) {
|
|
2107
2331
|
return (0, tree_sitter_helpers_1.getNodeText)(key, this.source).replace(/^['"`]|['"`]$/g, '');
|
|
@@ -2506,7 +2730,7 @@ class TreeSitterExtractor {
|
|
|
2506
2730
|
// Go: var_declaration, short_var_declaration, const_declaration
|
|
2507
2731
|
const isConst = this.extractor.isConst?.(node) ?? false;
|
|
2508
2732
|
const kind = isConst ? 'constant' : 'variable';
|
|
2509
|
-
const docstring =
|
|
2733
|
+
const docstring = this.docstringFor(node);
|
|
2510
2734
|
const isExported = this.extractor.isExported?.(node, this.source) ?? false;
|
|
2511
2735
|
// Extract variable declarators based on language
|
|
2512
2736
|
if (this.language === 'typescript' || this.language === 'javascript' ||
|
|
@@ -2534,7 +2758,7 @@ class TreeSitterExtractor {
|
|
|
2534
2758
|
}
|
|
2535
2759
|
const name = (0, tree_sitter_helpers_1.getNodeText)(nameNode, this.source);
|
|
2536
2760
|
// Arrow functions / function expressions: extract as function instead of variable
|
|
2537
|
-
if (valueNode && (valueNode.type === 'arrow_function' || valueNode.type === 'function_expression')) {
|
|
2761
|
+
if (valueNode && (valueNode.type === 'arrow_function' || valueNode.type === 'function_expression' || valueNode.type === 'generator_function')) {
|
|
2538
2762
|
this.extractFunction(valueNode);
|
|
2539
2763
|
continue;
|
|
2540
2764
|
}
|
|
@@ -2584,7 +2808,10 @@ class TreeSitterExtractor {
|
|
|
2584
2808
|
// never nodes — so `node`/`callers` on `fetchUser` return "not
|
|
2585
2809
|
// found" and the agent Reads the store to reconstruct the flow.
|
|
2586
2810
|
// Scoped to EXPORTED consts to exclude inline-object noise
|
|
2587
|
-
// (`ctx.set({...})`) the object-method skip deliberately avoids
|
|
2811
|
+
// (`ctx.set({...})`) the object-method skip deliberately avoids —
|
|
2812
|
+
// where "exported" includes the two-statement form `const useStore
|
|
2813
|
+
// = create(…)` … `export default useStore` (see isExportedLater),
|
|
2814
|
+
// the shape most React Native stores are written in.
|
|
2588
2815
|
const objectOfFns = valueNode && (valueNode.type === 'object' || valueNode.type === 'object_expression')
|
|
2589
2816
|
? valueNode
|
|
2590
2817
|
: valueNode?.type === 'call_expression'
|
|
@@ -2596,7 +2823,7 @@ class TreeSitterExtractor {
|
|
|
2596
2823
|
// whose functions are body-local consts — it must fall through to a
|
|
2597
2824
|
// normal body walk (extracting those consts), not be skipped here.
|
|
2598
2825
|
const hasInlineFns = !!objectOfFns && this.objectHasInlineFunctions(objectOfFns);
|
|
2599
|
-
const extractObjectMethods = isExported && !!objectOfFns && hasInlineFns;
|
|
2826
|
+
const extractObjectMethods = (isExported || this.isExportedLater(name)) && !!objectOfFns && hasInlineFns;
|
|
2600
2827
|
// RTK Query: `createApi`/`injectEndpoints` define endpoints as
|
|
2601
2828
|
// object-literal properties whose values are `build.query/mutation(...)`
|
|
2602
2829
|
// calls — nested under an `endpoints` arrow, so neither the
|
|
@@ -2623,19 +2850,25 @@ class TreeSitterExtractor {
|
|
|
2623
2850
|
VUE_STORE_COLLECTION_NAMES.has(name) && this.looksLikeVueStoreFile()) {
|
|
2624
2851
|
storeCollections.push(objectOfFns);
|
|
2625
2852
|
}
|
|
2626
|
-
// Visit the initializer body for calls
|
|
2627
|
-
//
|
|
2628
|
-
// / createApi / store-collection
|
|
2629
|
-
//
|
|
2630
|
-
//
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2853
|
+
// Visit the initializer body for calls, ATTRIBUTED to the declared
|
|
2854
|
+
// symbol (#693) — EXCEPT the shapes whose members are extracted
|
|
2855
|
+
// one-by-one below (the store-factory / createApi / store-collection
|
|
2856
|
+
// objects), where walking the whole initializer would re-visit each
|
|
2857
|
+
// member arrow and double-count its calls.
|
|
2858
|
+
//
|
|
2859
|
+
// Two things were wrong here before. The walk ran with only the FILE
|
|
2860
|
+
// on the stack, so `const cfg = load()` recorded the FILE as load's
|
|
2861
|
+
// caller — the exact leak Go's #693 fixed. And an object literal was
|
|
2862
|
+
// skipped outright, so `const obj = { handler: () => target() }`
|
|
2863
|
+
// contributed nothing at all unless the const was exported (only then
|
|
2864
|
+
// does extractObjectLiteralFunctions mint the members).
|
|
2865
|
+
const membersExtractedSeparately = extractObjectMethods || !!rtkEndpoints || !!piniaSetup || storeCollections.length > 0;
|
|
2866
|
+
if (valueNode && !membersExtractedSeparately) {
|
|
2867
|
+
if (varNode)
|
|
2868
|
+
this.nodeStack.push(varNode.id);
|
|
2638
2869
|
this.visitFunctionBody(valueNode, '');
|
|
2870
|
+
if (varNode)
|
|
2871
|
+
this.nodeStack.pop();
|
|
2639
2872
|
}
|
|
2640
2873
|
if (extractObjectMethods && objectOfFns) {
|
|
2641
2874
|
this.extractObjectLiteralFunctions(objectOfFns);
|
|
@@ -2659,17 +2892,32 @@ class TreeSitterExtractor {
|
|
|
2659
2892
|
const right = (0, tree_sitter_helpers_1.getChildByField)(node, 'right') || node.namedChild(1);
|
|
2660
2893
|
// Ruby constant assignments (`MAX = 3`) have a `constant`-typed LHS, not
|
|
2661
2894
|
// `identifier`; without this they were never extracted as symbols at all.
|
|
2895
|
+
let assigned = null;
|
|
2662
2896
|
if (left && (left.type === 'identifier' || left.type === 'constant')) {
|
|
2663
2897
|
const name = (0, tree_sitter_helpers_1.getNodeText)(left, this.source);
|
|
2664
2898
|
// Skip if name starts with lowercase and looks like a function call result
|
|
2665
2899
|
// Python constants are usually UPPER_CASE
|
|
2666
2900
|
const initValue = right ? (0, tree_sitter_helpers_1.getNodeText)(right, this.source).slice(0, 100) : undefined;
|
|
2667
2901
|
const initSignature = initValue ? `= ${initValue}${initValue.length >= 100 ? '...' : ''}` : undefined;
|
|
2668
|
-
this.createNode(kind, name, node, {
|
|
2902
|
+
assigned = this.createNode(kind, name, node, {
|
|
2669
2903
|
docstring,
|
|
2670
2904
|
signature: initSignature,
|
|
2671
2905
|
});
|
|
2672
2906
|
}
|
|
2907
|
+
// Walk the initializer ATTRIBUTED to the assigned name (#693). A
|
|
2908
|
+
// module-level `app = FastAPI()` / `ENGINE = create_engine(url)` /
|
|
2909
|
+
// `handler = lambda: run()` dropped every call on the right-hand side, so
|
|
2910
|
+
// whatever the module builds at import time linked to nothing. A tuple
|
|
2911
|
+
// target (`a, b = f(), g()`) mints no symbol, so its RHS is walked at the
|
|
2912
|
+
// enclosing scope rather than lost. Python only: Ruby shares this branch
|
|
2913
|
+
// and gets its own turn.
|
|
2914
|
+
if (this.language === 'python' && right) {
|
|
2915
|
+
if (assigned)
|
|
2916
|
+
this.nodeStack.push(assigned.id);
|
|
2917
|
+
this.visitFunctionBody(right, '');
|
|
2918
|
+
if (assigned)
|
|
2919
|
+
this.nodeStack.pop();
|
|
2920
|
+
}
|
|
2673
2921
|
}
|
|
2674
2922
|
else if (this.language === 'go') {
|
|
2675
2923
|
// Go: var_declaration, short_var_declaration, const_declaration
|
|
@@ -2735,15 +2983,26 @@ class TreeSitterExtractor {
|
|
|
2735
2983
|
const varList = assign.namedChildren.find((c) => c.type === 'variable_list');
|
|
2736
2984
|
const exprList = assign.namedChildren.find((c) => c.type === 'expression_list');
|
|
2737
2985
|
const values = exprList ? exprList.namedChildren : [];
|
|
2738
|
-
const
|
|
2739
|
-
|
|
2740
|
-
const name = (0, tree_sitter_helpers_1.getNodeText)(nameNode, this.source);
|
|
2741
|
-
if (!name)
|
|
2742
|
-
return;
|
|
2986
|
+
const targets = varList ? varList.namedChildren : [];
|
|
2987
|
+
targets.forEach((nameNode, i) => {
|
|
2743
2988
|
const valueNode = values[i];
|
|
2989
|
+
const target = this.luaAssignmentTarget(nameNode);
|
|
2990
|
+
if (!target)
|
|
2991
|
+
return;
|
|
2992
|
+
if (valueNode?.type === 'function_definition') {
|
|
2993
|
+
this.extractLuaFunctionValue(valueNode, target.name, target.receiver, docstring);
|
|
2994
|
+
return;
|
|
2995
|
+
}
|
|
2996
|
+
if (valueNode?.type === 'table_constructor') {
|
|
2997
|
+
this.extractLuaTableFunctions(valueNode, target.fullName);
|
|
2998
|
+
}
|
|
2999
|
+
// A dotted assignment updates a table member; it is not a standalone
|
|
3000
|
+
// variable node. Function-valued members were handled above.
|
|
3001
|
+
if (target.receiver || node.type === 'assignment_statement')
|
|
3002
|
+
return;
|
|
2744
3003
|
const initValue = valueNode ? (0, tree_sitter_helpers_1.getNodeText)(valueNode, this.source).slice(0, 100) : undefined;
|
|
2745
3004
|
const initSignature = initValue ? `= ${initValue}${initValue.length >= 100 ? '...' : ''}` : undefined;
|
|
2746
|
-
this.createNode(kind, name, nameNode, { docstring, signature: initSignature, isExported });
|
|
3005
|
+
this.createNode(kind, target.name, nameNode, { docstring, signature: initSignature, isExported });
|
|
2747
3006
|
});
|
|
2748
3007
|
}
|
|
2749
3008
|
else if (this.language === 'c') {
|
|
@@ -2808,6 +3067,8 @@ class TreeSitterExtractor {
|
|
|
2808
3067
|
else {
|
|
2809
3068
|
// Generic fallback for other languages
|
|
2810
3069
|
// Try to find identifier children
|
|
3070
|
+
const nameField = (0, tree_sitter_helpers_1.getChildByField)(node, 'name');
|
|
3071
|
+
let declared = null;
|
|
2811
3072
|
for (let i = 0; i < node.namedChildCount; i++) {
|
|
2812
3073
|
const child = node.namedChild(i);
|
|
2813
3074
|
if (child?.type === 'identifier' || child?.type === 'variable_declarator') {
|
|
@@ -2815,13 +3076,103 @@ class TreeSitterExtractor {
|
|
|
2815
3076
|
? (0, tree_sitter_helpers_1.getNodeText)(child, this.source)
|
|
2816
3077
|
: extractName(child, this.source, this.extractor);
|
|
2817
3078
|
if (name && name !== '<anonymous>') {
|
|
2818
|
-
this.createNode(kind, name, child, {
|
|
3079
|
+
const created = this.createNode(kind, name, child, {
|
|
2819
3080
|
docstring,
|
|
2820
3081
|
isExported,
|
|
2821
3082
|
});
|
|
3083
|
+
if (created && nameField && child.startIndex === nameField.startIndex) {
|
|
3084
|
+
declared = created;
|
|
3085
|
+
}
|
|
2822
3086
|
}
|
|
2823
3087
|
}
|
|
2824
3088
|
}
|
|
3089
|
+
// Walk the initializer ATTRIBUTED to the declared symbol (#693). Rust
|
|
3090
|
+
// only for now: `const N: usize = compute()` and
|
|
3091
|
+
// `static REGISTRY: Lazy<T> = Lazy::new(|| build())` dropped every call
|
|
3092
|
+
// inside the initializer, so a handler table or a lazily-built singleton
|
|
3093
|
+
// linked to nothing. The other languages sharing this fallback spell
|
|
3094
|
+
// their initializer differently and get their own turn.
|
|
3095
|
+
if (this.language === 'rust') {
|
|
3096
|
+
const valueNode = (0, tree_sitter_helpers_1.getChildByField)(node, 'value');
|
|
3097
|
+
if (valueNode) {
|
|
3098
|
+
if (declared)
|
|
3099
|
+
this.nodeStack.push(declared.id);
|
|
3100
|
+
this.visitFunctionBody(valueNode, '');
|
|
3101
|
+
if (declared)
|
|
3102
|
+
this.nodeStack.pop();
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
/** Resolve a Lua assignment target into its callable name and optional table receiver. */
|
|
3108
|
+
luaAssignmentTarget(node) {
|
|
3109
|
+
if (node.type === 'identifier') {
|
|
3110
|
+
const name = (0, tree_sitter_helpers_1.getNodeText)(node, this.source).trim();
|
|
3111
|
+
return name ? { name, fullName: name } : null;
|
|
3112
|
+
}
|
|
3113
|
+
if (node.type !== 'dot_index_expression' &&
|
|
3114
|
+
node.type !== 'method_index_expression' &&
|
|
3115
|
+
node.type !== 'bracket_index_expression')
|
|
3116
|
+
return null;
|
|
3117
|
+
const table = (0, tree_sitter_helpers_1.getChildByField)(node, 'table');
|
|
3118
|
+
const field = (0, tree_sitter_helpers_1.getChildByField)(node, 'field') ?? (0, tree_sitter_helpers_1.getChildByField)(node, 'method');
|
|
3119
|
+
if (!table || !field)
|
|
3120
|
+
return null;
|
|
3121
|
+
const receiver = (0, tree_sitter_helpers_1.getNodeText)(table, this.source).trim();
|
|
3122
|
+
const name = this.luaStaticFieldName(field, node.type === 'bracket_index_expression');
|
|
3123
|
+
if (!receiver || !name)
|
|
3124
|
+
return null;
|
|
3125
|
+
return { name, receiver, fullName: `${receiver}.${name}` };
|
|
3126
|
+
}
|
|
3127
|
+
/** A statically-known Lua field name; dynamic bracket keys are not callable identities. */
|
|
3128
|
+
luaStaticFieldName(node, bracketed) {
|
|
3129
|
+
if (node.type === 'identifier') {
|
|
3130
|
+
return bracketed ? '' : (0, tree_sitter_helpers_1.getNodeText)(node, this.source).trim();
|
|
3131
|
+
}
|
|
3132
|
+
if (node.type === 'string') {
|
|
3133
|
+
const content = node.namedChildren.find((child) => child.type === 'string_content');
|
|
3134
|
+
return content ? (0, tree_sitter_helpers_1.getNodeText)(content, this.source).trim() : '';
|
|
3135
|
+
}
|
|
3136
|
+
return '';
|
|
3137
|
+
}
|
|
3138
|
+
/** Extract an anonymous Lua function using the name supplied by its assignment target. */
|
|
3139
|
+
extractLuaFunctionValue(node, name, receiver, docstring) {
|
|
3140
|
+
if (!this.extractor)
|
|
3141
|
+
return;
|
|
3142
|
+
const signature = this.extractor.getSignature?.(node, this.source);
|
|
3143
|
+
const extra = { docstring, signature };
|
|
3144
|
+
if (receiver)
|
|
3145
|
+
extra.qualifiedName = this.composeReceiverQualifiedName(receiver, name);
|
|
3146
|
+
else
|
|
3147
|
+
extra.isExported = this.extractor.isExported?.(node, this.source);
|
|
3148
|
+
const functionNode = this.createNode(receiver ? 'method' : 'function', name, node, extra);
|
|
3149
|
+
if (!functionNode)
|
|
3150
|
+
return;
|
|
3151
|
+
this.nodeStack.push(functionNode.id);
|
|
3152
|
+
const body = (0, tree_sitter_helpers_1.getChildByField)(node, this.extractor.bodyField);
|
|
3153
|
+
if (body)
|
|
3154
|
+
this.visitFunctionBody(body, functionNode.id);
|
|
3155
|
+
this.nodeStack.pop();
|
|
3156
|
+
}
|
|
3157
|
+
/** Extract function-valued keyed fields from a Lua table, including nested tables. */
|
|
3158
|
+
extractLuaTableFunctions(table, receiver) {
|
|
3159
|
+
for (const field of table.namedChildren) {
|
|
3160
|
+
if (field.type !== 'field')
|
|
3161
|
+
continue;
|
|
3162
|
+
const nameNode = (0, tree_sitter_helpers_1.getChildByField)(field, 'name');
|
|
3163
|
+
const valueNode = (0, tree_sitter_helpers_1.getChildByField)(field, 'value');
|
|
3164
|
+
if (!nameNode || !valueNode)
|
|
3165
|
+
continue;
|
|
3166
|
+
const bracketed = (0, tree_sitter_helpers_1.getNodeText)(field, this.source).trimStart().startsWith('[');
|
|
3167
|
+
const name = this.luaStaticFieldName(nameNode, bracketed);
|
|
3168
|
+
if (!name)
|
|
3169
|
+
continue;
|
|
3170
|
+
if (valueNode.type === 'function_definition') {
|
|
3171
|
+
this.extractLuaFunctionValue(valueNode, name, receiver);
|
|
3172
|
+
}
|
|
3173
|
+
else if (valueNode.type === 'table_constructor') {
|
|
3174
|
+
this.extractLuaTableFunctions(valueNode, `${receiver}.${name}`);
|
|
3175
|
+
}
|
|
2825
3176
|
}
|
|
2826
3177
|
}
|
|
2827
3178
|
/**
|
|
@@ -2836,7 +3187,7 @@ class TreeSitterExtractor {
|
|
|
2836
3187
|
const name = extractName(node, this.source, this.extractor);
|
|
2837
3188
|
if (name === '<anonymous>')
|
|
2838
3189
|
return false;
|
|
2839
|
-
const docstring =
|
|
3190
|
+
const docstring = this.docstringFor(node);
|
|
2840
3191
|
const isExported = this.extractor.isExported?.(node, this.source);
|
|
2841
3192
|
// Check if this type alias is actually a struct or interface definition
|
|
2842
3193
|
// (e.g. Go: `type Foo struct { ... }` is a type_spec wrapping struct_type)
|
|
@@ -3000,7 +3351,7 @@ class TreeSitterExtractor {
|
|
|
3000
3351
|
const memberKind = child.type === 'method_signature'
|
|
3001
3352
|
? 'method'
|
|
3002
3353
|
: this.isTsFunctionTypedProperty(child) ? 'method' : 'property';
|
|
3003
|
-
const docstring =
|
|
3354
|
+
const docstring = this.docstringFor(child);
|
|
3004
3355
|
const signature = (0, tree_sitter_helpers_1.getNodeText)(child, this.source);
|
|
3005
3356
|
this.createNode(memberKind, memberName, child, {
|
|
3006
3357
|
docstring,
|
|
@@ -4393,10 +4744,17 @@ class TreeSitterExtractor {
|
|
|
4393
4744
|
// This helps the resolver distinguish method calls from bare function calls
|
|
4394
4745
|
// (e.g., Python's console.print() vs builtin print())
|
|
4395
4746
|
// Skip self/this/cls as they don't aid resolution
|
|
4396
|
-
const
|
|
4747
|
+
const rawReceiver = (0, tree_sitter_helpers_1.getChildByField)(func, 'object') ||
|
|
4397
4748
|
(0, tree_sitter_helpers_1.getChildByField)(func, 'operand') ||
|
|
4398
4749
|
(0, tree_sitter_helpers_1.getChildByField)(func, 'argument') ||
|
|
4399
4750
|
func.namedChild(0);
|
|
4751
|
+
// TS/JS: look through wrappers that keep the receiver the same
|
|
4752
|
+
// object (`(x).m()`, `x!.m()`, `(x as T).m()`, `(await f()).m()`),
|
|
4753
|
+
// so the branches below see the identifier / call / chain the
|
|
4754
|
+
// call is really made on.
|
|
4755
|
+
const receiver = rawReceiver && TS_JS_CHAIN_LANGUAGES.has(this.language)
|
|
4756
|
+
? peelTsJsReceiver(rawReceiver)
|
|
4757
|
+
: rawReceiver;
|
|
4400
4758
|
// A LITERAL receiver — `", ".join(...)`, `"x".toUpperCase()`,
|
|
4401
4759
|
// `5.times`, `[].concat(...)` — calls a builtin of the literal's
|
|
4402
4760
|
// type, never a project symbol. The bare-name fallback below let
|
|
@@ -4417,6 +4775,18 @@ class TreeSitterExtractor {
|
|
|
4417
4775
|
calleeName = methodName;
|
|
4418
4776
|
}
|
|
4419
4777
|
}
|
|
4778
|
+
else if (this.language === 'rust' && receiver && receiver.type === 'self') {
|
|
4779
|
+
// Rust `self.method()`. Keep the `self.` prefix, exactly as the
|
|
4780
|
+
// field shape below does (#1585): the resolver reads the owner
|
|
4781
|
+
// off the CALLING method's qualified name and resolves the
|
|
4782
|
+
// method on that type. Collapsing to the bare method name handed
|
|
4783
|
+
// the resolver a name with no owner, which it then matched among
|
|
4784
|
+
// all same-named methods by file proximity — so `self.reset()`
|
|
4785
|
+
// inside `impl Target` landed on a `Decoy::reset` that happened
|
|
4786
|
+
// to sit nearer, with nothing in the edge to show it was a guess
|
|
4787
|
+
// (#1861). Mirrored in the kernel's extract_call (rustlang.rs).
|
|
4788
|
+
calleeName = `self.${methodName}`;
|
|
4789
|
+
}
|
|
4420
4790
|
else if (this.language === 'rust' &&
|
|
4421
4791
|
receiver &&
|
|
4422
4792
|
receiver.type === 'field_expression' &&
|
|
@@ -4511,6 +4881,56 @@ class TreeSitterExtractor {
|
|
|
4511
4881
|
// name, which either failed to resolve or resolved ambiguously.
|
|
4512
4882
|
calleeName = `${(0, tree_sitter_helpers_1.getNodeText)(receiver, this.source)}.${methodName}`;
|
|
4513
4883
|
}
|
|
4884
|
+
else if ((this.language === 'typescript' ||
|
|
4885
|
+
this.language === 'javascript' ||
|
|
4886
|
+
this.language === 'tsx' ||
|
|
4887
|
+
this.language === 'jsx') &&
|
|
4888
|
+
receiver &&
|
|
4889
|
+
receiver.type === 'member_expression' &&
|
|
4890
|
+
(0, tree_sitter_helpers_1.getChildByField)(receiver, 'object')?.type === 'this' &&
|
|
4891
|
+
THIS_FIELD_PROPERTY_TYPES.has((0, tree_sitter_helpers_1.getChildByField)(receiver, 'property')?.type ?? '')) {
|
|
4892
|
+
// TS/JS call through a field of the enclosing class —
|
|
4893
|
+
// `this.mailer.send()` (#1496). Keep the `this.<field>` prefix:
|
|
4894
|
+
// the resolver reads the field's declared type off the class's
|
|
4895
|
+
// own declaration (`private mailer: Mailer`, `mailer = new
|
|
4896
|
+
// Mailer()`) and resolves the method on THAT type — or leaves the
|
|
4897
|
+
// ref unresolved when the type is external or unknown. Previously
|
|
4898
|
+
// this collapsed to the bare method name, which exact-matched
|
|
4899
|
+
// whichever same-named method was nearest — the calling method
|
|
4900
|
+
// itself when the two share a name, a self-edge not in the
|
|
4901
|
+
// source. Same discipline as Rust's `self.<field>` (#1585).
|
|
4902
|
+
// Mirrored in the kernel's extract_call (tsjs/extractors.rs).
|
|
4903
|
+
// An ES private field (`this.#items.add()`) is the same shape;
|
|
4904
|
+
// its name keeps the `#` (#1987).
|
|
4905
|
+
const fieldName = (0, tree_sitter_helpers_1.getNodeText)((0, tree_sitter_helpers_1.getChildByField)(receiver, 'property'), this.source);
|
|
4906
|
+
calleeName = `this.${fieldName}.${methodName}`;
|
|
4907
|
+
}
|
|
4908
|
+
else if ((this.language === 'typescript' ||
|
|
4909
|
+
this.language === 'javascript' ||
|
|
4910
|
+
this.language === 'tsx' ||
|
|
4911
|
+
this.language === 'jsx' ||
|
|
4912
|
+
this.language === 'python') &&
|
|
4913
|
+
receiver &&
|
|
4914
|
+
(receiver.type === 'call_expression' || receiver.type === 'call')) {
|
|
4915
|
+
// Receiver that is itself a call — `d.setdefault(k, []).append(v)`,
|
|
4916
|
+
// `make().run()`, `res.json().data` (#1683). The bare method name
|
|
4917
|
+
// this used to emit exact-matched any top-level project symbol of
|
|
4918
|
+
// that name and fabricated a call edge from an unrelated function
|
|
4919
|
+
// (`append`, `get`, `run`…). Keep the inner callee, encoded as
|
|
4920
|
+
// `<inner>().<method>` like the Java/Kotlin/C++ chains: the
|
|
4921
|
+
// marker never appears in an ordinary ref, so nothing name-matches
|
|
4922
|
+
// it, and a chain resolver can later infer the receiver's type
|
|
4923
|
+
// from what the inner call returns. An inner callee that is not a
|
|
4924
|
+
// plain name or member chain (`(await x)()`, `arr[0]()`) has no
|
|
4925
|
+
// static receiver at all — emit nothing: a silent miss, never a
|
|
4926
|
+
// wrong edge. The inner call is visited on its own either way.
|
|
4927
|
+
// Mirrored in the kernel (tsjs/extractors.rs, python.rs).
|
|
4928
|
+
const innerFn = (0, tree_sitter_helpers_1.getChildByField)(receiver, 'function');
|
|
4929
|
+
const innerCallee = innerFn ? (0, tree_sitter_helpers_1.getNodeText)(innerFn, this.source).replace(/\s+/g, '') : '';
|
|
4930
|
+
if (!/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(innerCallee))
|
|
4931
|
+
return;
|
|
4932
|
+
calleeName = `${innerCallee}().${methodName}`;
|
|
4933
|
+
}
|
|
4514
4934
|
else if (this.language === 'go' &&
|
|
4515
4935
|
receiver &&
|
|
4516
4936
|
receiver.type === 'selector_expression' &&
|
|
@@ -4525,6 +4945,30 @@ class TreeSitterExtractor {
|
|
|
4525
4945
|
// inference (see matchGoFieldChainCall) or stay unresolved.
|
|
4526
4946
|
calleeName = `${(0, tree_sitter_helpers_1.getNodeText)(receiver, this.source).replace(/\s+/g, '')}.${methodName}`;
|
|
4527
4947
|
}
|
|
4948
|
+
else if (TS_JS_CHAIN_LANGUAGES.has(this.language) &&
|
|
4949
|
+
receiver &&
|
|
4950
|
+
TS_JS_CHAIN_RECEIVER_TYPES.has(receiver.type) &&
|
|
4951
|
+
isUnresolvedTsJsChain(receiver, this.source)) {
|
|
4952
|
+
// Keep the source call for effect reporting, but never collapse
|
|
4953
|
+
// it to a guessed method. The resolver only lets frameworks
|
|
4954
|
+
// with receiver evidence handle these qualified chains.
|
|
4955
|
+
const chain = (0, tree_sitter_helpers_1.getNodeText)(func, this.source).replace(/\s+/g, '').replace(/\?\./g, '.');
|
|
4956
|
+
if (!/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*){2,}$/.test(chain))
|
|
4957
|
+
return;
|
|
4958
|
+
calleeName = chain;
|
|
4959
|
+
}
|
|
4960
|
+
else if (TS_JS_CHAIN_LANGUAGES.has(this.language) &&
|
|
4961
|
+
receiver &&
|
|
4962
|
+
!keepsBareTsJsReceiver(receiver, this.source)) {
|
|
4963
|
+
// Any other TS/JS receiver is an expression with no static
|
|
4964
|
+
// type here — `(a ?? b).map()`, `f().list.map()`,
|
|
4965
|
+
// `arr[0].run()`, `(() => {}).call()`. The bare method name this
|
|
4966
|
+
// used to emit exact-matched whichever project method shared the
|
|
4967
|
+
// name (`(await list()).map()` onto an adapter class's `map`).
|
|
4968
|
+
// Emit nothing: a silent miss, never a wrong edge. Mirrored in
|
|
4969
|
+
// the kernel's extract_call (tsjs/extractors.rs).
|
|
4970
|
+
return;
|
|
4971
|
+
}
|
|
4528
4972
|
else {
|
|
4529
4973
|
calleeName = methodName;
|
|
4530
4974
|
}
|
|
@@ -4728,43 +5172,103 @@ class TreeSitterExtractor {
|
|
|
4728
5172
|
}
|
|
4729
5173
|
}
|
|
4730
5174
|
/**
|
|
4731
|
-
*
|
|
4732
|
-
* that invokes a constructor — `Calculator calc(0)` (direct-init) or
|
|
4733
|
-
* `Widget w{1, 2}` (brace-init) — as opposed to a plain variable or a
|
|
4734
|
-
* function declaration? Used to emit an `instantiates` edge for the
|
|
5175
|
+
* C++ stack construction — `Calculator calc(0)` / `Widget w{1, 2}` — is
|
|
4735
5176
|
* call-less construction syntax (#1035); heap `new T(...)` is handled
|
|
4736
5177
|
* separately by INSTANTIATION_KINDS.
|
|
4737
5178
|
*
|
|
4738
|
-
*
|
|
4739
|
-
*
|
|
4740
|
-
*
|
|
4741
|
-
*
|
|
4742
|
-
*
|
|
4743
|
-
*
|
|
4744
|
-
*
|
|
4745
|
-
*
|
|
4746
|
-
*
|
|
4747
|
-
*
|
|
4748
|
-
*
|
|
5179
|
+
* The `type` field must be a class-like NAMED type (`type_identifier`,
|
|
5180
|
+
* `template_type`, or `qualified_identifier`). Primitives (`int x(0)`),
|
|
5181
|
+
* `auto` (`placeholder_type_specifier` — that form always carries a real
|
|
5182
|
+
* `call_expression`, already handled), and sized specifiers are excluded —
|
|
5183
|
+
* they construct no class. `extern T x;` declares, it constructs nothing.
|
|
5184
|
+
*
|
|
5185
|
+
* Per declarator:
|
|
5186
|
+
* - a bare `identifier` is default construction (`T item;`) — arity 0;
|
|
5187
|
+
* - an `init_declarator` whose `value` is an `argument_list` (`(args)`) or
|
|
5188
|
+
* `initializer_list` (`{args}`) carries constructor arguments — arity is
|
|
5189
|
+
* the argument count. An array declarator's braces hold ELEMENTS, not
|
|
5190
|
+
* constructor arguments, so each braced element has its own arity;
|
|
5191
|
+
* - pointer / reference / function declarators construct nothing:
|
|
5192
|
+
* `T* p{}` is a null pointer, `T& r{x}` binds a reference, and the
|
|
5193
|
+
* most-vexing-parse `T c();` is a function declaration.
|
|
5194
|
+
*
|
|
5195
|
+
* `instantiates` (the type) is retained for initialized declarations,
|
|
5196
|
+
* preserving the #1035 dependency edges. `calls` (`T::T/arity`, resolved to
|
|
5197
|
+
* the constructor by src/resolution/cpp-constructor.ts, #1839) is emitted
|
|
5198
|
+
* for every declarator with an arity, default construction included.
|
|
5199
|
+
* Mirrored in the kernel (ccpp/mod.rs cpp_stack_constructions).
|
|
4749
5200
|
*/
|
|
4750
|
-
|
|
5201
|
+
cppStackConstructions(node) {
|
|
5202
|
+
const none = { instantiates: false, arities: [] };
|
|
4751
5203
|
const typeNode = (0, tree_sitter_helpers_1.getChildByField)(node, 'type');
|
|
4752
5204
|
if (!typeNode ||
|
|
4753
5205
|
(typeNode.type !== 'type_identifier' &&
|
|
4754
5206
|
typeNode.type !== 'template_type' &&
|
|
4755
5207
|
typeNode.type !== 'qualified_identifier')) {
|
|
4756
|
-
return
|
|
5208
|
+
return none;
|
|
4757
5209
|
}
|
|
5210
|
+
let instantiates = false;
|
|
5211
|
+
const arities = [];
|
|
4758
5212
|
for (let i = 0; i < node.namedChildCount; i++) {
|
|
4759
5213
|
const child = node.namedChild(i);
|
|
4760
|
-
if (child
|
|
5214
|
+
if (!child)
|
|
5215
|
+
continue;
|
|
5216
|
+
if (child.type === 'storage_class_specifier' && (0, tree_sitter_helpers_1.getNodeText)(child, this.source) === 'extern')
|
|
5217
|
+
return none;
|
|
5218
|
+
if (child.type === 'identifier' || child.type === 'array_declarator') {
|
|
5219
|
+
if (child.type === 'array_declarator' && !this.cppObjectArray(child))
|
|
5220
|
+
continue;
|
|
5221
|
+
arities.push(0);
|
|
5222
|
+
continue;
|
|
5223
|
+
}
|
|
5224
|
+
if (child.type !== 'init_declarator')
|
|
5225
|
+
continue;
|
|
5226
|
+
const declarator = (0, tree_sitter_helpers_1.getChildByField)(child, 'declarator');
|
|
5227
|
+
if (declarator?.type !== 'identifier' && declarator?.type !== 'array_declarator')
|
|
4761
5228
|
continue;
|
|
4762
5229
|
const value = (0, tree_sitter_helpers_1.getChildByField)(child, 'value');
|
|
4763
|
-
if (value
|
|
4764
|
-
|
|
5230
|
+
if (!value || (value.type !== 'argument_list' && value.type !== 'initializer_list'))
|
|
5231
|
+
continue;
|
|
5232
|
+
instantiates = true;
|
|
5233
|
+
if (declarator.type === 'identifier') {
|
|
5234
|
+
arities.push(value.namedChildren.filter((c) => c.type !== 'comment').length);
|
|
5235
|
+
}
|
|
5236
|
+
else if (this.cppObjectArray(declarator)) {
|
|
5237
|
+
const dimensions = [];
|
|
5238
|
+
let array = declarator;
|
|
5239
|
+
while (array?.type === 'array_declarator') {
|
|
5240
|
+
const size = (0, tree_sitter_helpers_1.getChildByField)(array, 'size')?.text ?? '';
|
|
5241
|
+
dimensions.unshift(/^\d+$/.test(size) && Number.isSafeInteger(Number(size)) ? Number(size) : NaN);
|
|
5242
|
+
array = (0, tree_sitter_helpers_1.getChildByField)(array, 'declarator');
|
|
5243
|
+
}
|
|
5244
|
+
const elements = (list, depth) => {
|
|
5245
|
+
const entries = list.namedChildren.filter((c) => c.type !== 'comment');
|
|
5246
|
+
let elided = false;
|
|
5247
|
+
for (const entry of entries) {
|
|
5248
|
+
if (depth + 1 < dimensions.length) {
|
|
5249
|
+
if (entry.type === 'initializer_list')
|
|
5250
|
+
elements(entry, depth + 1);
|
|
5251
|
+
else
|
|
5252
|
+
elided = true; // Unbraced multidimensional layout needs type information.
|
|
5253
|
+
}
|
|
5254
|
+
else {
|
|
5255
|
+
arities.push(entry.type === 'initializer_list'
|
|
5256
|
+
? entry.namedChildren.filter((c) => c.type !== 'comment').length : 1);
|
|
5257
|
+
}
|
|
5258
|
+
}
|
|
5259
|
+
if (!elided && (entries.length === 0 || dimensions[depth] > entries.length))
|
|
5260
|
+
arities.push(0);
|
|
5261
|
+
};
|
|
5262
|
+
elements(value, 0);
|
|
4765
5263
|
}
|
|
4766
5264
|
}
|
|
4767
|
-
return
|
|
5265
|
+
return { instantiates, arities };
|
|
5266
|
+
}
|
|
5267
|
+
cppObjectArray(node) {
|
|
5268
|
+
let element = (0, tree_sitter_helpers_1.getChildByField)(node, 'declarator');
|
|
5269
|
+
while (element?.type === 'array_declarator')
|
|
5270
|
+
element = (0, tree_sitter_helpers_1.getChildByField)(element, 'declarator');
|
|
5271
|
+
return element?.type === 'identifier';
|
|
4768
5272
|
}
|
|
4769
5273
|
/**
|
|
4770
5274
|
* Static-member / value-read pass. A type/enum/class used only via a member
|
|
@@ -4921,6 +5425,24 @@ class TreeSitterExtractor {
|
|
|
4921
5425
|
* (most non-decorator-using languages), the function is a no-op.
|
|
4922
5426
|
*/
|
|
4923
5427
|
extractDecoratorsFor(declNode, decoratedId) {
|
|
5428
|
+
// Rust outer attributes are siblings, not children of the function.
|
|
5429
|
+
// Preserve Tauri's runtime registration for the dead-code decorator rule.
|
|
5430
|
+
if (this.language === 'rust' && declNode.type === 'function_item') {
|
|
5431
|
+
for (let sibling = declNode.previousNamedSibling; sibling; sibling = sibling.previousNamedSibling) {
|
|
5432
|
+
if (sibling.type === 'line_comment' || sibling.type === 'block_comment')
|
|
5433
|
+
continue;
|
|
5434
|
+
if (sibling.type !== 'attribute_item')
|
|
5435
|
+
break;
|
|
5436
|
+
const attribute = sibling.namedChild(0);
|
|
5437
|
+
const name = attribute?.namedChild(0)?.text.replace(/\s/g, '');
|
|
5438
|
+
if (name === 'tauri::command') {
|
|
5439
|
+
const decorated = this.nodes.find(n => n.id === decoratedId);
|
|
5440
|
+
if (decorated)
|
|
5441
|
+
decorated.decorators = ['tauri::command'];
|
|
5442
|
+
break;
|
|
5443
|
+
}
|
|
5444
|
+
}
|
|
5445
|
+
}
|
|
4924
5446
|
const consider = (n) => {
|
|
4925
5447
|
if (!n)
|
|
4926
5448
|
return;
|
|
@@ -5160,11 +5682,166 @@ class TreeSitterExtractor {
|
|
|
5160
5682
|
}
|
|
5161
5683
|
targets.add(target);
|
|
5162
5684
|
}
|
|
5685
|
+
/**
|
|
5686
|
+
* Whether an anonymous function is the whole value of a `variable_declarator`
|
|
5687
|
+
* with a plain identifier name — `const NAME = () => {…}` / `= function () {…}`.
|
|
5688
|
+
* JS-family only.
|
|
5689
|
+
*/
|
|
5690
|
+
declaratorBoundFunction(node) {
|
|
5691
|
+
if (this.language !== 'typescript' &&
|
|
5692
|
+
this.language !== 'javascript' &&
|
|
5693
|
+
this.language !== 'tsx' &&
|
|
5694
|
+
this.language !== 'jsx') {
|
|
5695
|
+
return false;
|
|
5696
|
+
}
|
|
5697
|
+
if (node.type !== 'arrow_function' && node.type !== 'function_expression')
|
|
5698
|
+
return false;
|
|
5699
|
+
const declarator = node.parent;
|
|
5700
|
+
if (!declarator || declarator.type !== 'variable_declarator')
|
|
5701
|
+
return false;
|
|
5702
|
+
const value = (0, tree_sitter_helpers_1.getChildByField)(declarator, 'value');
|
|
5703
|
+
if (!value || value.startIndex !== node.startIndex || value.endIndex !== node.endIndex)
|
|
5704
|
+
return false;
|
|
5705
|
+
return (0, tree_sitter_helpers_1.getChildByField)(declarator, 'name')?.type === 'identifier';
|
|
5706
|
+
}
|
|
5707
|
+
/**
|
|
5708
|
+
* The property a CommonJS export assignment binds a function to —
|
|
5709
|
+
* `exports.NAME = <node>` or `module.exports.NAME = <node>` — or null for
|
|
5710
|
+
* any other assignment. JS-family only; the node must be the assignment's
|
|
5711
|
+
* whole right-hand side.
|
|
5712
|
+
*/
|
|
5713
|
+
commonJsExportName(assignment, value) {
|
|
5714
|
+
if (this.language !== 'typescript' &&
|
|
5715
|
+
this.language !== 'javascript' &&
|
|
5716
|
+
this.language !== 'tsx' &&
|
|
5717
|
+
this.language !== 'jsx') {
|
|
5718
|
+
return null;
|
|
5719
|
+
}
|
|
5720
|
+
const right = (0, tree_sitter_helpers_1.getChildByField)(assignment, 'right');
|
|
5721
|
+
if (!right || right.startIndex !== value.startIndex || right.endIndex !== value.endIndex)
|
|
5722
|
+
return null;
|
|
5723
|
+
const left = (0, tree_sitter_helpers_1.getChildByField)(assignment, 'left');
|
|
5724
|
+
if (!left || left.type !== 'member_expression')
|
|
5725
|
+
return null;
|
|
5726
|
+
const object = (0, tree_sitter_helpers_1.getChildByField)(left, 'object');
|
|
5727
|
+
const property = (0, tree_sitter_helpers_1.getChildByField)(left, 'property');
|
|
5728
|
+
if (!object || !property || property.type !== 'property_identifier')
|
|
5729
|
+
return null;
|
|
5730
|
+
const objectText = (0, tree_sitter_helpers_1.getNodeText)(object, this.source);
|
|
5731
|
+
if (objectText !== 'exports' && objectText !== 'module.exports')
|
|
5732
|
+
return null;
|
|
5733
|
+
return (0, tree_sitter_helpers_1.getNodeText)(property, this.source);
|
|
5734
|
+
}
|
|
5735
|
+
/**
|
|
5736
|
+
* The declarator name a React handler hook binds an anonymous function to —
|
|
5737
|
+
* `const NAME = useCallback(<node>, [...])` — or null for any other shape.
|
|
5738
|
+
* JS-family only; the node must be the hook call's FIRST argument, and the
|
|
5739
|
+
* call's value must be bound directly by a `variable_declarator`.
|
|
5740
|
+
*/
|
|
5741
|
+
reactHookBoundName(node) {
|
|
5742
|
+
if (this.language !== 'typescript' &&
|
|
5743
|
+
this.language !== 'javascript' &&
|
|
5744
|
+
this.language !== 'tsx' &&
|
|
5745
|
+
this.language !== 'jsx') {
|
|
5746
|
+
return null;
|
|
5747
|
+
}
|
|
5748
|
+
if (node.type !== 'arrow_function' && node.type !== 'function_expression')
|
|
5749
|
+
return null;
|
|
5750
|
+
const args = node.parent;
|
|
5751
|
+
if (!args || args.type !== 'arguments')
|
|
5752
|
+
return null;
|
|
5753
|
+
const first = args.namedChild(0);
|
|
5754
|
+
if (!first || first.startIndex !== node.startIndex || first.endIndex !== node.endIndex)
|
|
5755
|
+
return null;
|
|
5756
|
+
const call = args.parent;
|
|
5757
|
+
if (!call || call.type !== 'call_expression')
|
|
5758
|
+
return null;
|
|
5759
|
+
const callee = (0, tree_sitter_helpers_1.getChildByField)(call, 'function');
|
|
5760
|
+
if (!callee || !REACT_HANDLER_HOOKS.test((0, tree_sitter_helpers_1.getNodeText)(callee, this.source)))
|
|
5761
|
+
return null;
|
|
5762
|
+
const declarator = call.parent;
|
|
5763
|
+
if (!declarator || declarator.type !== 'variable_declarator')
|
|
5764
|
+
return null;
|
|
5765
|
+
const nameNode = (0, tree_sitter_helpers_1.getChildByField)(declarator, 'name');
|
|
5766
|
+
return nameNode?.type === 'identifier' ? (0, tree_sitter_helpers_1.getNodeText)(nameNode, this.source) : null;
|
|
5767
|
+
}
|
|
5768
|
+
/**
|
|
5769
|
+
* The declarator name for an anonymous function passed to a CURRIED wrapper
|
|
5770
|
+
* call — `const NAME = factory(...)(function () {…})` — or the property key
|
|
5771
|
+
* when the call is an object member, `{ NAME: factory(...)(fn) }`; else null.
|
|
5772
|
+
*
|
|
5773
|
+
* `reactHookBoundName` above already names a function through the declarator
|
|
5774
|
+
* that binds it; the shape is general, but that method is deliberately
|
|
5775
|
+
* bounded to the three React handler hooks. This is the same shape with a
|
|
5776
|
+
* different, equally decidable bound: the callee is itself a call, i.e. a
|
|
5777
|
+
* factory that returns the wrapper (#1747).
|
|
5778
|
+
*
|
|
5779
|
+
* Requiring the callee to be a call is what keeps this narrow. It admits
|
|
5780
|
+
* `Effect.fn("Session.run")(function* () {…})`, `connect(mapState)(fn)` and
|
|
5781
|
+
* a project's own `wrap("name")(fn)`, and it does not admit the one-call
|
|
5782
|
+
* forms where the argument is a computation rather than a body worth a node
|
|
5783
|
+
* of its own — `useMemo(() => 1 + 1, [])`, `arr.map(() => …)` — which stay
|
|
5784
|
+
* anonymous exactly as before.
|
|
5785
|
+
*
|
|
5786
|
+
* Generators are included here and not in `reactHookBoundName`: a React
|
|
5787
|
+
* handler is never a generator, while `function*` is the common form in the
|
|
5788
|
+
* ecosystem this shape comes from.
|
|
5789
|
+
*/
|
|
5790
|
+
curriedWrapperBoundName(node) {
|
|
5791
|
+
if (this.language !== 'typescript' &&
|
|
5792
|
+
this.language !== 'javascript' &&
|
|
5793
|
+
this.language !== 'tsx' &&
|
|
5794
|
+
this.language !== 'jsx') {
|
|
5795
|
+
return null;
|
|
5796
|
+
}
|
|
5797
|
+
if (node.type !== 'arrow_function' &&
|
|
5798
|
+
node.type !== 'function_expression' &&
|
|
5799
|
+
node.type !== 'generator_function') {
|
|
5800
|
+
return null;
|
|
5801
|
+
}
|
|
5802
|
+
const args = node.parent;
|
|
5803
|
+
if (!args || args.type !== 'arguments')
|
|
5804
|
+
return null;
|
|
5805
|
+
const first = args.namedChild(0);
|
|
5806
|
+
if (!first || first.startIndex !== node.startIndex || first.endIndex !== node.endIndex)
|
|
5807
|
+
return null;
|
|
5808
|
+
const call = args.parent;
|
|
5809
|
+
if (!call || call.type !== 'call_expression')
|
|
5810
|
+
return null;
|
|
5811
|
+
// The bound that replaces the hook allowlist: the thing being called is
|
|
5812
|
+
// itself a call, so this is the second application of a curried wrapper.
|
|
5813
|
+
const callee = (0, tree_sitter_helpers_1.getChildByField)(call, 'function');
|
|
5814
|
+
if (!callee || callee.type !== 'call_expression')
|
|
5815
|
+
return null;
|
|
5816
|
+
const binder = call.parent;
|
|
5817
|
+
if (!binder)
|
|
5818
|
+
return null;
|
|
5819
|
+
// `{ getMode: Effect.fn("…")(function* () {…}) }` — a service is often an
|
|
5820
|
+
// object a factory returns, so the wrapper's result lands in a `pair`. The
|
|
5821
|
+
// property key names it, as extractObjectLiteralFunctions names
|
|
5822
|
+
// `key: () => {}`.
|
|
5823
|
+
if (binder.type === 'pair') {
|
|
5824
|
+
const key = (0, tree_sitter_helpers_1.getChildByField)(binder, 'key');
|
|
5825
|
+
const value = (0, tree_sitter_helpers_1.getChildByField)(binder, 'value');
|
|
5826
|
+
if (!key || !value || value.startIndex !== call.startIndex || value.endIndex !== call.endIndex)
|
|
5827
|
+
return null;
|
|
5828
|
+
return this.objectKeyName(key);
|
|
5829
|
+
}
|
|
5830
|
+
if (binder.type !== 'variable_declarator')
|
|
5831
|
+
return null;
|
|
5832
|
+
const nameNode = (0, tree_sitter_helpers_1.getChildByField)(binder, 'name');
|
|
5833
|
+
return nameNode?.type === 'identifier' ? (0, tree_sitter_helpers_1.getNodeText)(nameNode, this.source) : null;
|
|
5834
|
+
}
|
|
5163
5835
|
visitFunctionBody(body, _functionId) {
|
|
5164
5836
|
if (!this.extractor)
|
|
5165
5837
|
return;
|
|
5166
5838
|
const visitForCallsAndStructure = (node) => {
|
|
5167
5839
|
const nodeType = node.type;
|
|
5840
|
+
// A function-like macro defined inside a body is still a macro (#1838).
|
|
5841
|
+
if ((this.language === 'c' || this.language === 'cpp') && nodeType === 'preproc_function_def') {
|
|
5842
|
+
this.visitNode(node);
|
|
5843
|
+
return;
|
|
5844
|
+
}
|
|
5168
5845
|
// Function-as-value capture (#756) — function bodies are walked here,
|
|
5169
5846
|
// not in visitNode, so the capture hook must fire in both walkers.
|
|
5170
5847
|
this.maybeCaptureFnRefs(node, nodeType);
|
|
@@ -5214,8 +5891,30 @@ class TreeSitterExtractor {
|
|
|
5214
5891
|
// (which strips template args / namespace and emits the `instantiates`
|
|
5215
5892
|
// ref). Children still recurse below, so a nested ctor-arg call
|
|
5216
5893
|
// (`Calculator calc(make())`) keeps its own `calls` ref.
|
|
5217
|
-
if (nodeType === 'declaration' && this.language === 'cpp'
|
|
5218
|
-
this.
|
|
5894
|
+
if (nodeType === 'declaration' && this.language === 'cpp') {
|
|
5895
|
+
const { instantiates, arities } = this.cppStackConstructions(node);
|
|
5896
|
+
if (instantiates)
|
|
5897
|
+
this.extractInstantiation(node);
|
|
5898
|
+
// One `calls` ref per constructed object, naming the constructor and
|
|
5899
|
+
// its argument count (`ns::T::T/1`) so the resolver can pick the
|
|
5900
|
+
// overload — a type is not a callee (#1839).
|
|
5901
|
+
const callerId = this.nodeStack[this.nodeStack.length - 1];
|
|
5902
|
+
const typeNode = (0, tree_sitter_helpers_1.getChildByField)(node, 'type');
|
|
5903
|
+
if (callerId && typeNode && arities.length) {
|
|
5904
|
+
const className = (0, c_cpp_1.stripCppTemplateArgs)((0, tree_sitter_helpers_1.getNodeText)(typeNode, this.source));
|
|
5905
|
+
const name = className.split('::').filter(Boolean).pop();
|
|
5906
|
+
if (name) {
|
|
5907
|
+
for (const arity of arities) {
|
|
5908
|
+
this.unresolvedReferences.push({
|
|
5909
|
+
fromNodeId: callerId,
|
|
5910
|
+
referenceName: `${className}::${name}/${arity}`,
|
|
5911
|
+
referenceKind: 'calls',
|
|
5912
|
+
line: node.startPosition.row + 1,
|
|
5913
|
+
column: node.startPosition.column,
|
|
5914
|
+
});
|
|
5915
|
+
}
|
|
5916
|
+
}
|
|
5917
|
+
}
|
|
5219
5918
|
}
|
|
5220
5919
|
// C++ local function-pointer bindings (see cppLocalFnPtrs): record
|
|
5221
5920
|
// `auto kernel = &fn<…>;` declarations and `kernel = &other_fn<…>;`
|
|
@@ -5273,6 +5972,43 @@ class TreeSitterExtractor {
|
|
|
5273
5972
|
this.extractFunction(node);
|
|
5274
5973
|
return;
|
|
5275
5974
|
}
|
|
5975
|
+
// `const handleSubmit = useCallback(() => {…}, [deps])` — React's
|
|
5976
|
+
// memoised handler. The function is anonymous only syntactically: the
|
|
5977
|
+
// arrow is the first argument of a call whose result the declarator
|
|
5978
|
+
// binds, and that binding is the name every `onPress={handleSubmit}`
|
|
5979
|
+
// and `addListener('x', handleSubmit)` uses. Without a node of its own
|
|
5980
|
+
// the handler's calls attribute to the component and the JSX prop or
|
|
5981
|
+
// event registration has nothing to resolve to — the trigger of a flow
|
|
5982
|
+
// is invisible. Bounded to the hooks React documents for handlers
|
|
5983
|
+
// (`useCallback`, `useEffectEvent`, the experimental `useEvent`):
|
|
5984
|
+
// `useMemo` / `useEffect` callbacks are computations, not handlers.
|
|
5985
|
+
const hookBound = this.reactHookBoundName(node);
|
|
5986
|
+
if (hookBound) {
|
|
5987
|
+
this.extractFunction(node, hookBound);
|
|
5988
|
+
return;
|
|
5989
|
+
}
|
|
5990
|
+
// `const run = Effect.fn("Session.run")(function* () {…})` (#1747) —
|
|
5991
|
+
// the same declarator binding through a curried wrapper. Without a node
|
|
5992
|
+
// the body's calls attribute to the enclosing container, so the file or
|
|
5993
|
+
// the outer function picks up an outgoing edge that belongs to this
|
|
5994
|
+
// function and the callee's caller list names the wrong thing.
|
|
5995
|
+
const wrapperBound = this.curriedWrapperBoundName(node);
|
|
5996
|
+
if (wrapperBound) {
|
|
5997
|
+
this.extractFunction(node, wrapperBound);
|
|
5998
|
+
return;
|
|
5999
|
+
}
|
|
6000
|
+
// `const handleClear = () => {…}` inside a body (#1669) — the same
|
|
6001
|
+
// binding that names a function at module scope names one here, and in
|
|
6002
|
+
// a React component it is how every handler that skips `useCallback`
|
|
6003
|
+
// is written. Without a node the handler is absent from callers /
|
|
6004
|
+
// impact ("Symbol not found" reads like "no callers") and its calls
|
|
6005
|
+
// attribute to the component. extractFunction resolves the name from
|
|
6006
|
+
// the declarator; a destructuring or otherwise unnamed binding stays
|
|
6007
|
+
// anonymous and falls through.
|
|
6008
|
+
if (this.declaratorBoundFunction(node)) {
|
|
6009
|
+
this.extractFunction(node);
|
|
6010
|
+
return;
|
|
6011
|
+
}
|
|
5276
6012
|
}
|
|
5277
6013
|
// Extract structural nodes found inside function bodies.
|
|
5278
6014
|
// Each extract method visits its own children, so we return after extracting.
|
|
@@ -5286,6 +6022,8 @@ class TreeSitterExtractor {
|
|
|
5286
6022
|
this.extractInterface(node);
|
|
5287
6023
|
else if (classification === 'trait')
|
|
5288
6024
|
this.extractClass(node, 'trait');
|
|
6025
|
+
else if (classification === 'module')
|
|
6026
|
+
this.extractClass(node, 'module');
|
|
5289
6027
|
else
|
|
5290
6028
|
this.extractClass(node);
|
|
5291
6029
|
return;
|