@optave/codegraph 3.13.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 +35 -34
- 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/config.d.ts.map +1 -1
- package/dist/cli/commands/config.js +137 -134
- package/dist/cli/commands/config.js.map +1 -1
- 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/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 +68 -0
- 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 +17 -5
- package/dist/domain/graph/builder/call-resolver.d.ts.map +1 -1
- package/dist/domain/graph/builder/call-resolver.js +85 -220
- package/dist/domain/graph/builder/call-resolver.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 +16 -1
- package/dist/domain/graph/builder/helpers.d.ts.map +1 -1
- package/dist/domain/graph/builder/helpers.js +162 -72
- 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 +10 -4
- package/dist/domain/graph/builder/pipeline.js.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.js +496 -250
- 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 +2 -1
- package/dist/domain/graph/builder/stages/detect-changes.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 +895 -545
- package/dist/domain/graph/builder/stages/native-orchestrator.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 +12 -0
- package/dist/domain/parser.d.ts.map +1 -1
- package/dist/domain/parser.js +12 -2
- 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 +3 -0
- 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 +24 -5
- package/dist/domain/wasm-worker-pool.js.map +1 -1
- package/dist/domain/wasm-worker-protocol.d.ts +7 -0
- package/dist/domain/wasm-worker-protocol.d.ts.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 +4 -2
- package/dist/extractors/helpers.d.ts.map +1 -1
- package/dist/extractors/helpers.js +5 -1
- package/dist/extractors/helpers.js.map +1 -1
- package/dist/extractors/java.js +77 -1
- package/dist/extractors/java.js.map +1 -1
- package/dist/extractors/javascript.d.ts.map +1 -1
- package/dist/extractors/javascript.js +549 -163
- 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.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/infrastructure/config.d.ts +10 -0
- package/dist/infrastructure/config.d.ts.map +1 -1
- package/dist/infrastructure/config.js +31 -3
- package/dist/infrastructure/config.js.map +1 -1
- package/dist/infrastructure/registry.d.ts +0 -7
- package/dist/infrastructure/registry.d.ts.map +1 -1
- package/dist/infrastructure/registry.js +29 -13
- 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/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 +76 -1
- package/dist/types.d.ts.map +1 -1
- package/grammars/tree-sitter-erlang.wasm +0 -0
- package/package.json +7 -7
- 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/config.ts +184 -184
- package/src/cli/commands/roles.ts +6 -1
- 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 +68 -0
- 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 +112 -232
- package/src/domain/graph/builder/context.ts +1 -0
- package/src/domain/graph/builder/helpers.ts +190 -72
- package/src/domain/graph/builder/incremental.ts +249 -120
- package/src/domain/graph/builder/pipeline.ts +11 -5
- package/src/domain/graph/builder/stages/build-edges.ts +696 -296
- package/src/domain/graph/builder/stages/collect-files.ts +12 -6
- package/src/domain/graph/builder/stages/detect-changes.ts +3 -1
- package/src/domain/graph/builder/stages/native-orchestrator.ts +1102 -590
- 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 +12 -2
- package/src/domain/queries.ts +1 -1
- package/src/domain/wasm-worker-entry.ts +3 -0
- package/src/domain/wasm-worker-pool.ts +28 -4
- package/src/domain/wasm-worker-protocol.ts +4 -0
- package/src/extractors/dart.ts +48 -3
- package/src/extractors/groovy.ts +62 -2
- package/src/extractors/helpers.ts +5 -2
- package/src/extractors/java.ts +80 -1
- package/src/extractors/javascript.ts +566 -161
- 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.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/infrastructure/config.ts +32 -3
- package/src/infrastructure/registry.ts +44 -20
- 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/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 +86 -1
|
@@ -358,6 +358,32 @@ function reconcileCfgCyclomatic(fileSymbols: Map<string, ExtractorOutput>): void
|
|
|
358
358
|
|
|
359
359
|
// ─── WASM pre-parse ─────────────────────────────────────────────────────
|
|
360
360
|
|
|
361
|
+
// ─── Per-file analysis predicates ───────────────────────────────────────
|
|
362
|
+
|
|
363
|
+
/** Whether a file needs WASM AST extraction (astNodes not yet populated). */
|
|
364
|
+
function fileNeedsWasmAst(symbols: ExtractorOutput, ext: string, lid: string): boolean {
|
|
365
|
+
return !Array.isArray(symbols.astNodes) && (WALK_EXTENSIONS.has(ext) || AST_TYPE_MAPS.has(lid));
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** Whether a file needs WASM complexity analysis (any function body missing metrics). */
|
|
369
|
+
function fileNeedsWasmComplexity(symbols: ExtractorOutput, ext: string, lid: string): boolean {
|
|
370
|
+
if (!COMPLEXITY_EXTENSIONS.has(ext) && !COMPLEXITY_RULES.has(lid)) return false;
|
|
371
|
+
const defs = symbols.definitions || [];
|
|
372
|
+
return defs.some((d) => hasFuncBody(d) && !d.complexity);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** Whether a file needs WASM CFG analysis (any function body missing CFG blocks). */
|
|
376
|
+
function fileNeedsWasmCfg(symbols: ExtractorOutput, ext: string, lid: string): boolean {
|
|
377
|
+
if (!CFG_EXTENSIONS.has(ext) && !CFG_RULES.has(lid)) return false;
|
|
378
|
+
const defs = symbols.definitions || [];
|
|
379
|
+
return defs.some((d) => hasFuncBody(d) && d.cfg !== null && !Array.isArray(d.cfg?.blocks));
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** Whether a file needs WASM dataflow analysis (dataflow not yet populated). */
|
|
383
|
+
function fileNeedsWasmDataflow(symbols: ExtractorOutput, ext: string, lid: string): boolean {
|
|
384
|
+
return !symbols.dataflow && (DATAFLOW_EXTENSIONS.has(ext) || DATAFLOW_RULES.has(lid));
|
|
385
|
+
}
|
|
386
|
+
|
|
361
387
|
/** Check whether a single file needs a WASM tree for any enabled analysis pass. */
|
|
362
388
|
function fileNeedsWasmTree(
|
|
363
389
|
relPath: string,
|
|
@@ -366,33 +392,12 @@ function fileNeedsWasmTree(
|
|
|
366
392
|
): boolean {
|
|
367
393
|
if (symbols._tree) return false;
|
|
368
394
|
const ext = path.extname(relPath).toLowerCase();
|
|
369
|
-
const defs = symbols.definitions || [];
|
|
370
395
|
const lid = symbols._langId || '';
|
|
371
396
|
|
|
372
|
-
if (
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
)
|
|
377
|
-
return true;
|
|
378
|
-
if (
|
|
379
|
-
flags.doComplexity &&
|
|
380
|
-
(COMPLEXITY_EXTENSIONS.has(ext) || COMPLEXITY_RULES.has(lid)) &&
|
|
381
|
-
defs.some((d) => hasFuncBody(d) && !d.complexity)
|
|
382
|
-
)
|
|
383
|
-
return true;
|
|
384
|
-
if (
|
|
385
|
-
flags.doCfg &&
|
|
386
|
-
(CFG_EXTENSIONS.has(ext) || CFG_RULES.has(lid)) &&
|
|
387
|
-
defs.some((d) => hasFuncBody(d) && d.cfg !== null && !Array.isArray(d.cfg?.blocks))
|
|
388
|
-
)
|
|
389
|
-
return true;
|
|
390
|
-
if (
|
|
391
|
-
flags.doDataflow &&
|
|
392
|
-
!symbols.dataflow &&
|
|
393
|
-
(DATAFLOW_EXTENSIONS.has(ext) || DATAFLOW_RULES.has(lid))
|
|
394
|
-
)
|
|
395
|
-
return true;
|
|
397
|
+
if (flags.doAst && fileNeedsWasmAst(symbols, ext, lid)) return true;
|
|
398
|
+
if (flags.doComplexity && fileNeedsWasmComplexity(symbols, ext, lid)) return true;
|
|
399
|
+
if (flags.doCfg && fileNeedsWasmCfg(symbols, ext, lid)) return true;
|
|
400
|
+
if (flags.doDataflow && fileNeedsWasmDataflow(symbols, ext, lid)) return true;
|
|
396
401
|
return false;
|
|
397
402
|
}
|
|
398
403
|
|
|
@@ -701,50 +706,25 @@ function allNativeDataComplete(
|
|
|
701
706
|
const ext = path.extname(relPath).toLowerCase();
|
|
702
707
|
const langId = symbols._langId || '';
|
|
703
708
|
|
|
704
|
-
|
|
705
|
-
if (
|
|
706
|
-
doAst &&
|
|
707
|
-
!Array.isArray(symbols.astNodes) &&
|
|
708
|
-
(WALK_EXTENSIONS.has(ext) || AST_TYPE_MAPS.has(langId))
|
|
709
|
-
) {
|
|
709
|
+
if (doAst && fileNeedsWasmAst(symbols, ext, langId)) {
|
|
710
710
|
debug(`allNativeDataComplete: ${relPath} missing astNodes`);
|
|
711
711
|
return false;
|
|
712
712
|
}
|
|
713
|
-
|
|
714
|
-
// Dataflow: native must have produced it
|
|
715
|
-
if (
|
|
716
|
-
doDataflow &&
|
|
717
|
-
!symbols.dataflow &&
|
|
718
|
-
(DATAFLOW_EXTENSIONS.has(ext) || DATAFLOW_RULES.has(langId))
|
|
719
|
-
) {
|
|
713
|
+
if (doDataflow && fileNeedsWasmDataflow(symbols, ext, langId)) {
|
|
720
714
|
debug(`allNativeDataComplete: ${relPath} missing dataflow`);
|
|
721
715
|
return false;
|
|
722
716
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
debug(`allNativeDataComplete: ${relPath}:${def.name} missing complexity`);
|
|
735
|
-
return false;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
// CFG: every function must already have blocks
|
|
739
|
-
if (
|
|
740
|
-
doCfg &&
|
|
741
|
-
def.cfg !== null &&
|
|
742
|
-
!Array.isArray(def.cfg?.blocks) &&
|
|
743
|
-
(CFG_EXTENSIONS.has(ext) || CFG_RULES.has(langId))
|
|
744
|
-
) {
|
|
745
|
-
debug(`allNativeDataComplete: ${relPath}:${def.name} missing cfg blocks`);
|
|
746
|
-
return false;
|
|
747
|
-
}
|
|
717
|
+
if (doComplexity && fileNeedsWasmComplexity(symbols, ext, langId)) {
|
|
718
|
+
const offender = (symbols.definitions || []).find((d) => hasFuncBody(d) && !d.complexity);
|
|
719
|
+
debug(`allNativeDataComplete: ${relPath}:${offender?.name ?? '?'} missing complexity`);
|
|
720
|
+
return false;
|
|
721
|
+
}
|
|
722
|
+
if (doCfg && fileNeedsWasmCfg(symbols, ext, langId)) {
|
|
723
|
+
const offender = (symbols.definitions || []).find(
|
|
724
|
+
(d) => hasFuncBody(d) && d.cfg !== null && !Array.isArray(d.cfg?.blocks),
|
|
725
|
+
);
|
|
726
|
+
debug(`allNativeDataComplete: ${relPath}:${offender?.name ?? '?'} missing cfg blocks`);
|
|
727
|
+
return false;
|
|
748
728
|
}
|
|
749
729
|
}
|
|
750
730
|
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import type { DataflowRulesConfig, TreeSitterNode } from '../../types.js';
|
|
2
|
+
import { makeDataflowRules } from '../shared.js';
|
|
3
|
+
|
|
4
|
+
// ─── Kotlin ───────────────────────────────────────────────────────────────────
|
|
5
|
+
//
|
|
6
|
+
// Kotlin function_declaration wraps params in `function_value_parameters`.
|
|
7
|
+
// The name is a `simple_identifier` direct child (found via findChild in extractor).
|
|
8
|
+
// call_expression: first child is simple_identifier OR navigation_expression (method call).
|
|
9
|
+
// navigation_expression: acts as member access for `obj.method()`.
|
|
10
|
+
// Field names for call function/args are NOT standard named fields in tree-sitter-kotlin,
|
|
11
|
+
// so we leave callFunctionField/callArgsField at defaults — childForFieldName returns null
|
|
12
|
+
// gracefully and the analysis falls back to skipping arg tracking.
|
|
13
|
+
|
|
14
|
+
function getKotlinParamListNode(funcNode: TreeSitterNode): TreeSitterNode | null {
|
|
15
|
+
for (const child of funcNode.namedChildren) {
|
|
16
|
+
if (child.type === 'function_value_parameters') return child;
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function extractKotlinParamName(node: TreeSitterNode): string[] | null {
|
|
22
|
+
if (node.type !== 'parameter') return null;
|
|
23
|
+
const nameNode = node.childForFieldName('name');
|
|
24
|
+
if (nameNode) return [nameNode.text];
|
|
25
|
+
// Fallback: find simple_identifier among named children
|
|
26
|
+
for (const child of node.namedChildren) {
|
|
27
|
+
if (child.type === 'simple_identifier') return [child.text];
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const dataflowKotlin: DataflowRulesConfig = makeDataflowRules({
|
|
33
|
+
functionNodes: new Set(['function_declaration']),
|
|
34
|
+
nameField: 'name',
|
|
35
|
+
|
|
36
|
+
getParamListNode: getKotlinParamListNode,
|
|
37
|
+
paramWrapperTypes: new Set(['parameter']),
|
|
38
|
+
extractParamName: extractKotlinParamName,
|
|
39
|
+
|
|
40
|
+
returnNode: 'return_statement',
|
|
41
|
+
|
|
42
|
+
callNode: 'call_expression',
|
|
43
|
+
// tree-sitter-kotlin does not expose standard named fields for call function/args;
|
|
44
|
+
// defaults ('function'/'arguments') will return null gracefully.
|
|
45
|
+
|
|
46
|
+
memberNode: 'navigation_expression',
|
|
47
|
+
// Field names for navigation_expression object/property also lack standard names;
|
|
48
|
+
// defaults will return null gracefully.
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// ─── Swift ────────────────────────────────────────────────────────────────────
|
|
52
|
+
//
|
|
53
|
+
// Swift function_declaration: name is `simple_identifier`, params in child node.
|
|
54
|
+
// The extractor uses findChild(node, 'simple_identifier') for the function name.
|
|
55
|
+
// Swift's tree-sitter grammar wraps params in a `parameter` or `parameters` node.
|
|
56
|
+
// call_expression: first child is simple_identifier or navigation_expression.
|
|
57
|
+
// navigation_expression: obj.method() — last child is navigation_suffix > simple_identifier.
|
|
58
|
+
|
|
59
|
+
function getSwiftParamListNode(funcNode: TreeSitterNode): TreeSitterNode | null {
|
|
60
|
+
// Look for parameter_clause or parameters as a direct child
|
|
61
|
+
for (let i = 0; i < funcNode.childCount; i++) {
|
|
62
|
+
const child = funcNode.child(i);
|
|
63
|
+
if (!child) continue;
|
|
64
|
+
if (child.type === 'parameter_clause' || child.type === 'parameters') return child;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function extractSwiftParamName(node: TreeSitterNode): string[] | null {
|
|
70
|
+
if (node.type === 'parameter') {
|
|
71
|
+
// Swift parameters have internal label + external label; use internal name
|
|
72
|
+
// The `name` field in tree-sitter-swift is the internal parameter name
|
|
73
|
+
const nameNode = node.childForFieldName('name') ?? node.childForFieldName('internal_name');
|
|
74
|
+
if (nameNode) return [nameNode.text];
|
|
75
|
+
// Fallback: find simple_identifier
|
|
76
|
+
for (const child of node.namedChildren) {
|
|
77
|
+
if (child.type === 'simple_identifier') return [child.text];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const dataflowSwift: DataflowRulesConfig = makeDataflowRules({
|
|
84
|
+
functionNodes: new Set(['function_declaration']),
|
|
85
|
+
nameField: 'name',
|
|
86
|
+
|
|
87
|
+
getParamListNode: getSwiftParamListNode,
|
|
88
|
+
paramWrapperTypes: new Set(['parameter']),
|
|
89
|
+
extractParamName: extractSwiftParamName,
|
|
90
|
+
|
|
91
|
+
returnNode: 'return_statement',
|
|
92
|
+
|
|
93
|
+
callNode: 'call_expression',
|
|
94
|
+
// tree-sitter-swift call_expression: function is first child, args follow.
|
|
95
|
+
// No standard named fields — leave defaults to return null gracefully.
|
|
96
|
+
|
|
97
|
+
memberNode: 'navigation_expression',
|
|
98
|
+
// navigation_expression field names are non-standard in tree-sitter-swift.
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// ─── Scala ────────────────────────────────────────────────────────────────────
|
|
102
|
+
//
|
|
103
|
+
// Scala function_definition: `node.childForFieldName('name')` for the name (confirmed
|
|
104
|
+
// in extractor). Parameters are via findChild(funcNode, 'parameters') (no named field).
|
|
105
|
+
// call_expression: `childForFieldName('function')` confirmed in extractor line 146.
|
|
106
|
+
// field_expression: `childForFieldName('value')` = object, `childForFieldName('field')` = property.
|
|
107
|
+
// val_definition / var_definition: `childForFieldName('pattern')` = name side.
|
|
108
|
+
|
|
109
|
+
function getScalaParamListNode(funcNode: TreeSitterNode): TreeSitterNode | null {
|
|
110
|
+
// Scala parameters list is a direct child; extractor uses findChild(funcNode, 'parameters')
|
|
111
|
+
for (let i = 0; i < funcNode.childCount; i++) {
|
|
112
|
+
const child = funcNode.child(i);
|
|
113
|
+
if (child?.type === 'parameters') return child;
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function extractScalaParamName(node: TreeSitterNode): string[] | null {
|
|
119
|
+
if (node.type !== 'parameter') return null;
|
|
120
|
+
// Extractor uses findChild(param, 'identifier')
|
|
121
|
+
for (const child of node.namedChildren) {
|
|
122
|
+
if (child.type === 'identifier') return [child.text];
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const dataflowScala: DataflowRulesConfig = makeDataflowRules({
|
|
128
|
+
functionNodes: new Set(['function_definition']),
|
|
129
|
+
nameField: 'name',
|
|
130
|
+
|
|
131
|
+
getParamListNode: getScalaParamListNode,
|
|
132
|
+
paramWrapperTypes: new Set(['parameter']),
|
|
133
|
+
extractParamName: extractScalaParamName,
|
|
134
|
+
|
|
135
|
+
returnNode: 'return_expression',
|
|
136
|
+
|
|
137
|
+
varDeclaratorNodes: new Set(['val_definition', 'var_definition']),
|
|
138
|
+
varNameField: 'pattern',
|
|
139
|
+
|
|
140
|
+
callNode: 'call_expression',
|
|
141
|
+
callFunctionField: 'function',
|
|
142
|
+
callArgsField: 'arguments',
|
|
143
|
+
|
|
144
|
+
memberNode: 'field_expression',
|
|
145
|
+
memberObjectField: 'value',
|
|
146
|
+
memberPropertyField: 'field',
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// ─── Dart ─────────────────────────────────────────────────────────────────────
|
|
150
|
+
//
|
|
151
|
+
// Dart uses `function_signature` for top-level functions and `method_signature`
|
|
152
|
+
// for class methods (both confirmed in extractor). The extractor uses
|
|
153
|
+
// `childForFieldName('name')` for the function name on both node types.
|
|
154
|
+
// Dart call: `selector` node with `argument_part` — the extractor uses this.
|
|
155
|
+
// There is no standard `call_expression` node type in tree-sitter-dart.
|
|
156
|
+
// We use `function_signature` as the primary function node type.
|
|
157
|
+
// Parameters: `childForFieldName('parameters')` on function_signature (confirmed in extractor).
|
|
158
|
+
|
|
159
|
+
function extractDartParamName(node: TreeSitterNode): string[] | null {
|
|
160
|
+
// Dart: parameter types include 'formal_parameter', 'named_formal_parameter',
|
|
161
|
+
// 'optional_formal_parameter', and bare 'identifier'
|
|
162
|
+
if (
|
|
163
|
+
node.type === 'formal_parameter' ||
|
|
164
|
+
node.type === 'optional_formal_parameter' ||
|
|
165
|
+
node.type === 'named_formal_parameter'
|
|
166
|
+
) {
|
|
167
|
+
const nameNode = node.childForFieldName('name');
|
|
168
|
+
if (nameNode) return [nameNode.text];
|
|
169
|
+
// Fallback: last identifier child is usually the name
|
|
170
|
+
let lastName: string | null = null;
|
|
171
|
+
for (const child of node.namedChildren) {
|
|
172
|
+
if (child.type === 'identifier') lastName = child.text;
|
|
173
|
+
}
|
|
174
|
+
if (lastName) return [lastName];
|
|
175
|
+
}
|
|
176
|
+
if (node.type === 'identifier') return [node.text];
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export const dataflowDart: DataflowRulesConfig = makeDataflowRules({
|
|
181
|
+
functionNodes: new Set(['function_signature', 'method_signature']),
|
|
182
|
+
nameField: 'name',
|
|
183
|
+
|
|
184
|
+
paramListField: 'parameters',
|
|
185
|
+
paramWrapperTypes: new Set([
|
|
186
|
+
'formal_parameter',
|
|
187
|
+
'optional_formal_parameter',
|
|
188
|
+
'named_formal_parameter',
|
|
189
|
+
]),
|
|
190
|
+
extractParamName: extractDartParamName,
|
|
191
|
+
|
|
192
|
+
returnNode: 'return_statement',
|
|
193
|
+
|
|
194
|
+
callNode: 'call_expression',
|
|
195
|
+
// tree-sitter-dart does not have standard named fields for calls;
|
|
196
|
+
// the extractor uses `selector` nodes instead. Leave defaults.
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// ─── Groovy ───────────────────────────────────────────────────────────────────
|
|
200
|
+
//
|
|
201
|
+
// Groovy has multiple function node types (method_definition/declaration,
|
|
202
|
+
// constructor_definition/declaration, function_definition/declaration).
|
|
203
|
+
// Params: `childForFieldName('parameters')` with fallback to findChild('formal_parameters')
|
|
204
|
+
// (confirmed in extractor extractGroovyParams, line 334).
|
|
205
|
+
// call_expression: `childForFieldName('function')` confirmed in extractor line 299.
|
|
206
|
+
// field_expression: `childForFieldName('argument')` = object (confirmed in extractor line 303),
|
|
207
|
+
// `childForFieldName('field')` = property.
|
|
208
|
+
|
|
209
|
+
function getGroovyParamListNode(funcNode: TreeSitterNode): TreeSitterNode | null {
|
|
210
|
+
const byField = funcNode.childForFieldName('parameters');
|
|
211
|
+
if (byField) return byField;
|
|
212
|
+
// Fallback: search for formal_parameters child
|
|
213
|
+
for (let i = 0; i < funcNode.childCount; i++) {
|
|
214
|
+
const child = funcNode.child(i);
|
|
215
|
+
if (child?.type === 'formal_parameters') return child;
|
|
216
|
+
}
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function extractGroovyParamName(node: TreeSitterNode): string[] | null {
|
|
221
|
+
if (node.type === 'formal_parameter' || node.type === 'parameter') {
|
|
222
|
+
const nameNode = node.childForFieldName('name');
|
|
223
|
+
if (nameNode) return [nameNode.text];
|
|
224
|
+
// Fallback: first identifier child
|
|
225
|
+
for (const child of node.namedChildren) {
|
|
226
|
+
if (child.type === 'identifier') return [child.text];
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export const dataflowGroovy: DataflowRulesConfig = makeDataflowRules({
|
|
233
|
+
functionNodes: new Set([
|
|
234
|
+
'method_definition',
|
|
235
|
+
'method_declaration',
|
|
236
|
+
'constructor_definition',
|
|
237
|
+
'constructor_declaration',
|
|
238
|
+
'function_definition',
|
|
239
|
+
'function_declaration',
|
|
240
|
+
]),
|
|
241
|
+
nameField: 'name',
|
|
242
|
+
|
|
243
|
+
getParamListNode: getGroovyParamListNode,
|
|
244
|
+
paramWrapperTypes: new Set(['formal_parameter', 'parameter']),
|
|
245
|
+
extractParamName: extractGroovyParamName,
|
|
246
|
+
|
|
247
|
+
returnNode: 'return_statement',
|
|
248
|
+
|
|
249
|
+
varDeclaratorNode: 'variable_declarator',
|
|
250
|
+
|
|
251
|
+
callNodes: new Set([
|
|
252
|
+
'call_expression',
|
|
253
|
+
'function_call',
|
|
254
|
+
'juxt_function_call',
|
|
255
|
+
'method_invocation',
|
|
256
|
+
]),
|
|
257
|
+
callFunctionField: 'function',
|
|
258
|
+
callArgsField: 'arguments',
|
|
259
|
+
|
|
260
|
+
memberNode: 'field_expression',
|
|
261
|
+
memberObjectField: 'argument',
|
|
262
|
+
memberPropertyField: 'field',
|
|
263
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { DataflowRulesConfig } from '../../types.js';
|
|
2
|
+
import { makeDataflowRules } from '../shared.js';
|
|
3
|
+
|
|
4
|
+
// ─── Lua ──────────────────────────────────────────────────────────────────────
|
|
5
|
+
//
|
|
6
|
+
// Lua function_declaration: name via `childForFieldName('name')` (confirmed in extractor line 47).
|
|
7
|
+
// The name node may be `method_index_expression`, `dot_index_expression`, or `identifier`.
|
|
8
|
+
// Parameters: `childForFieldName('parameters')` (confirmed in extractor line 89) — returns
|
|
9
|
+
// a node containing `identifier` children directly (no wrapper type).
|
|
10
|
+
// function_call: name via `childForFieldName('name')` (confirmed in extractor line 132).
|
|
11
|
+
// dot_index_expression: table=`childForFieldName('table')`, field=`childForFieldName('field')`.
|
|
12
|
+
// method_index_expression: table=`childForFieldName('table')`, method=`childForFieldName('method')`.
|
|
13
|
+
|
|
14
|
+
export const dataflowLua: DataflowRulesConfig = makeDataflowRules({
|
|
15
|
+
functionNodes: new Set(['function_declaration']),
|
|
16
|
+
nameField: 'name',
|
|
17
|
+
|
|
18
|
+
paramListField: 'parameters',
|
|
19
|
+
// Lua params are bare identifier children in the param list — no wrapper type
|
|
20
|
+
paramIdentifier: 'identifier',
|
|
21
|
+
|
|
22
|
+
returnNode: 'return_statement',
|
|
23
|
+
|
|
24
|
+
callNode: 'function_call',
|
|
25
|
+
callFunctionField: 'name',
|
|
26
|
+
callArgsField: 'arguments',
|
|
27
|
+
|
|
28
|
+
memberNode: 'dot_index_expression',
|
|
29
|
+
memberObjectField: 'table',
|
|
30
|
+
memberPropertyField: 'field',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// ─── R ────────────────────────────────────────────────────────────────────────
|
|
34
|
+
//
|
|
35
|
+
// R functions are defined as: `name <- function_definition` (binary_operator with `<-`).
|
|
36
|
+
// The extractor handles this as binary_operator + function_definition on the RHS.
|
|
37
|
+
// There is no standalone function declaration node — `function_definition` is always
|
|
38
|
+
// an RHS expression. The parent `binary_operator` is the true "function node".
|
|
39
|
+
// R does NOT have an explicit `return` statement keyword that always appears —
|
|
40
|
+
// `return()` is a regular function call. Set returnNode: null.
|
|
41
|
+
// call node: `call` (confirmed in extractor handleCall line 111).
|
|
42
|
+
// The call node's first child (not a named field) is the function expression.
|
|
43
|
+
// Parameters: findChild(funcDef, 'parameters') on function_definition (extractor line 88).
|
|
44
|
+
// Each parameter is a `parameter` node with `childForFieldName('name')` or identifier child.
|
|
45
|
+
|
|
46
|
+
export const dataflowR: DataflowRulesConfig = makeDataflowRules({
|
|
47
|
+
// R functions are the `binary_operator` node where RHS is `function_definition`.
|
|
48
|
+
// We track the binary_operator as a function scope, but the param list lives
|
|
49
|
+
// inside the nested `function_definition` child. This is best-effort: the
|
|
50
|
+
// unified dataflow walker will find `binary_operator` nodes but may not locate
|
|
51
|
+
// the param list via the standard field walk. Most analysis benefit comes from
|
|
52
|
+
// variable tracking and call arg flows.
|
|
53
|
+
// Use function_definition directly: the walker will enter it as function scope.
|
|
54
|
+
functionNodes: new Set(['function_definition']),
|
|
55
|
+
// R function_definition has no 'name' field — the name comes from the enclosing
|
|
56
|
+
// binary_operator's LHS. The nameExtractor is not needed here since the
|
|
57
|
+
// extractor handles name resolution; the dataflow visitor just needs to find
|
|
58
|
+
// the function scope boundary.
|
|
59
|
+
nameField: 'name',
|
|
60
|
+
|
|
61
|
+
paramListField: 'parameters',
|
|
62
|
+
paramWrapperTypes: new Set(['parameter']),
|
|
63
|
+
|
|
64
|
+
returnNode: null, // R uses return() as a function call, not a statement
|
|
65
|
+
|
|
66
|
+
callNode: 'call',
|
|
67
|
+
// R `call` node has the function as its first child (not a named field).
|
|
68
|
+
// Leaving callFunctionField at default 'function' — childForFieldName will
|
|
69
|
+
// return null, and the analysis falls back to skipping the callee name.
|
|
70
|
+
|
|
71
|
+
assignmentNode: 'binary_operator',
|
|
72
|
+
assignLeftField: 'left',
|
|
73
|
+
assignRightField: 'right',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// ─── Julia ────────────────────────────────────────────────────────────────────
|
|
77
|
+
//
|
|
78
|
+
// Julia function_definition: extractor uses a `signature` child → `call_expression`
|
|
79
|
+
// to find the function name + params (complex nesting). The function node type
|
|
80
|
+
// is `function_definition` (confirmed in extractor line 41).
|
|
81
|
+
// The params are inside the signature's call_expression's argument_list.
|
|
82
|
+
// For dataflow purposes, we just mark function_definition as the scope boundary.
|
|
83
|
+
// Params are inside function_definition → signature → call_expression → argument_list.
|
|
84
|
+
// Since there's no direct param list field on function_definition, use getParamListNode.
|
|
85
|
+
// call_expression: `node.child(0)` for function name (confirmed in extractor handleCall line 387).
|
|
86
|
+
// Julia has explicit `return_statement` (confirmed in extractor comment: "Julia has explicit return").
|
|
87
|
+
// variable assignment: `assignment` node (confirmed in extractor handleAssignment line 158).
|
|
88
|
+
|
|
89
|
+
export const dataflowJulia: DataflowRulesConfig = makeDataflowRules({
|
|
90
|
+
functionNodes: new Set(['function_definition']),
|
|
91
|
+
nameField: 'name',
|
|
92
|
+
|
|
93
|
+
// Julia params are buried deep: function_definition → signature → call_expression → argument_list.
|
|
94
|
+
// No direct named field on function_definition for params. Leave param extraction
|
|
95
|
+
// to best-effort: getParamListNode returns null (default), so params will be skipped
|
|
96
|
+
// gracefully. The primary value is function scope tracking and call arg flows.
|
|
97
|
+
paramListField: 'parameters',
|
|
98
|
+
|
|
99
|
+
returnNode: 'return_statement',
|
|
100
|
+
|
|
101
|
+
assignmentNode: 'assignment',
|
|
102
|
+
assignLeftField: 'left',
|
|
103
|
+
assignRightField: 'right',
|
|
104
|
+
|
|
105
|
+
callNode: 'call_expression',
|
|
106
|
+
// Julia call_expression: first child is the function (no named field 'function').
|
|
107
|
+
// Leave callFunctionField at default — will return null gracefully.
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// ─── Bash ─────────────────────────────────────────────────────────────────────
|
|
111
|
+
//
|
|
112
|
+
// Bash function_definition: name via `childForFieldName('name')` (confirmed in extractor line 42).
|
|
113
|
+
// Bash has no typed parameters or return values.
|
|
114
|
+
// command: `command_name` child (extractor handleBashCommand line 55).
|
|
115
|
+
// No param lists, no return nodes, no variable declarators in the conventional sense.
|
|
116
|
+
// Minimal config — primarily useful for function scope tracking and call edges.
|
|
117
|
+
|
|
118
|
+
export const dataflowBash: DataflowRulesConfig = makeDataflowRules({
|
|
119
|
+
functionNodes: new Set(['function_definition']),
|
|
120
|
+
nameField: 'name',
|
|
121
|
+
|
|
122
|
+
returnNode: null, // Bash has no explicit return statement node (return is a command)
|
|
123
|
+
|
|
124
|
+
callNode: 'command',
|
|
125
|
+
// Bash `command` node: function name is in `command_name` child (not a named field).
|
|
126
|
+
// Leave callFunctionField at default — will return null gracefully.
|
|
127
|
+
});
|