@optave/codegraph 3.12.0 → 3.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -46
- package/dist/ast-analysis/engine.d.ts.map +1 -1
- package/dist/ast-analysis/engine.js +38 -40
- package/dist/ast-analysis/engine.js.map +1 -1
- package/dist/ast-analysis/rules/b2.d.ts +7 -0
- package/dist/ast-analysis/rules/b2.d.ts.map +1 -0
- package/dist/ast-analysis/rules/b2.js +240 -0
- package/dist/ast-analysis/rules/b2.js.map +1 -0
- package/dist/ast-analysis/rules/b3.d.ts +6 -0
- package/dist/ast-analysis/rules/b3.d.ts.map +1 -0
- package/dist/ast-analysis/rules/b3.js +105 -0
- package/dist/ast-analysis/rules/b3.js.map +1 -0
- package/dist/ast-analysis/rules/b4.d.ts +9 -0
- package/dist/ast-analysis/rules/b4.d.ts.map +1 -0
- package/dist/ast-analysis/rules/b4.js +361 -0
- package/dist/ast-analysis/rules/b4.js.map +1 -0
- package/dist/ast-analysis/rules/b5.d.ts +4 -0
- package/dist/ast-analysis/rules/b5.d.ts.map +1 -0
- package/dist/ast-analysis/rules/b5.js +52 -0
- package/dist/ast-analysis/rules/b5.js.map +1 -0
- package/dist/ast-analysis/rules/c.d.ts +4 -0
- package/dist/ast-analysis/rules/c.d.ts.map +1 -0
- package/dist/ast-analysis/rules/c.js +143 -0
- package/dist/ast-analysis/rules/c.js.map +1 -0
- package/dist/ast-analysis/rules/index.d.ts.map +1 -1
- package/dist/ast-analysis/rules/index.js +34 -0
- package/dist/ast-analysis/rules/index.js.map +1 -1
- package/dist/ast-analysis/rules/javascript.d.ts.map +1 -1
- package/dist/ast-analysis/rules/javascript.js +3 -0
- package/dist/ast-analysis/rules/javascript.js.map +1 -1
- package/dist/ast-analysis/shared.d.ts.map +1 -1
- package/dist/ast-analysis/shared.js +2 -0
- package/dist/ast-analysis/shared.js.map +1 -1
- package/dist/ast-analysis/visitor-utils.d.ts +1 -0
- package/dist/ast-analysis/visitor-utils.d.ts.map +1 -1
- package/dist/ast-analysis/visitor-utils.js +5 -0
- package/dist/ast-analysis/visitor-utils.js.map +1 -1
- package/dist/ast-analysis/visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitor.js +60 -47
- package/dist/ast-analysis/visitor.js.map +1 -1
- package/dist/ast-analysis/visitors/cfg-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/cfg-visitor.js +126 -76
- package/dist/ast-analysis/visitors/cfg-visitor.js.map +1 -1
- package/dist/ast-analysis/visitors/complexity-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/complexity-visitor.js +27 -15
- package/dist/ast-analysis/visitors/complexity-visitor.js.map +1 -1
- package/dist/ast-analysis/visitors/dataflow-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/dataflow-visitor.js +54 -21
- package/dist/ast-analysis/visitors/dataflow-visitor.js.map +1 -1
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +2 -1
- package/dist/cli/commands/audit.js.map +1 -1
- package/dist/cli/commands/batch.d.ts.map +1 -1
- package/dist/cli/commands/batch.js +1 -0
- package/dist/cli/commands/batch.js.map +1 -1
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +6 -1
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +275 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/roles.d.ts.map +1 -1
- package/dist/cli/commands/roles.js +6 -1
- package/dist/cli/commands/roles.js.map +1 -1
- package/dist/cli/commands/triage.js +1 -1
- package/dist/cli/commands/triage.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +10 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/shared/options.d.ts +2 -1
- package/dist/cli/shared/options.d.ts.map +1 -1
- package/dist/cli/shared/options.js +11 -1
- package/dist/cli/shared/options.js.map +1 -1
- package/dist/cli/types.d.ts +2 -0
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/db/better-sqlite3.d.ts +2 -1
- package/dist/db/better-sqlite3.d.ts.map +1 -1
- package/dist/db/better-sqlite3.js.map +1 -1
- package/dist/db/connection.d.ts +7 -1
- package/dist/db/connection.d.ts.map +1 -1
- package/dist/db/connection.js +20 -5
- package/dist/db/connection.js.map +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +69 -1
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/repository/build-stmts.d.ts.map +1 -1
- package/dist/db/repository/build-stmts.js +18 -0
- package/dist/db/repository/build-stmts.js.map +1 -1
- package/dist/db/repository/dataflow.d.ts +5 -0
- package/dist/db/repository/dataflow.d.ts.map +1 -1
- package/dist/db/repository/dataflow.js +14 -0
- package/dist/db/repository/dataflow.js.map +1 -1
- package/dist/db/repository/index.d.ts +1 -1
- package/dist/db/repository/index.d.ts.map +1 -1
- package/dist/db/repository/index.js +1 -1
- package/dist/db/repository/index.js.map +1 -1
- package/dist/db/repository/native-repository.d.ts.map +1 -1
- package/dist/db/repository/native-repository.js +47 -34
- package/dist/db/repository/native-repository.js.map +1 -1
- package/dist/domain/analysis/context.d.ts +2 -2
- package/dist/domain/analysis/dependencies.d.ts +2 -2
- package/dist/domain/analysis/diff-impact.d.ts +2 -2
- package/dist/domain/analysis/fn-impact.d.ts +3 -1
- package/dist/domain/analysis/fn-impact.d.ts.map +1 -1
- package/dist/domain/analysis/fn-impact.js +4 -0
- package/dist/domain/analysis/fn-impact.js.map +1 -1
- package/dist/domain/analysis/implementations.d.ts +2 -2
- package/dist/domain/analysis/module-map.d.ts.map +1 -1
- package/dist/domain/analysis/module-map.js +32 -5
- package/dist/domain/analysis/module-map.js.map +1 -1
- package/dist/domain/analysis/roles.d.ts +7 -1
- package/dist/domain/analysis/roles.d.ts.map +1 -1
- package/dist/domain/analysis/roles.js +16 -0
- package/dist/domain/analysis/roles.js.map +1 -1
- package/dist/domain/analysis/symbol-lookup.d.ts +4 -4
- package/dist/domain/graph/builder/call-resolver.d.ts +29 -13
- package/dist/domain/graph/builder/call-resolver.d.ts.map +1 -1
- package/dist/domain/graph/builder/call-resolver.js +125 -205
- package/dist/domain/graph/builder/call-resolver.js.map +1 -1
- package/dist/domain/graph/builder/cha.d.ts +9 -1
- package/dist/domain/graph/builder/cha.d.ts.map +1 -1
- package/dist/domain/graph/builder/cha.js +17 -2
- package/dist/domain/graph/builder/cha.js.map +1 -1
- package/dist/domain/graph/builder/context.d.ts +1 -0
- package/dist/domain/graph/builder/context.d.ts.map +1 -1
- package/dist/domain/graph/builder/context.js.map +1 -1
- package/dist/domain/graph/builder/helpers.d.ts +24 -1
- package/dist/domain/graph/builder/helpers.d.ts.map +1 -1
- package/dist/domain/graph/builder/helpers.js +174 -65
- package/dist/domain/graph/builder/helpers.js.map +1 -1
- package/dist/domain/graph/builder/incremental.d.ts.map +1 -1
- package/dist/domain/graph/builder/incremental.js +166 -97
- package/dist/domain/graph/builder/incremental.js.map +1 -1
- package/dist/domain/graph/builder/pipeline.d.ts.map +1 -1
- package/dist/domain/graph/builder/pipeline.js +46 -5
- package/dist/domain/graph/builder/pipeline.js.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.d.ts +0 -2
- package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.js +554 -538
- package/dist/domain/graph/builder/stages/build-edges.js.map +1 -1
- package/dist/domain/graph/builder/stages/collect-files.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/collect-files.js +10 -7
- package/dist/domain/graph/builder/stages/collect-files.js.map +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.js +3 -2
- package/dist/domain/graph/builder/stages/detect-changes.js.map +1 -1
- package/dist/domain/graph/builder/stages/finalize.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/finalize.js +4 -0
- package/dist/domain/graph/builder/stages/finalize.js.map +1 -1
- package/dist/domain/graph/builder/stages/native-orchestrator.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/native-orchestrator.js +952 -343
- package/dist/domain/graph/builder/stages/native-orchestrator.js.map +1 -1
- package/dist/domain/graph/builder/stages/resolve-imports.js +1 -1
- package/dist/domain/graph/builder/stages/resolve-imports.js.map +1 -1
- package/dist/domain/graph/resolver/points-to.d.ts.map +1 -1
- package/dist/domain/graph/resolver/points-to.js +105 -57
- package/dist/domain/graph/resolver/points-to.js.map +1 -1
- package/dist/domain/graph/resolver/strategy.d.ts +61 -0
- package/dist/domain/graph/resolver/strategy.d.ts.map +1 -0
- package/dist/domain/graph/resolver/strategy.js +222 -0
- package/dist/domain/graph/resolver/strategy.js.map +1 -0
- package/dist/domain/graph/watcher.d.ts.map +1 -1
- package/dist/domain/graph/watcher.js +16 -9
- package/dist/domain/graph/watcher.js.map +1 -1
- package/dist/domain/parser.d.ts +16 -5
- package/dist/domain/parser.d.ts.map +1 -1
- package/dist/domain/parser.js +58 -17
- package/dist/domain/parser.js.map +1 -1
- package/dist/domain/queries.d.ts +1 -1
- package/dist/domain/queries.d.ts.map +1 -1
- package/dist/domain/queries.js +1 -1
- package/dist/domain/queries.js.map +1 -1
- package/dist/domain/wasm-worker-entry.js +13 -2
- package/dist/domain/wasm-worker-entry.js.map +1 -1
- package/dist/domain/wasm-worker-pool.d.ts.map +1 -1
- package/dist/domain/wasm-worker-pool.js +26 -5
- package/dist/domain/wasm-worker-pool.js.map +1 -1
- package/dist/domain/wasm-worker-protocol.d.ts +8 -0
- package/dist/domain/wasm-worker-protocol.d.ts.map +1 -1
- package/dist/extractors/cpp.d.ts.map +1 -1
- package/dist/extractors/cpp.js +42 -1
- package/dist/extractors/cpp.js.map +1 -1
- package/dist/extractors/cuda.d.ts.map +1 -1
- package/dist/extractors/cuda.js +42 -1
- package/dist/extractors/cuda.js.map +1 -1
- package/dist/extractors/dart.js +48 -3
- package/dist/extractors/dart.js.map +1 -1
- package/dist/extractors/groovy.js +62 -3
- package/dist/extractors/groovy.js.map +1 -1
- package/dist/extractors/helpers.d.ts +15 -2
- package/dist/extractors/helpers.d.ts.map +1 -1
- package/dist/extractors/helpers.js +45 -1
- package/dist/extractors/helpers.js.map +1 -1
- package/dist/extractors/java.d.ts.map +1 -1
- package/dist/extractors/java.js +85 -8
- package/dist/extractors/java.js.map +1 -1
- package/dist/extractors/javascript.d.ts.map +1 -1
- package/dist/extractors/javascript.js +686 -169
- package/dist/extractors/javascript.js.map +1 -1
- package/dist/extractors/kotlin.js +58 -3
- package/dist/extractors/kotlin.js.map +1 -1
- package/dist/extractors/objc.js +25 -2
- package/dist/extractors/objc.js.map +1 -1
- package/dist/extractors/scala.js +62 -2
- package/dist/extractors/scala.js.map +1 -1
- package/dist/extractors/swift.js +52 -3
- package/dist/extractors/swift.js.map +1 -1
- package/dist/features/audit.js +26 -23
- package/dist/features/audit.js.map +1 -1
- package/dist/features/boundaries.d.ts.map +1 -1
- package/dist/features/boundaries.js +12 -9
- package/dist/features/boundaries.js.map +1 -1
- package/dist/features/cfg.d.ts.map +1 -1
- package/dist/features/cfg.js +25 -18
- package/dist/features/cfg.js.map +1 -1
- package/dist/features/check.d.ts.map +1 -1
- package/dist/features/check.js +18 -5
- package/dist/features/check.js.map +1 -1
- package/dist/features/communities.d.ts +4 -2
- package/dist/features/communities.d.ts.map +1 -1
- package/dist/features/communities.js +6 -4
- package/dist/features/communities.js.map +1 -1
- package/dist/features/dataflow.d.ts +60 -0
- package/dist/features/dataflow.d.ts.map +1 -1
- package/dist/features/dataflow.js +530 -6
- package/dist/features/dataflow.js.map +1 -1
- package/dist/features/manifesto.d.ts.map +1 -1
- package/dist/features/manifesto.js +59 -72
- package/dist/features/manifesto.js.map +1 -1
- package/dist/features/sequence.d.ts.map +1 -1
- package/dist/features/sequence.js +27 -22
- package/dist/features/sequence.js.map +1 -1
- package/dist/features/snapshot.d.ts.map +1 -1
- package/dist/features/snapshot.js +36 -28
- package/dist/features/snapshot.js.map +1 -1
- package/dist/features/structure-query.d.ts +1 -1
- package/dist/features/structure-query.d.ts.map +1 -1
- package/dist/features/structure-query.js +6 -6
- package/dist/features/structure-query.js.map +1 -1
- package/dist/features/structure.d.ts.map +1 -1
- package/dist/features/structure.js +150 -62
- package/dist/features/structure.js.map +1 -1
- package/dist/features/triage.d.ts.map +1 -1
- package/dist/features/triage.js +18 -11
- package/dist/features/triage.js.map +1 -1
- package/dist/graph/algorithms/bfs.d.ts +1 -1
- package/dist/graph/algorithms/bfs.d.ts.map +1 -1
- package/dist/graph/algorithms/bfs.js +14 -13
- package/dist/graph/algorithms/bfs.js.map +1 -1
- package/dist/graph/algorithms/tarjan.d.ts.map +1 -1
- package/dist/graph/algorithms/tarjan.js +5 -0
- package/dist/graph/algorithms/tarjan.js.map +1 -1
- package/dist/graph/builders/dependency.js +28 -22
- package/dist/graph/builders/dependency.js.map +1 -1
- package/dist/graph/classifiers/roles.d.ts +10 -1
- package/dist/graph/classifiers/roles.d.ts.map +1 -1
- package/dist/graph/classifiers/roles.js +60 -6
- package/dist/graph/classifiers/roles.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/config.d.ts +87 -4
- package/dist/infrastructure/config.d.ts.map +1 -1
- package/dist/infrastructure/config.js +424 -22
- package/dist/infrastructure/config.js.map +1 -1
- package/dist/infrastructure/registry.d.ts +27 -7
- package/dist/infrastructure/registry.d.ts.map +1 -1
- package/dist/infrastructure/registry.js +79 -5
- package/dist/infrastructure/registry.js.map +1 -1
- package/dist/infrastructure/update-check.d.ts.map +1 -1
- package/dist/infrastructure/update-check.js +49 -31
- package/dist/infrastructure/update-check.js.map +1 -1
- package/dist/mcp/server.d.ts +2 -10
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/ast-query.d.ts +1 -1
- package/dist/mcp/tools/ast-query.d.ts.map +1 -1
- package/dist/mcp/tools/audit.d.ts +1 -1
- package/dist/mcp/tools/audit.d.ts.map +1 -1
- package/dist/mcp/tools/batch-query.d.ts +1 -1
- package/dist/mcp/tools/batch-query.d.ts.map +1 -1
- package/dist/mcp/tools/branch-compare.d.ts +1 -1
- package/dist/mcp/tools/branch-compare.d.ts.map +1 -1
- package/dist/mcp/tools/brief.d.ts +1 -1
- package/dist/mcp/tools/brief.d.ts.map +1 -1
- package/dist/mcp/tools/cfg.d.ts +1 -1
- package/dist/mcp/tools/cfg.d.ts.map +1 -1
- package/dist/mcp/tools/check.d.ts +1 -1
- package/dist/mcp/tools/check.d.ts.map +1 -1
- package/dist/mcp/tools/co-changes.d.ts +1 -1
- package/dist/mcp/tools/co-changes.d.ts.map +1 -1
- package/dist/mcp/tools/code-owners.d.ts +1 -1
- package/dist/mcp/tools/code-owners.d.ts.map +1 -1
- package/dist/mcp/tools/communities.d.ts +1 -1
- package/dist/mcp/tools/communities.d.ts.map +1 -1
- package/dist/mcp/tools/complexity.d.ts +1 -1
- package/dist/mcp/tools/complexity.d.ts.map +1 -1
- package/dist/mcp/tools/context.d.ts +1 -1
- package/dist/mcp/tools/context.d.ts.map +1 -1
- package/dist/mcp/tools/dataflow.d.ts +1 -1
- package/dist/mcp/tools/dataflow.d.ts.map +1 -1
- package/dist/mcp/tools/diff-impact.d.ts +1 -1
- package/dist/mcp/tools/diff-impact.d.ts.map +1 -1
- package/dist/mcp/tools/execution-flow.d.ts +1 -1
- package/dist/mcp/tools/execution-flow.d.ts.map +1 -1
- package/dist/mcp/tools/export-graph.d.ts +1 -1
- package/dist/mcp/tools/export-graph.d.ts.map +1 -1
- package/dist/mcp/tools/file-deps.d.ts +1 -1
- package/dist/mcp/tools/file-deps.d.ts.map +1 -1
- package/dist/mcp/tools/file-exports.d.ts +1 -1
- package/dist/mcp/tools/file-exports.d.ts.map +1 -1
- package/dist/mcp/tools/find-cycles.d.ts +1 -1
- package/dist/mcp/tools/find-cycles.d.ts.map +1 -1
- package/dist/mcp/tools/fn-impact.d.ts +1 -1
- package/dist/mcp/tools/fn-impact.d.ts.map +1 -1
- package/dist/mcp/tools/impact-analysis.d.ts +1 -1
- package/dist/mcp/tools/impact-analysis.d.ts.map +1 -1
- package/dist/mcp/tools/implementations.d.ts +1 -1
- package/dist/mcp/tools/implementations.d.ts.map +1 -1
- package/dist/mcp/tools/index.d.ts +2 -5
- package/dist/mcp/tools/index.d.ts.map +1 -1
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/interfaces.d.ts +1 -1
- package/dist/mcp/tools/interfaces.d.ts.map +1 -1
- package/dist/mcp/tools/list-functions.d.ts +1 -1
- package/dist/mcp/tools/list-functions.d.ts.map +1 -1
- package/dist/mcp/tools/list-repos.d.ts +1 -1
- package/dist/mcp/tools/list-repos.d.ts.map +1 -1
- package/dist/mcp/tools/module-map.d.ts +1 -1
- package/dist/mcp/tools/module-map.d.ts.map +1 -1
- package/dist/mcp/tools/node-roles.d.ts +1 -1
- package/dist/mcp/tools/node-roles.d.ts.map +1 -1
- package/dist/mcp/tools/path.d.ts +1 -1
- package/dist/mcp/tools/path.d.ts.map +1 -1
- package/dist/mcp/tools/query.d.ts +1 -1
- package/dist/mcp/tools/query.d.ts.map +1 -1
- package/dist/mcp/tools/semantic-search.d.ts +1 -1
- package/dist/mcp/tools/semantic-search.d.ts.map +1 -1
- package/dist/mcp/tools/sequence.d.ts +1 -1
- package/dist/mcp/tools/sequence.d.ts.map +1 -1
- package/dist/mcp/tools/structure.d.ts +1 -1
- package/dist/mcp/tools/structure.d.ts.map +1 -1
- package/dist/mcp/tools/symbol-children.d.ts +1 -1
- package/dist/mcp/tools/symbol-children.d.ts.map +1 -1
- package/dist/mcp/tools/triage.d.ts +1 -1
- package/dist/mcp/tools/triage.d.ts.map +1 -1
- package/dist/mcp/tools/where.d.ts +1 -1
- package/dist/mcp/tools/where.d.ts.map +1 -1
- package/dist/mcp/types.d.ts +19 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +6 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/presentation/queries-cli/index.d.ts +1 -1
- package/dist/presentation/queries-cli/index.d.ts.map +1 -1
- package/dist/presentation/queries-cli/index.js +1 -1
- package/dist/presentation/queries-cli/index.js.map +1 -1
- package/dist/presentation/queries-cli/overview.d.ts +1 -0
- package/dist/presentation/queries-cli/overview.d.ts.map +1 -1
- package/dist/presentation/queries-cli/overview.js +20 -1
- package/dist/presentation/queries-cli/overview.js.map +1 -1
- package/dist/presentation/queries-cli.d.ts +1 -1
- package/dist/presentation/queries-cli.d.ts.map +1 -1
- package/dist/presentation/queries-cli.js +1 -1
- package/dist/presentation/queries-cli.js.map +1 -1
- package/dist/presentation/structure.d.ts +1 -1
- package/dist/presentation/structure.d.ts.map +1 -1
- package/dist/presentation/structure.js +2 -2
- package/dist/presentation/structure.js.map +1 -1
- package/dist/presentation/viewer.d.ts.map +1 -1
- package/dist/presentation/viewer.js +45 -32
- package/dist/presentation/viewer.js.map +1 -1
- package/dist/shared/constants.d.ts +21 -0
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/constants.js +25 -0
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/normalize.d.ts.map +1 -1
- package/dist/shared/normalize.js +12 -22
- package/dist/shared/normalize.js.map +1 -1
- package/dist/shared/paginate.d.ts +4 -17
- package/dist/shared/paginate.d.ts.map +1 -1
- package/dist/shared/paginate.js.map +1 -1
- package/dist/types.d.ts +113 -1
- package/dist/types.d.ts.map +1 -1
- package/grammars/tree-sitter-erlang.wasm +0 -0
- package/grammars/tree-sitter-gleam.wasm +0 -0
- package/package.json +7 -8
- package/src/ast-analysis/engine.ts +43 -63
- package/src/ast-analysis/rules/b2.ts +263 -0
- package/src/ast-analysis/rules/b3.ts +127 -0
- package/src/ast-analysis/rules/b4.ts +378 -0
- package/src/ast-analysis/rules/b5.ts +65 -0
- package/src/ast-analysis/rules/c.ts +157 -0
- package/src/ast-analysis/rules/index.ts +34 -0
- package/src/ast-analysis/rules/javascript.ts +3 -0
- package/src/ast-analysis/shared.ts +2 -0
- package/src/ast-analysis/visitor-utils.ts +5 -0
- package/src/ast-analysis/visitor.ts +82 -52
- package/src/ast-analysis/visitors/cfg-visitor.ts +198 -84
- package/src/ast-analysis/visitors/complexity-visitor.ts +44 -16
- package/src/ast-analysis/visitors/dataflow-visitor.ts +68 -29
- package/src/cli/commands/audit.ts +2 -1
- package/src/cli/commands/batch.ts +1 -0
- package/src/cli/commands/build.ts +6 -1
- package/src/cli/commands/config.ts +353 -0
- package/src/cli/commands/roles.ts +6 -1
- package/src/cli/commands/triage.ts +1 -1
- package/src/cli/index.ts +10 -0
- package/src/cli/shared/options.ts +11 -1
- package/src/cli/types.ts +2 -0
- package/src/db/better-sqlite3.ts +5 -4
- package/src/db/connection.ts +23 -5
- package/src/db/index.ts +1 -0
- package/src/db/migrations.ts +69 -1
- package/src/db/repository/build-stmts.ts +30 -0
- package/src/db/repository/dataflow.ts +16 -0
- package/src/db/repository/index.ts +1 -1
- package/src/db/repository/native-repository.ts +56 -40
- package/src/domain/analysis/fn-impact.ts +4 -0
- package/src/domain/analysis/module-map.ts +38 -6
- package/src/domain/analysis/roles.ts +23 -0
- package/src/domain/graph/builder/call-resolver.ts +156 -218
- package/src/domain/graph/builder/cha.ts +18 -1
- package/src/domain/graph/builder/context.ts +1 -0
- package/src/domain/graph/builder/helpers.ts +205 -67
- package/src/domain/graph/builder/incremental.ts +249 -119
- package/src/domain/graph/builder/pipeline.ts +59 -6
- package/src/domain/graph/builder/stages/build-edges.ts +783 -652
- package/src/domain/graph/builder/stages/collect-files.ts +12 -6
- package/src/domain/graph/builder/stages/detect-changes.ts +4 -2
- package/src/domain/graph/builder/stages/finalize.ts +4 -0
- package/src/domain/graph/builder/stages/native-orchestrator.ts +1214 -398
- package/src/domain/graph/builder/stages/resolve-imports.ts +1 -1
- package/src/domain/graph/resolver/points-to.ts +182 -59
- package/src/domain/graph/resolver/strategy.ts +265 -0
- package/src/domain/graph/watcher.ts +19 -9
- package/src/domain/parser.ts +57 -16
- package/src/domain/queries.ts +1 -1
- package/src/domain/wasm-worker-entry.ts +13 -2
- package/src/domain/wasm-worker-pool.ts +29 -4
- package/src/domain/wasm-worker-protocol.ts +5 -0
- package/src/extractors/cpp.ts +44 -1
- package/src/extractors/cuda.ts +44 -1
- package/src/extractors/dart.ts +48 -3
- package/src/extractors/groovy.ts +62 -2
- package/src/extractors/helpers.ts +48 -2
- package/src/extractors/java.ts +88 -8
- package/src/extractors/javascript.ts +693 -167
- package/src/extractors/kotlin.ts +57 -3
- package/src/extractors/objc.ts +25 -1
- package/src/extractors/scala.ts +63 -1
- package/src/extractors/swift.ts +46 -3
- package/src/features/audit.ts +43 -34
- package/src/features/boundaries.ts +17 -9
- package/src/features/cfg.ts +31 -22
- package/src/features/check.ts +21 -5
- package/src/features/communities.ts +28 -19
- package/src/features/dataflow.ts +755 -6
- package/src/features/manifesto.ts +76 -75
- package/src/features/sequence.ts +29 -23
- package/src/features/snapshot.ts +36 -25
- package/src/features/structure-query.ts +7 -7
- package/src/features/structure.ts +185 -55
- package/src/features/triage.ts +28 -15
- package/src/graph/algorithms/bfs.ts +13 -12
- package/src/graph/algorithms/tarjan.ts +5 -0
- package/src/graph/builders/dependency.ts +35 -23
- package/src/graph/classifiers/roles.ts +74 -7
- package/src/index.ts +5 -1
- package/src/infrastructure/config.ts +511 -23
- package/src/infrastructure/registry.ts +117 -12
- package/src/infrastructure/update-check.ts +55 -33
- package/src/mcp/server.ts +2 -8
- package/src/mcp/tools/ast-query.ts +1 -1
- package/src/mcp/tools/audit.ts +1 -1
- package/src/mcp/tools/batch-query.ts +1 -1
- package/src/mcp/tools/branch-compare.ts +1 -1
- package/src/mcp/tools/brief.ts +1 -1
- package/src/mcp/tools/cfg.ts +1 -1
- package/src/mcp/tools/check.ts +1 -1
- package/src/mcp/tools/co-changes.ts +1 -1
- package/src/mcp/tools/code-owners.ts +1 -1
- package/src/mcp/tools/communities.ts +1 -1
- package/src/mcp/tools/complexity.ts +1 -1
- package/src/mcp/tools/context.ts +1 -1
- package/src/mcp/tools/dataflow.ts +1 -1
- package/src/mcp/tools/diff-impact.ts +1 -1
- package/src/mcp/tools/execution-flow.ts +1 -1
- package/src/mcp/tools/export-graph.ts +1 -1
- package/src/mcp/tools/file-deps.ts +1 -1
- package/src/mcp/tools/file-exports.ts +1 -1
- package/src/mcp/tools/find-cycles.ts +1 -1
- package/src/mcp/tools/fn-impact.ts +1 -1
- package/src/mcp/tools/impact-analysis.ts +1 -1
- package/src/mcp/tools/implementations.ts +1 -1
- package/src/mcp/tools/index.ts +2 -5
- package/src/mcp/tools/interfaces.ts +1 -1
- package/src/mcp/tools/list-functions.ts +1 -1
- package/src/mcp/tools/list-repos.ts +1 -1
- package/src/mcp/tools/module-map.ts +1 -1
- package/src/mcp/tools/node-roles.ts +1 -1
- package/src/mcp/tools/path.ts +1 -1
- package/src/mcp/tools/query.ts +1 -1
- package/src/mcp/tools/semantic-search.ts +1 -1
- package/src/mcp/tools/sequence.ts +1 -1
- package/src/mcp/tools/structure.ts +1 -1
- package/src/mcp/tools/symbol-children.ts +1 -1
- package/src/mcp/tools/triage.ts +1 -1
- package/src/mcp/tools/where.ts +1 -1
- package/src/mcp/types.ts +21 -0
- package/src/presentation/queries-cli/index.ts +1 -1
- package/src/presentation/queries-cli/overview.ts +35 -1
- package/src/presentation/queries-cli.ts +1 -0
- package/src/presentation/structure.ts +3 -3
- package/src/presentation/viewer.ts +98 -87
- package/src/shared/constants.ts +26 -0
- package/src/shared/normalize.ts +13 -22
- package/src/shared/paginate.ts +4 -18
- package/src/types.ts +127 -1
|
@@ -5,8 +5,16 @@
|
|
|
5
5
|
* Both callers supply a `CallNodeLookup` adapter that abstracts their
|
|
6
6
|
* node-lookup mechanism (pre-loaded Maps vs. per-query SQLite statements).
|
|
7
7
|
* The resolution logic lives here exactly once.
|
|
8
|
+
*
|
|
9
|
+
* `resolveByMethodOrGlobal` delegates its two branches to strategy helpers
|
|
10
|
+
* in `../resolver/strategy.ts` to keep per-strategy complexity manageable.
|
|
8
11
|
*/
|
|
9
12
|
import { computeConfidence } from '../resolve.js';
|
|
13
|
+
import {
|
|
14
|
+
isModuleScopedLanguage,
|
|
15
|
+
resolveByGlobal,
|
|
16
|
+
resolveByReceiver,
|
|
17
|
+
} from '../resolver/strategy.js';
|
|
10
18
|
|
|
11
19
|
// ── Public interface ─────────────────────────────────────────────────────
|
|
12
20
|
|
|
@@ -23,165 +31,148 @@ export interface CallNodeLookup {
|
|
|
23
31
|
|
|
24
32
|
export const RECEIVER_KINDS = new Set(['class', 'struct', 'interface', 'type', 'module']);
|
|
25
33
|
|
|
34
|
+
// Re-export so consumers that import isModuleScopedLanguage from this module
|
|
35
|
+
// continue to work without changes (build-edges.ts, etc.).
|
|
36
|
+
export { isModuleScopedLanguage };
|
|
37
|
+
|
|
38
|
+
// ── Shared resolution functions ──────────────────────────────────────────
|
|
39
|
+
|
|
26
40
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
41
|
+
* Callable definition kinds — variable/constant bindings are NOT callable
|
|
42
|
+
* in the function-as-enclosing-scope sense (they are local declarations, not
|
|
43
|
+
* function bodies). Top-level variable bindings (e.g. Haskell `main = do …`)
|
|
44
|
+
* are handled separately as a fallback tier.
|
|
31
45
|
*/
|
|
32
|
-
const
|
|
33
|
-
'.js',
|
|
34
|
-
'.mjs',
|
|
35
|
-
'.cjs',
|
|
36
|
-
'.jsx',
|
|
37
|
-
'.ts',
|
|
38
|
-
'.tsx',
|
|
39
|
-
'.mts',
|
|
40
|
-
'.cts',
|
|
41
|
-
]);
|
|
46
|
+
const CALLABLE_KINDS = new Set(['function', 'method']);
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Variable-like binding kinds that may act as top-level callers when no
|
|
50
|
+
* enclosing function/method exists (e.g. Haskell top-level `main` is a
|
|
51
|
+
* `bind` node → kind `variable`). Local variable declarations inside a
|
|
52
|
+
* function body must NOT win over the enclosing function.
|
|
53
|
+
*/
|
|
54
|
+
const TOP_LEVEL_BINDING_KINDS = new Set(['variable', 'constant']);
|
|
47
55
|
|
|
48
|
-
|
|
56
|
+
type Def = { name: string; kind: string; line: number; endLine?: number | null };
|
|
57
|
+
type CallerMatch = { id: number; name: string } | null;
|
|
49
58
|
|
|
50
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Find the narrowest enclosing function/method definition for `callLine`.
|
|
61
|
+
* Returns the DB node and name, or null if none encloses the call.
|
|
62
|
+
*/
|
|
63
|
+
function findEnclosingCallable(
|
|
51
64
|
lookup: CallNodeLookup,
|
|
52
|
-
|
|
53
|
-
definitions: ReadonlyArray<
|
|
54
|
-
name: string;
|
|
55
|
-
kind: string;
|
|
56
|
-
line: number;
|
|
57
|
-
endLine?: number | null;
|
|
58
|
-
}>,
|
|
65
|
+
callLine: number,
|
|
66
|
+
definitions: ReadonlyArray<Def>,
|
|
59
67
|
relPath: string,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let
|
|
63
|
-
let callerName: string | null = null;
|
|
64
|
-
let callerSpan = Infinity;
|
|
68
|
+
): CallerMatch {
|
|
69
|
+
let best: CallerMatch = null;
|
|
70
|
+
let bestSpan = Infinity;
|
|
65
71
|
for (const def of definitions) {
|
|
66
|
-
if (def.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
}
|
|
72
|
+
if (!CALLABLE_KINDS.has(def.kind)) continue;
|
|
73
|
+
if (def.line > callLine) continue;
|
|
74
|
+
const end = def.endLine ?? Infinity;
|
|
75
|
+
if (callLine > end) continue;
|
|
76
|
+
const span = end === Infinity ? Infinity : end - def.line;
|
|
77
|
+
if (span < bestSpan) {
|
|
78
|
+
const row = lookup.nodeId(def.name, def.kind, relPath, def.line);
|
|
79
|
+
if (row) {
|
|
80
|
+
best = { ...row, name: def.name };
|
|
81
|
+
bestSpan = span;
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
|
-
return
|
|
85
|
+
return best;
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Find the widest (outermost) enclosing variable/constant binding for `callLine`.
|
|
90
|
+
* Used as fallback for top-level bindings (e.g. Haskell `main = do …`).
|
|
91
|
+
* We pick the WIDEST span so that nested `let` bindings inside `main`'s
|
|
92
|
+
* do-block do not shadow `main` itself as the attributing caller.
|
|
93
|
+
*/
|
|
94
|
+
function findEnclosingBinding(
|
|
85
95
|
lookup: CallNodeLookup,
|
|
86
|
-
|
|
96
|
+
callLine: number,
|
|
97
|
+
definitions: ReadonlyArray<Def>,
|
|
87
98
|
relPath: string,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
typeMap.get(call.receiver) ??
|
|
103
|
-
// Phase 8.3f: callee-scoped rest-param key (`callee::restName`) to avoid
|
|
104
|
-
// same-name rest-binding collision across functions in the same file (#1358).
|
|
105
|
-
(callerName ? typeMap.get(`${callerName}::${effectiveReceiver}`) : undefined);
|
|
106
|
-
if (!typeEntry && call.receiver.startsWith('this.') && callerName) {
|
|
107
|
-
const dotIdx = callerName.lastIndexOf('.');
|
|
108
|
-
if (dotIdx > -1) {
|
|
109
|
-
const callerClass = callerName.slice(0, dotIdx);
|
|
110
|
-
typeEntry = typeMap.get(`${callerClass}.${effectiveReceiver}`);
|
|
99
|
+
): CallerMatch {
|
|
100
|
+
let best: CallerMatch = null;
|
|
101
|
+
let bestSpan = -1; // looking for WIDEST span, so start at -1
|
|
102
|
+
for (const def of definitions) {
|
|
103
|
+
if (!TOP_LEVEL_BINDING_KINDS.has(def.kind)) continue;
|
|
104
|
+
if (def.line > callLine) continue;
|
|
105
|
+
const end = def.endLine ?? Infinity;
|
|
106
|
+
if (callLine > end) continue;
|
|
107
|
+
const span = end === Infinity ? Infinity : end - def.line;
|
|
108
|
+
if (span > bestSpan) {
|
|
109
|
+
const row = lookup.nodeId(def.name, def.kind, relPath, def.line);
|
|
110
|
+
if (row) {
|
|
111
|
+
best = { ...row, name: def.name };
|
|
112
|
+
bestSpan = span;
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
: (typeEntry as { type?: string }).type
|
|
117
|
-
: null;
|
|
115
|
+
}
|
|
116
|
+
return best;
|
|
117
|
+
}
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (!typeName && call.receiver) {
|
|
129
|
-
const m = /^\(?\s*new\s+([A-Z_$][A-Za-z0-9_$]*)/.exec(call.receiver);
|
|
130
|
-
if (m?.[1]) typeName = m[1];
|
|
131
|
-
}
|
|
119
|
+
export function findCaller(
|
|
120
|
+
lookup: CallNodeLookup,
|
|
121
|
+
call: { line: number },
|
|
122
|
+
definitions: ReadonlyArray<Def>,
|
|
123
|
+
relPath: string,
|
|
124
|
+
fileNodeRow: { id: number },
|
|
125
|
+
): { id: number; callerName: string | null } {
|
|
126
|
+
// Pass 1: find the narrowest enclosing function/method.
|
|
127
|
+
const fnCaller = findEnclosingCallable(lookup, call.line, definitions, relPath);
|
|
132
128
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
// Prefer function/method enclosing scope over variable binding.
|
|
130
|
+
// Only fall back to a variable/constant binding when the call is at
|
|
131
|
+
// top-level scope (no enclosing function/method found), which handles
|
|
132
|
+
// languages like Haskell where `main` is a top-level `bind` node.
|
|
133
|
+
if (fnCaller) {
|
|
134
|
+
return { id: fnCaller.id, callerName: fnCaller.name };
|
|
135
|
+
}
|
|
138
136
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
? protoEntry
|
|
145
|
-
: (protoEntry as { type?: string }).type
|
|
146
|
-
: null;
|
|
147
|
-
if (protoTarget) {
|
|
148
|
-
const resolved = lookup
|
|
149
|
-
.byName(protoTarget)
|
|
150
|
-
.filter((t) => computeConfidence(relPath, t.file, null) >= 0.5);
|
|
151
|
-
if (resolved.length > 0) return resolved;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
137
|
+
// Pass 2: find the widest (outermost) enclosing variable/constant binding.
|
|
138
|
+
const varCaller = findEnclosingBinding(lookup, call.line, definitions, relPath);
|
|
139
|
+
if (varCaller) {
|
|
140
|
+
return { id: varCaller.id, callerName: varCaller.name };
|
|
141
|
+
}
|
|
154
142
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
// like `C6.staticMethod()` or `D.d()` where the receiver IS the class.
|
|
158
|
-
// Matches both 'method' and 'function' kinds to cover field-initializer synthetic defs.
|
|
159
|
-
if (!typeName) {
|
|
160
|
-
const qualifiedName = `${effectiveReceiver}.${call.name}`;
|
|
161
|
-
const direct = lookup
|
|
162
|
-
.byName(qualifiedName)
|
|
163
|
-
.filter(
|
|
164
|
-
(n) =>
|
|
165
|
-
(n.kind === 'method' || n.kind === 'function') &&
|
|
166
|
-
computeConfidence(relPath, n.file, null) >= 0.5,
|
|
167
|
-
);
|
|
168
|
-
if (direct.length > 0) return direct;
|
|
169
|
-
}
|
|
143
|
+
return { ...fileNodeRow, callerName: null };
|
|
144
|
+
}
|
|
170
145
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Dispatcher for call-site resolution.
|
|
148
|
+
*
|
|
149
|
+
* Delegates to two strategy helpers (in `../resolver/strategy.ts`) to keep
|
|
150
|
+
* each branch independently readable and under the complexity threshold:
|
|
151
|
+
* - resolveByReceiver — receiver is a concrete object/class reference
|
|
152
|
+
* - resolveByGlobal — bare call, or this/self/super receiver
|
|
153
|
+
*
|
|
154
|
+
* The original logic is unchanged; only the physical location moved.
|
|
155
|
+
*/
|
|
156
|
+
export function resolveByMethodOrGlobal(
|
|
157
|
+
lookup: CallNodeLookup,
|
|
158
|
+
call: { name: string; receiver?: string | null },
|
|
159
|
+
relPath: string,
|
|
160
|
+
typeMap: Map<string, unknown>,
|
|
161
|
+
callerName?: string | null,
|
|
162
|
+
): ReadonlyArray<{ id: number; file: string }> {
|
|
163
|
+
if (
|
|
164
|
+
call.receiver &&
|
|
165
|
+
call.receiver !== 'this' &&
|
|
166
|
+
call.receiver !== 'self' &&
|
|
167
|
+
call.receiver !== 'super'
|
|
168
|
+
) {
|
|
169
|
+
return resolveByReceiver(
|
|
170
|
+
lookup,
|
|
171
|
+
call as { name: string; receiver: string },
|
|
172
|
+
relPath,
|
|
173
|
+
typeMap,
|
|
174
|
+
callerName,
|
|
175
|
+
);
|
|
185
176
|
}
|
|
186
177
|
if (
|
|
187
178
|
!call.receiver ||
|
|
@@ -189,68 +180,7 @@ export function resolveByMethodOrGlobal(
|
|
|
189
180
|
call.receiver === 'self' ||
|
|
190
181
|
call.receiver === 'super'
|
|
191
182
|
) {
|
|
192
|
-
|
|
193
|
-
// When a plain function (no class prefix) is registered as a get/set accessor for `obj`
|
|
194
|
-
// via Object.defineProperty, typeMap seeds 'callerName:this' = 'obj'.
|
|
195
|
-
// We then resolve this.method() → typeMap['obj.method'] → the concrete definition.
|
|
196
|
-
// This runs before the broad exact-name lookup to avoid false positives from
|
|
197
|
-
// unrelated same-file definitions.
|
|
198
|
-
if (call.receiver === 'this' && callerName && !callerName.includes('.')) {
|
|
199
|
-
const accessorThisEntry = typeMap.get(`${callerName}:this`);
|
|
200
|
-
const objName = accessorThisEntry
|
|
201
|
-
? typeof accessorThisEntry === 'string'
|
|
202
|
-
? accessorThisEntry
|
|
203
|
-
: (accessorThisEntry as { type?: string }).type
|
|
204
|
-
: null;
|
|
205
|
-
if (objName) {
|
|
206
|
-
const objMethodEntry = typeMap.get(`${objName}.${call.name}`);
|
|
207
|
-
const targetFn = objMethodEntry
|
|
208
|
-
? typeof objMethodEntry === 'string'
|
|
209
|
-
? objMethodEntry
|
|
210
|
-
: (objMethodEntry as { type?: string }).type
|
|
211
|
-
: null;
|
|
212
|
-
if (targetFn) {
|
|
213
|
-
const resolved = lookup
|
|
214
|
-
.byName(targetFn)
|
|
215
|
-
.filter((t) => computeConfidence(relPath, t.file, null) >= 0.5);
|
|
216
|
-
if (resolved.length > 0) return resolved;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const exact = lookup
|
|
222
|
-
.byName(call.name)
|
|
223
|
-
.filter((t) => computeConfidence(relPath, t.file, null) >= 0.5);
|
|
224
|
-
if (exact.length > 0) return exact;
|
|
225
|
-
|
|
226
|
-
// Try same-class method lookup via callerName.
|
|
227
|
-
// e.g. `this.area()` inside `Shape.describe` → try `Shape.area`.
|
|
228
|
-
// Also covers no-receiver calls inside class methods, e.g. `IsValidEmail(x)` inside
|
|
229
|
-
// `Validators.ValidateUser` → try `Validators.IsValidEmail` (C#/Java static siblings).
|
|
230
|
-
// This seeds the initial edge that runChaPostPass later expands to subclass overrides.
|
|
231
|
-
//
|
|
232
|
-
// For JS/TS, bare (no-receiver) calls are module-scoped — there is no implicit class
|
|
233
|
-
// binding. Skip the same-class fallback for bare calls in those languages to prevent
|
|
234
|
-
// false positives (e.g. `flush()` inside `Processor.run` must not resolve to
|
|
235
|
-
// `Processor.flush`). this.method() calls are unaffected: they still reach the fallback
|
|
236
|
-
// because `call.receiver === 'this'` is truthy, not a bare call.
|
|
237
|
-
const isBareCall = !call.receiver;
|
|
238
|
-
if (callerName && !(isBareCall && isModuleScopedLanguage(relPath))) {
|
|
239
|
-
const dotIdx = callerName.lastIndexOf('.');
|
|
240
|
-
if (dotIdx > -1) {
|
|
241
|
-
// Extract only the segment immediately before the method name so that
|
|
242
|
-
// 'Namespace.ClassName.method' yields 'ClassName', not 'Namespace.ClassName'.
|
|
243
|
-
// Symbols are stored under their bare class name, not their qualified path.
|
|
244
|
-
const prevDot = callerName.lastIndexOf('.', dotIdx - 1);
|
|
245
|
-
const callerClass = callerName.slice(prevDot + 1, dotIdx);
|
|
246
|
-
const qualifiedName = `${callerClass}.${call.name}`;
|
|
247
|
-
const sameClass = lookup
|
|
248
|
-
.byName(qualifiedName)
|
|
249
|
-
.filter((t) => t.kind === 'method' && computeConfidence(relPath, t.file, null) >= 0.5);
|
|
250
|
-
if (sameClass.length > 0) return sameClass;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return exact; // empty
|
|
183
|
+
return resolveByGlobal(lookup, call, relPath, typeMap, callerName);
|
|
254
184
|
}
|
|
255
185
|
return [];
|
|
256
186
|
}
|
|
@@ -263,6 +193,12 @@ export function resolveCallTargets(
|
|
|
263
193
|
typeMap: Map<string, unknown>,
|
|
264
194
|
callerName?: string | null,
|
|
265
195
|
): { targets: Array<{ id: number; file: string }>; importedFrom: string | undefined } {
|
|
196
|
+
// Flagged dynamic calls use synthetic names like '<dynamic:eval>'. Short-circuit
|
|
197
|
+
// so they never accidentally match a real symbol via lookup.byName.
|
|
198
|
+
if (call.name.startsWith('<dynamic:')) {
|
|
199
|
+
return { targets: [], importedFrom: undefined };
|
|
200
|
+
}
|
|
201
|
+
|
|
266
202
|
const importedFrom = importedNames.get(call.name);
|
|
267
203
|
let targets: ReadonlyArray<{ id: number; file: string }> | undefined;
|
|
268
204
|
|
|
@@ -299,13 +235,17 @@ export function resolveCallTargets(
|
|
|
299
235
|
* Returns the edge tuple to insert, or null if nothing matched or the edge
|
|
300
236
|
* was already seen. Callers are responsible for the actual DB/array insert.
|
|
301
237
|
*
|
|
302
|
-
* Receiver resolution
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
238
|
+
* Receiver resolution:
|
|
239
|
+
* 1. Look up same-file nodes for `effectiveReceiver` (unfiltered by kind).
|
|
240
|
+
* 2. If any same-file node exists AND `effectiveReceiver` is not in `importedNames`
|
|
241
|
+
* (i.e. it is a locally-defined symbol, not an import artifact), apply
|
|
242
|
+
* RECEIVER_KINDS and return the filtered set — no global fallback.
|
|
243
|
+
* A local `function C(){}` means this file owns `C`; no cross-file class
|
|
244
|
+
* should win over it (issue #1539).
|
|
245
|
+
* 3. If the same-file node IS an import artifact (e.g. destructured require),
|
|
246
|
+
* or no same-file node exists at all, fall back to global candidates filtered
|
|
247
|
+
* by RECEIVER_KINDS. This preserves the pre-#1539 behaviour for cases where
|
|
248
|
+
* an imported name appears as kind='function' in the importer file.
|
|
309
249
|
*/
|
|
310
250
|
export function resolveReceiverEdge(
|
|
311
251
|
lookup: CallNodeLookup,
|
|
@@ -314,6 +254,7 @@ export function resolveReceiverEdge(
|
|
|
314
254
|
relPath: string,
|
|
315
255
|
typeMap: Map<string, unknown>,
|
|
316
256
|
seenCallEdges: Set<string>,
|
|
257
|
+
importedNames: ReadonlyMap<string, string>,
|
|
317
258
|
): { callerId: number; receiverId: number; confidence: number } | null {
|
|
318
259
|
const typeEntry = typeMap.get(call.receiver);
|
|
319
260
|
const typeName = typeEntry
|
|
@@ -326,18 +267,15 @@ export function resolveReceiverEdge(
|
|
|
326
267
|
? ((typeEntry as { confidence?: number }).confidence ?? null)
|
|
327
268
|
: null;
|
|
328
269
|
const effectiveReceiver = typeName || call.receiver;
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const sameFileCandidates =
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
sameFileCandidates.length > 0
|
|
339
|
-
? sameFileCandidates
|
|
340
|
-
: lookup.byName(effectiveReceiver).filter((n) => RECEIVER_KINDS.has(n.kind ?? ''));
|
|
270
|
+
// Block global fallback only when the same-file node is a local definition,
|
|
271
|
+
// not when it's an import artifact (e.g. `const { C } = require(…)` seeds a
|
|
272
|
+
// kind='function' node in the importer but the real class lives elsewhere).
|
|
273
|
+
const sameFileAll = lookup.byNameAndFile(effectiveReceiver, relPath);
|
|
274
|
+
const isLocalDefinition = sameFileAll.length > 0 && !importedNames?.has(effectiveReceiver);
|
|
275
|
+
const sameFileCandidates = sameFileAll.filter((n) => RECEIVER_KINDS.has(n.kind ?? ''));
|
|
276
|
+
const candidates = isLocalDefinition
|
|
277
|
+
? sameFileCandidates
|
|
278
|
+
: lookup.byName(effectiveReceiver).filter((n) => RECEIVER_KINDS.has(n.kind ?? ''));
|
|
341
279
|
if (candidates.length === 0) return null;
|
|
342
280
|
const recvTarget = candidates[0]!;
|
|
343
281
|
const recvKey = `recv|${caller.id}|${recvTarget.id}`;
|
|
@@ -96,6 +96,14 @@ export function buildChaContext(fileSymbols: ReadonlyMap<string, ExtractorOutput
|
|
|
96
96
|
* For `super`, resolution starts from the parent of the caller's class.
|
|
97
97
|
* For `this`/`self`, resolution starts from the caller's own class and walks
|
|
98
98
|
* up the inheritance chain (supporting inherited method lookup).
|
|
99
|
+
*
|
|
100
|
+
* When `callerFile` is provided, same-file method nodes are preferred: if the
|
|
101
|
+
* hierarchy walk finds a qualified method that exists in both the caller's own
|
|
102
|
+
* file AND in unrelated files (e.g. a class named `A` that appears in multiple
|
|
103
|
+
* fixture files), only the same-file nodes are returned. This prevents
|
|
104
|
+
* cross-fixture false edges caused by accidental name collisions across
|
|
105
|
+
* unrelated files in the same project build. When no same-file nodes exist,
|
|
106
|
+
* all found nodes are returned as before.
|
|
99
107
|
*/
|
|
100
108
|
export function resolveThisDispatch(
|
|
101
109
|
methodName: string,
|
|
@@ -103,6 +111,7 @@ export function resolveThisDispatch(
|
|
|
103
111
|
receiver: 'this' | 'self' | 'super',
|
|
104
112
|
chaCtx: ChaContext,
|
|
105
113
|
lookup: CallNodeLookup,
|
|
114
|
+
callerFile?: string | null,
|
|
106
115
|
): ReadonlyArray<{ id: number; file: string }> {
|
|
107
116
|
if (!callerName) return [];
|
|
108
117
|
const dotIdx = callerName.indexOf('.');
|
|
@@ -119,7 +128,15 @@ export function resolveThisDispatch(
|
|
|
119
128
|
visited.add(current);
|
|
120
129
|
const qualified = `${current}.${methodName}`;
|
|
121
130
|
const found = lookup.byName(qualified).filter((n) => n.kind === 'method');
|
|
122
|
-
if (found.length > 0)
|
|
131
|
+
if (found.length > 0) {
|
|
132
|
+
// When the caller's file is known, prefer same-file nodes to avoid
|
|
133
|
+
// emitting cross-file edges to identically-named methods in unrelated
|
|
134
|
+
// files. Only fall back to the full set when no same-file node exists.
|
|
135
|
+
if (callerFile && found.some((n) => n.file === callerFile)) {
|
|
136
|
+
return found.filter((n) => n.file === callerFile);
|
|
137
|
+
}
|
|
138
|
+
return found;
|
|
139
|
+
}
|
|
123
140
|
current = chaCtx.parents.get(current);
|
|
124
141
|
}
|
|
125
142
|
return [];
|