cgraphx 2.0.2 → 2.0.6
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/dist/.claude-template/FLOW-MAP.md +13 -3
- package/dist/.claude-template/agents/task-history.md +186 -0
- package/dist/.claude-template/commands/end.md +1 -0
- package/dist/.claude-template/skills/cgraphx-guide/SKILL.md +5 -3
- package/dist/.claude-template/skills/cgraphx-guide/how-to-use.html +8 -8
- package/dist/.claude-template/skills/cgraphx-guide/how-to-use.md +8 -8
- package/dist/.claude-template/skills/clarify-requirements/SKILL.md +13 -9
- package/dist/.claude-template/skills/db-query/SKILL.md +19 -2
- package/dist/.claude-template/skills/iboc-check/SKILL.md +51 -23
- package/dist/.claude-template/skills/iboc-check/filler-prompt.md +3 -4
- package/dist/.claude-template/skills/run-api-test/SKILL.md +15 -15
- package/dist/.claude-template/skills/run-api-test/assets/{template-test-report.md → template-/346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212.md} +4 -4
- package/dist/.claude-template/skills/run-api-test/references/bru-run.md +1 -1
- package/dist/.claude-template/skills/run-api-test/references/db-verification.md +2 -2
- package/dist/.claude-template/skills/run-api-test/references/report-format.md +6 -6
- package/dist/.claude-template/skills/run-api-test/references/service-readiness.md +1 -1
- package/dist/.claude-template/skills/run-api-test/references/test-scope.md +6 -6
- package/dist/.claude-template/skills/run-ui-test/SKILL.md +186 -0
- package/dist/.claude-template/skills/run-ui-test/references/report-format.md +77 -0
- package/dist/.claude-template/skills/subagent-implement/SKILL.md +3 -2
- package/dist/.claude-template/skills/write-api/SKILL.md +18 -18
- package/dist/.claude-template/skills/write-api/assets/{template-api-spec.md → template-/346/216/245/345/217/243/346/265/213/350/257/225-spec.md} +1 -1
- package/dist/.claude-template/skills/write-api/references/{api-spec-format.md → /346/216/245/345/217/243/346/265/213/350/257/225-spec-format.md} +3 -3
- package/dist/.claude-template/skills/write-plan/SKILL.md +4 -2
- package/dist/.claude-template/skills/write-ui-test/SKILL.md +125 -0
- package/dist/.claude-template/skills/write-ui-test/references//347/224/250/344/276/213/350/247/204/346/240/274-format.md +94 -0
- package/dist/core/code/engine/cli/analyze-config.js +320 -0
- package/dist/core/code/engine/cli/analyze.js +1086 -0
- package/dist/core/code/engine/cli/cli-message.js +83 -0
- package/dist/core/code/engine/cli/detect-changes-format.js +58 -0
- package/dist/core/code/engine/cli/embedding-dims.js +43 -0
- package/dist/core/code/engine/cli/format-elapsed.js +12 -0
- package/dist/core/code/engine/cli/help-i18n.js +144 -0
- package/dist/core/code/engine/cli/i18n/en.js +110 -0
- package/dist/core/code/engine/cli/i18n/index.js +47 -0
- package/dist/core/code/engine/cli/i18n/resources.js +9 -0
- package/dist/core/code/engine/cli/i18n/zh-CN.js +110 -0
- package/dist/core/code/engine/cli/lazy-action.js +67 -0
- package/dist/core/code/engine/cli/optional-grammars.js +136 -0
- package/dist/core/code/engine/cli/resolve-invocation.js +76 -0
- package/dist/core/code/engine/cli/status.js +156 -0
- package/dist/core/code/engine/cli/tool.js +384 -0
- package/dist/core/code/engine/config/ignore-service.js +511 -0
- package/dist/core/code/engine/config/supported-languages.js +17 -0
- package/dist/core/code/engine/core/analysis-features.js +64 -0
- package/dist/core/code/engine/core/analyzer-identity.js +2171 -0
- package/dist/core/code/engine/core/git-staleness.js +180 -0
- package/dist/core/code/engine/core/graph/graph.js +180 -0
- package/dist/core/code/engine/core/graph/import-cycles.js +106 -0
- package/dist/core/code/engine/core/graph/types.js +2 -0
- package/dist/core/code/engine/core/index-freshness.js +12 -0
- package/dist/core/code/engine/core/ingestion/binding-accumulator.js +341 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/c-cpp.js +168 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/csharp.js +9 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/dart.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/go.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/jvm.js +54 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/php.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/python.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/ruby.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/rust.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/swift.js +8 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/configs/typescript-javascript.js +11 -0
- package/dist/core/code/engine/core/ingestion/call-extractors/generic.js +62 -0
- package/dist/core/code/engine/core/ingestion/call-processor.js +503 -0
- package/dist/core/code/engine/core/ingestion/call-routing.js +98 -0
- package/dist/core/code/engine/core/ingestion/call-types.js +3 -0
- package/dist/core/code/engine/core/ingestion/cfg/callee-cell-format.js +45 -0
- package/dist/core/code/engine/core/ingestion/cfg/cfg-builder.js +202 -0
- package/dist/core/code/engine/core/ingestion/cfg/collect.js +81 -0
- package/dist/core/code/engine/core/ingestion/cfg/control-dependence.js +185 -0
- package/dist/core/code/engine/core/ingestion/cfg/control-flow-context.js +130 -0
- package/dist/core/code/engine/core/ingestion/cfg/emit.js +646 -0
- package/dist/core/code/engine/core/ingestion/cfg/post-dominators.js +182 -0
- package/dist/core/code/engine/core/ingestion/cfg/reaching-def-reason-codec.js +139 -0
- package/dist/core/code/engine/core/ingestion/cfg/reaching-defs-graph.js +322 -0
- package/dist/core/code/engine/core/ingestion/cfg/reaching-defs.js +792 -0
- package/dist/core/code/engine/core/ingestion/cfg/synthetic-escape.js +305 -0
- package/dist/core/code/engine/core/ingestion/cfg/traversal-result.js +6 -0
- package/dist/core/code/engine/core/ingestion/cfg/types.js +14 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/c-cpp-harvest.js +545 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/c-cpp.js +590 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/call-site-harvest.js +356 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/csharp-harvest.js +593 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/csharp.js +871 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/dart-harvest.js +874 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/dart.js +840 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/go-harvest.js +625 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/go.js +642 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/java-harvest.js +517 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/java.js +816 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/kotlin-harvest.js +723 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/kotlin.js +813 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/php-harvest.js +630 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/php.js +725 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/python-harvest.js +776 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/python.js +562 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/ruby-harvest.js +591 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/ruby.js +760 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/rust-harvest.js +877 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/rust.js +562 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/scope-tree-harvest.js +120 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/swift-harvest.js +683 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/swift.js +791 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/typescript-harvest.js +1060 -0
- package/dist/core/code/engine/core/ingestion/cfg/visitors/typescript.js +587 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/c-cpp.js +77 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/csharp.js +24 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/dart.js +10 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/go.js +28 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/jvm.js +67 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/php.js +10 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/python.js +10 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/ruby.js +13 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/rust.js +10 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/swift.js +21 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/configs/typescript-javascript.js +31 -0
- package/dist/core/code/engine/core/ingestion/class-extractors/generic.js +144 -0
- package/dist/core/code/engine/core/ingestion/class-types.js +2 -0
- package/dist/core/code/engine/core/ingestion/cluster-enricher.js +174 -0
- package/dist/core/code/engine/core/ingestion/community-processor.js +604 -0
- package/dist/core/code/engine/core/ingestion/constants.js +26 -0
- package/dist/core/code/engine/core/ingestion/cpp-ue-preprocessor.js +263 -0
- package/dist/core/code/engine/core/ingestion/csharp-namespace-gate.js +133 -0
- package/dist/core/code/engine/core/ingestion/di-extractors/index.js +38 -0
- package/dist/core/code/engine/core/ingestion/di-extractors/spring.js +310 -0
- package/dist/core/code/engine/core/ingestion/emit-references.js +244 -0
- package/dist/core/code/engine/core/ingestion/entry-point-scoring.js +201 -0
- package/dist/core/code/engine/core/ingestion/export-detection.js +244 -0
- package/dist/core/code/engine/core/ingestion/field-extractor.js +29 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/c-cpp.js +107 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/csharp.js +124 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/dart.js +99 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/go.js +102 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/helpers.js +198 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/jvm.js +172 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/php.js +67 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/python.js +94 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/ruby.js +79 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/rust.js +55 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/swift.js +93 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/configs/typescript-javascript.js +59 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/generic.js +147 -0
- package/dist/core/code/engine/core/ingestion/field-extractors/typescript.js +266 -0
- package/dist/core/code/engine/core/ingestion/field-types.js +3 -0
- package/dist/core/code/engine/core/ingestion/filesystem-walker.js +136 -0
- package/dist/core/code/engine/core/ingestion/finalize-orchestrator.js +159 -0
- package/dist/core/code/engine/core/ingestion/framework-detection.js +432 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/analysis-features.js +38 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/annotation-arguments.js +234 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/aop-candidates.js +88 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/aop.js +487 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/auto-configuration.js +21 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/bean-candidates.js +189 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/bean-catalog.js +32 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/bean-factories.js +73 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/conditionals.js +323 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/config-bindings.js +119 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/di-metadata.js +385 -0
- package/dist/core/code/engine/core/ingestion/frameworks/spring/resource-injection.js +96 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/c-cpp.js +17 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/csharp.js +46 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/dart.js +59 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/go.js +30 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/jvm.js +73 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/php.js +19 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/python.js +45 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/ruby.js +20 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/rust.js +58 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/swift.js +94 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/configs/typescript-javascript.js +26 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/csharp.js +128 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/go.js +50 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/jvm.js +112 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/php.js +80 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/python.js +75 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/resolver-factory.js +36 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/ruby.js +20 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/rust.js +79 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/standard.js +180 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/types.js +7 -0
- package/dist/core/code/engine/core/ingestion/import-resolvers/utils.js +153 -0
- package/dist/core/code/engine/core/ingestion/import-target-adapter.js +99 -0
- package/dist/core/code/engine/core/ingestion/language-config.js +391 -0
- package/dist/core/code/engine/core/ingestion/language-provider.js +25 -0
- package/dist/core/code/engine/core/ingestion/languages/c/arity-metadata.js +98 -0
- package/dist/core/code/engine/core/ingestion/languages/c/arity.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/c/capture-side-channel.js +69 -0
- package/dist/core/code/engine/core/ingestion/languages/c/captures.js +189 -0
- package/dist/core/code/engine/core/ingestion/languages/c/header-scan.js +58 -0
- package/dist/core/code/engine/core/ingestion/languages/c/import-decomposer.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/c/import-target.js +103 -0
- package/dist/core/code/engine/core/ingestion/languages/c/index.js +33 -0
- package/dist/core/code/engine/core/ingestion/languages/c/interpret.js +53 -0
- package/dist/core/code/engine/core/ingestion/languages/c/merge-bindings.js +26 -0
- package/dist/core/code/engine/core/ingestion/languages/c/query.js +210 -0
- package/dist/core/code/engine/core/ingestion/languages/c/scope-resolver.js +112 -0
- package/dist/core/code/engine/core/ingestion/languages/c/simple-hooks.js +24 -0
- package/dist/core/code/engine/core/ingestion/languages/c/static-linkage.js +109 -0
- package/dist/core/code/engine/core/ingestion/languages/c-cpp.js +506 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/adl.js +804 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/arity-metadata.js +258 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/arity.js +37 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/capture-side-channel.js +89 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/captures.js +1975 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/constraint-extractor.js +311 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/constraint-filter.js +210 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/conversion-rank.js +163 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/file-local-linkage.js +327 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/header-scan.js +53 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/import-decomposer.js +134 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/import-target.js +16 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/index.js +33 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/inline-namespaces.js +379 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/interpret.js +239 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/member-lookup.js +470 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/merge-bindings.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/query.js +763 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/range-bindings.js +230 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/scope-resolver.js +354 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/simple-hooks.js +67 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/two-phase-lookup.js +348 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/type-classifier.js +56 -0
- package/dist/core/code/engine/core/ingestion/languages/cpp/user-defined-conversions.js +128 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/accessor-unwrap.js +67 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/arity-metadata.js +49 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/arity.js +40 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/cache-stats.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/captures.js +557 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/import-decomposer.js +96 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/import-target.js +176 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/index.js +95 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/interpret.js +150 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/merge-bindings.js +58 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/namespace-siblings.js +708 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/qualified-type-names.js +62 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/query.js +578 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/receiver-binding.js +142 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/resolution-config.js +18 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/scope-resolver.js +84 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp/simple-hooks.js +81 -0
- package/dist/core/code/engine/core/ingestion/languages/csharp.js +204 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/arity-metadata.js +38 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/arity.js +34 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/built-ins.js +37 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/cache-stats.js +30 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/captures.js +1096 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/expand-wildcards.js +34 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/extension-type-preprocess.js +33 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/import-target.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/index.js +45 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/interpret.js +101 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/merge-bindings.js +42 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/query.js +246 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/receiver-binding.js +90 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/scope-resolver.js +197 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/signature-bindings.js +54 -0
- package/dist/core/code/engine/core/ingestion/languages/dart/simple-hooks.js +61 -0
- package/dist/core/code/engine/core/ingestion/languages/dart.js +138 -0
- package/dist/core/code/engine/core/ingestion/languages/go/arity-metadata.js +71 -0
- package/dist/core/code/engine/core/ingestion/languages/go/arity.js +17 -0
- package/dist/core/code/engine/core/ingestion/languages/go/cache-stats.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/go/captures.js +492 -0
- package/dist/core/code/engine/core/ingestion/languages/go/expand-wildcards.js +97 -0
- package/dist/core/code/engine/core/ingestion/languages/go/generic-type-parameters.js +146 -0
- package/dist/core/code/engine/core/ingestion/languages/go/import-decomposer.js +47 -0
- package/dist/core/code/engine/core/ingestion/languages/go/import-target.js +70 -0
- package/dist/core/code/engine/core/ingestion/languages/go/index.js +39 -0
- package/dist/core/code/engine/core/ingestion/languages/go/interface-impls.js +955 -0
- package/dist/core/code/engine/core/ingestion/languages/go/interpret.js +177 -0
- package/dist/core/code/engine/core/ingestion/languages/go/merge-bindings.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/go/method-owners.js +131 -0
- package/dist/core/code/engine/core/ingestion/languages/go/namespace-mirror.js +56 -0
- package/dist/core/code/engine/core/ingestion/languages/go/package-clause.js +79 -0
- package/dist/core/code/engine/core/ingestion/languages/go/package-siblings.js +83 -0
- package/dist/core/code/engine/core/ingestion/languages/go/query.js +298 -0
- package/dist/core/code/engine/core/ingestion/languages/go/range-binding.js +127 -0
- package/dist/core/code/engine/core/ingestion/languages/go/receiver-binding.js +24 -0
- package/dist/core/code/engine/core/ingestion/languages/go/scope-resolver.js +75 -0
- package/dist/core/code/engine/core/ingestion/languages/go/simple-hooks.js +31 -0
- package/dist/core/code/engine/core/ingestion/languages/go/type-binding.js +279 -0
- package/dist/core/code/engine/core/ingestion/languages/go.js +160 -0
- package/dist/core/code/engine/core/ingestion/languages/index.js +66 -0
- package/dist/core/code/engine/core/ingestion/languages/java/analysis-features.js +16 -0
- package/dist/core/code/engine/core/ingestion/languages/java/arity-metadata.js +43 -0
- package/dist/core/code/engine/core/ingestion/languages/java/arity.js +27 -0
- package/dist/core/code/engine/core/ingestion/languages/java/cache-stats.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/java/capture-side-channel.js +123 -0
- package/dist/core/code/engine/core/ingestion/languages/java/captures.js +791 -0
- package/dist/core/code/engine/core/ingestion/languages/java/import-decomposer.js +88 -0
- package/dist/core/code/engine/core/ingestion/languages/java/import-target.js +103 -0
- package/dist/core/code/engine/core/ingestion/languages/java/index.js +43 -0
- package/dist/core/code/engine/core/ingestion/languages/java/interpret.js +146 -0
- package/dist/core/code/engine/core/ingestion/languages/java/merge-bindings.js +43 -0
- package/dist/core/code/engine/core/ingestion/languages/java/package-facts.js +16 -0
- package/dist/core/code/engine/core/ingestion/languages/java/package-siblings.js +11 -0
- package/dist/core/code/engine/core/ingestion/languages/java/query.js +319 -0
- package/dist/core/code/engine/core/ingestion/languages/java/receiver-binding.js +98 -0
- package/dist/core/code/engine/core/ingestion/languages/java/scope-resolver.js +213 -0
- package/dist/core/code/engine/core/ingestion/languages/java/simple-hooks.js +39 -0
- package/dist/core/code/engine/core/ingestion/languages/java/spring-aop.js +53 -0
- package/dist/core/code/engine/core/ingestion/languages/java/spring-bean-metadata.js +11 -0
- package/dist/core/code/engine/core/ingestion/languages/java/spring-conditionals.js +52 -0
- package/dist/core/code/engine/core/ingestion/languages/java/spring-config-bindings.js +222 -0
- package/dist/core/code/engine/core/ingestion/languages/java/spring-di.js +165 -0
- package/dist/core/code/engine/core/ingestion/languages/java.js +192 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/arity.js +15 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/captures.js +1122 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/import-target.js +56 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/index.js +109 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/interpret.js +45 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/merge-bindings.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/query.js +659 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/scope-resolver.js +78 -0
- package/dist/core/code/engine/core/ingestion/languages/javascript/simple-hooks.js +44 -0
- package/dist/core/code/engine/core/ingestion/languages/jvm/package-facts.js +46 -0
- package/dist/core/code/engine/core/ingestion/languages/jvm/package-siblings.js +200 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/arity-metadata.js +23 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/arity.js +18 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/cache-stats.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/capture-side-channel.js +160 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/captures.js +1262 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/companion-scopes.js +72 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/import-decomposer.js +40 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/import-target.js +135 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/index.js +26 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/interpret.js +75 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/merge-bindings.js +28 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/owners.js +134 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/package-facts.js +16 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/package-siblings.js +11 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/query.js +243 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/receiver-binding.js +103 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/scope-resolver.js +207 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/simple-hooks.js +42 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/spring-aop.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/spring-bean-metadata.js +11 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/spring-conditionals.js +53 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin/spring-di.js +304 -0
- package/dist/core/code/engine/core/ingestion/languages/kotlin.js +189 -0
- package/dist/core/code/engine/core/ingestion/languages/php/arity-metadata.js +66 -0
- package/dist/core/code/engine/core/ingestion/languages/php/arity.js +43 -0
- package/dist/core/code/engine/core/ingestion/languages/php/cache-stats.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/php/captures.js +1166 -0
- package/dist/core/code/engine/core/ingestion/languages/php/import-decomposer.js +238 -0
- package/dist/core/code/engine/core/ingestion/languages/php/import-target.js +213 -0
- package/dist/core/code/engine/core/ingestion/languages/php/index.js +85 -0
- package/dist/core/code/engine/core/ingestion/languages/php/interpret.js +256 -0
- package/dist/core/code/engine/core/ingestion/languages/php/merge-bindings.js +50 -0
- package/dist/core/code/engine/core/ingestion/languages/php/namespace-siblings.js +353 -0
- package/dist/core/code/engine/core/ingestion/languages/php/query.js +391 -0
- package/dist/core/code/engine/core/ingestion/languages/php/receiver-binding.js +135 -0
- package/dist/core/code/engine/core/ingestion/languages/php/scope-resolver.js +361 -0
- package/dist/core/code/engine/core/ingestion/languages/php/simple-hooks.js +116 -0
- package/dist/core/code/engine/core/ingestion/languages/php.js +302 -0
- package/dist/core/code/engine/core/ingestion/languages/python/arity-metadata.js +49 -0
- package/dist/core/code/engine/core/ingestion/languages/python/arity.js +41 -0
- package/dist/core/code/engine/core/ingestion/languages/python/cache-stats.js +34 -0
- package/dist/core/code/engine/core/ingestion/languages/python/captures.js +299 -0
- package/dist/core/code/engine/core/ingestion/languages/python/depends-references.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/python/import-decomposer.js +115 -0
- package/dist/core/code/engine/core/ingestion/languages/python/import-target.js +440 -0
- package/dist/core/code/engine/core/ingestion/languages/python/index-stats.js +30 -0
- package/dist/core/code/engine/core/ingestion/languages/python/index.js +96 -0
- package/dist/core/code/engine/core/ingestion/languages/python/interpret.js +430 -0
- package/dist/core/code/engine/core/ingestion/languages/python/merge-bindings.js +47 -0
- package/dist/core/code/engine/core/ingestion/languages/python/query.js +323 -0
- package/dist/core/code/engine/core/ingestion/languages/python/receiver-binding.js +310 -0
- package/dist/core/code/engine/core/ingestion/languages/python/scope-resolver.js +80 -0
- package/dist/core/code/engine/core/ingestion/languages/python/simple-hooks.js +53 -0
- package/dist/core/code/engine/core/ingestion/languages/python.js +140 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/arity.js +41 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/cache-stats.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/captures.js +864 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/import-target.js +88 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/index.js +29 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/interpret.js +115 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/merge-bindings.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/query.js +349 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/receiver-binding.js +70 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/scope-resolver.js +263 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby/simple-hooks.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/ruby.js +215 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/arity.js +16 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/cache-stats.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/captures.js +304 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/import-decomposer.js +167 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/import-target.js +108 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/index.js +29 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/interpret.js +201 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/merge-bindings.js +21 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/method-owners.js +76 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/module-path.js +222 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/qualified-call.js +482 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/query.js +280 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/range-binding.js +687 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/receiver-binding.js +148 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/scope-resolver.js +151 -0
- package/dist/core/code/engine/core/ingestion/languages/rust/simple-hooks.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/rust.js +183 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/arity-metadata.js +44 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/arity.js +45 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/base-type.js +30 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/cache-stats.js +32 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/captures.js +594 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/conditional-directive-preprocess.js +256 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/implicit-imports.js +60 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/import-decomposer.js +87 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/import-target.js +84 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/index.js +56 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/interpret.js +93 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/merge-bindings.js +51 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/query.js +226 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/receiver-binding.js +169 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/scope-resolver.js +192 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/sibling-type-bindings.js +68 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/signature-bindings.js +69 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/simple-hooks.js +65 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/target-grouping.js +97 -0
- package/dist/core/code/engine/core/ingestion/languages/swift/target-siblings.js +74 -0
- package/dist/core/code/engine/core/ingestion/languages/swift.js +246 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/arity-metadata.js +106 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/arity.js +57 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/array-callback.js +58 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/cache-stats.js +34 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/captures.js +956 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/cjs-export-assignment.js +535 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/cjs-module-exports.js +196 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/import-decomposer.js +374 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/import-target.js +65 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/index.js +108 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/interpret.js +344 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/merge-bindings.js +161 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/nuxt-auto-imports.js +325 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/query.js +1328 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/receiver-binding.js +201 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/scope-resolver.js +293 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript/simple-hooks.js +139 -0
- package/dist/core/code/engine/core/ingestion/languages/typescript.js +455 -0
- package/dist/core/code/engine/core/ingestion/languages/vue/captures.js +70 -0
- package/dist/core/code/engine/core/ingestion/languages/vue/import-target.js +61 -0
- package/dist/core/code/engine/core/ingestion/languages/vue/index.js +55 -0
- package/dist/core/code/engine/core/ingestion/languages/vue/scope-resolver.js +295 -0
- package/dist/core/code/engine/core/ingestion/languages/vue.js +96 -0
- package/dist/core/code/engine/core/ingestion/local-symbol-pruner.js +68 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/c-cpp.js +387 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/csharp.js +290 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/dart.js +392 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/go.js +179 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/jvm.js +350 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/php.js +306 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/python.js +312 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/ruby.js +289 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/rust.js +198 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/swift.js +286 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/configs/typescript-javascript.js +341 -0
- package/dist/core/code/engine/core/ingestion/method-extractors/generic.js +209 -0
- package/dist/core/code/engine/core/ingestion/method-types.js +3 -0
- package/dist/core/code/engine/core/ingestion/model/field-registry.js +41 -0
- package/dist/core/code/engine/core/ingestion/model/index.js +52 -0
- package/dist/core/code/engine/core/ingestion/model/method-registry.js +138 -0
- package/dist/core/code/engine/core/ingestion/model/owned-members-lookup.js +46 -0
- package/dist/core/code/engine/core/ingestion/model/registration-table.js +234 -0
- package/dist/core/code/engine/core/ingestion/model/resolve.js +183 -0
- package/dist/core/code/engine/core/ingestion/model/scope-resolution-indexes.js +43 -0
- package/dist/core/code/engine/core/ingestion/model/semantic-model.js +179 -0
- package/dist/core/code/engine/core/ingestion/model/symbol-table.js +216 -0
- package/dist/core/code/engine/core/ingestion/model/type-registry.js +84 -0
- package/dist/core/code/engine/core/ingestion/mro-processor.js +709 -0
- package/dist/core/code/engine/core/ingestion/parsing-processor.js +312 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/communities.js +69 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/cross-file.js +71 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/di.js +338 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/http-api-calls.js +312 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/index.js +54 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/mro.js +40 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/orm.js +78 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/parse-impl.js +1286 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/parse.js +41 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/processes.js +193 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/prune-local-symbols.js +29 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/registry.js +52 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/routes.js +409 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/rpc-edges.js +301 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/runner.js +207 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/scan.js +49 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/spring-aop.js +442 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/spring-auto-configuration.js +264 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/spring-config.js +440 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/structure.js +38 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/tools.js +89 -0
- package/dist/core/code/engine/core/ingestion/pipeline-phases/types.js +40 -0
- package/dist/core/code/engine/core/ingestion/pipeline.js +152 -0
- package/dist/core/code/engine/core/ingestion/process-processor.js +325 -0
- package/dist/core/code/engine/core/ingestion/resolve-references.js +205 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/constant-resolver.js +135 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/django-root-discovery.js +221 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/django.js +428 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/expo.js +39 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/fastapi-router-bindings.js +264 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/laravel.js +501 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/middleware.js +175 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/nextjs.js +81 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/php.js +25 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/python-const-resolver.js +307 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/response-shapes.js +299 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/route-path.js +71 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/spring-shared.js +310 -0
- package/dist/core/code/engine/core/ingestion/route-extractors/spring.js +441 -0
- package/dist/core/code/engine/core/ingestion/scope-extractor-bridge.js +60 -0
- package/dist/core/code/engine/core/ingestion/scope-extractor.js +1373 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/contract/scope-resolver.js +282 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/callee-id-sink.js +72 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/edges.js +194 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/ids.js +472 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/imports-to-edges.js +49 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/method-dispatch.js +43 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/node-lookup.js +274 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/graph-bridge/references-to-edges.js +93 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/callable-value-flow.js +1240 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/compound-receiver.js +1174 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/free-call-fallback.js +873 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/imported-return-types.js +226 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/mro.js +107 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/overload-narrowing.js +441 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/property-dispatch.js +122 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +1720 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/pipeline/phase.js +395 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/pipeline/reconcile-ownership.js +208 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/pipeline/registry.js +49 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/pipeline/run.js +632 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.js +112 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/resolution-outcome.js +41 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/scope/namespace-targets.js +81 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/scope/walkers.js +1835 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/unresolved-receivers.js +242 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/utils/definition-id.js +22 -0
- package/dist/core/code/engine/core/ingestion/scope-resolution/workspace-index.js +151 -0
- package/dist/core/code/engine/core/ingestion/structure-processor.js +40 -0
- package/dist/core/code/engine/core/ingestion/tree-sitter-queries.js +2244 -0
- package/dist/core/code/engine/core/ingestion/ts-js-hoc-utils.js +115 -0
- package/dist/core/code/engine/core/ingestion/type-env.js +1136 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/c-cpp.js +555 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/csharp.js +570 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/dart.js +372 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/go.js +508 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/jvm.js +875 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/php.js +537 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/python.js +477 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/ruby.js +380 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/rust.js +502 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/shared.js +843 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/swift.js +490 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/types.js +2 -0
- package/dist/core/code/engine/core/ingestion/type-extractors/typescript.js +690 -0
- package/dist/core/code/engine/core/ingestion/utils/ast-helpers.js +1693 -0
- package/dist/core/code/engine/core/ingestion/utils/call-analysis.js +779 -0
- package/dist/core/code/engine/core/ingestion/utils/callable-flow-captures.js +932 -0
- package/dist/core/code/engine/core/ingestion/utils/callable-labels.js +49 -0
- package/dist/core/code/engine/core/ingestion/utils/deferred-resolution-profile.js +151 -0
- package/dist/core/code/engine/core/ingestion/utils/effective-ram.js +67 -0
- package/dist/core/code/engine/core/ingestion/utils/env.js +60 -0
- package/dist/core/code/engine/core/ingestion/utils/event-loop.js +9 -0
- package/dist/core/code/engine/core/ingestion/utils/graph-sort.js +103 -0
- package/dist/core/code/engine/core/ingestion/utils/heap-probe.js +45 -0
- package/dist/core/code/engine/core/ingestion/utils/heritage-marker.js +47 -0
- package/dist/core/code/engine/core/ingestion/utils/line-base.js +24 -0
- package/dist/core/code/engine/core/ingestion/utils/max-file-size.js +59 -0
- package/dist/core/code/engine/core/ingestion/utils/method-props.js +198 -0
- package/dist/core/code/engine/core/ingestion/utils/qualified-name.js +73 -0
- package/dist/core/code/engine/core/ingestion/utils/receiver-chain-captures.js +60 -0
- package/dist/core/code/engine/core/ingestion/utils/receiver-chain-codec.js +188 -0
- package/dist/core/code/engine/core/ingestion/utils/scope-tree-walk.js +36 -0
- package/dist/core/code/engine/core/ingestion/utils/symbol-labels.js +48 -0
- package/dist/core/code/engine/core/ingestion/utils/template-arguments.js +187 -0
- package/dist/core/code/engine/core/ingestion/utils/type-parameters.js +209 -0
- package/dist/core/code/engine/core/ingestion/utils/verbose.js +6 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/c-cpp.js +133 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/csharp.js +66 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/dart.js +111 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/go.js +153 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/jvm.js +145 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/php.js +61 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/python.js +104 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/ruby.js +55 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/rust.js +79 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/swift.js +91 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/configs/typescript-javascript.js +86 -0
- package/dist/core/code/engine/core/ingestion/variable-extractors/generic.js +111 -0
- package/dist/core/code/engine/core/ingestion/variable-types.js +3 -0
- package/dist/core/code/engine/core/ingestion/vue-sfc-extractor.js +544 -0
- package/dist/core/code/engine/core/ingestion/workers/callable-id.js +122 -0
- package/dist/core/code/engine/core/ingestion/workers/clone-safety.js +470 -0
- package/dist/core/code/engine/core/ingestion/workers/parse-worker.js +2456 -0
- package/dist/core/code/engine/core/ingestion/workers/post-result.js +90 -0
- package/dist/core/code/engine/core/ingestion/workers/quarantine.js +41 -0
- package/dist/core/code/engine/core/ingestion/workers/result-merge.js +59 -0
- package/dist/core/code/engine/core/ingestion/workers/worker-pool.js +1725 -0
- package/dist/core/code/engine/core/ingestion/workspace-config.js +139 -0
- package/dist/core/code/engine/core/lbug/conn-lock.js +72 -0
- package/dist/core/code/engine/core/lbug/csv-generator.js +710 -0
- package/dist/core/code/engine/core/lbug/cypher-escape.js +24 -0
- package/dist/core/code/engine/core/lbug/extension-load-error.js +339 -0
- package/dist/core/code/engine/core/lbug/extension-loader.js +261 -0
- package/dist/core/code/engine/core/lbug/graph-emit-sink.js +584 -0
- package/dist/core/code/engine/core/lbug/lbug-adapter.js +2703 -0
- package/dist/core/code/engine/core/lbug/lbug-config.js +1029 -0
- package/dist/core/code/engine/core/lbug/native-check.js +435 -0
- package/dist/core/code/engine/core/lbug/pool-adapter.js +973 -0
- package/dist/core/code/engine/core/lbug/query-params.js +25 -0
- package/dist/core/code/engine/core/lbug/query-result-utils.js +31 -0
- package/dist/core/code/engine/core/lbug/rel-pair-routing.js +373 -0
- package/dist/core/code/engine/core/lbug/schema.js +771 -0
- package/dist/core/code/engine/core/lbug/shutdown-helpers.js +40 -0
- package/dist/core/code/engine/core/lbug/sidecar-recovery.js +716 -0
- package/dist/core/code/engine/core/lbug/stdio-capture.js +49 -0
- package/dist/core/code/engine/core/lbug/sync-csv-writer.js +115 -0
- package/dist/core/code/engine/core/lbug/wal-checkpoint-driver.js +215 -0
- package/dist/core/code/engine/core/lbug/wal-driver-state.js +28 -0
- package/dist/core/code/engine/core/logger.js +339 -0
- package/dist/core/code/engine/core/platform/capabilities.js +91 -0
- package/dist/core/code/engine/core/run-analyze.js +1098 -0
- package/dist/core/code/engine/core/tree-sitter/parser-loader.js +281 -0
- package/dist/core/code/engine/core/tree-sitter/safe-parse.js +258 -0
- package/dist/core/code/engine/core/tree-sitter/vendored-grammars.js +64 -0
- package/dist/core/code/engine/lib/utils.js +121 -0
- package/dist/core/code/engine/mcp/core/lbug-adapter.js +27 -0
- package/dist/core/code/engine/mcp/local/aop-metadata.js +230 -0
- package/dist/core/code/engine/mcp/local/bean-metadata.js +49 -0
- package/dist/core/code/engine/mcp/local/limits.js +15 -0
- package/dist/core/code/engine/mcp/local/line-display.js +6 -0
- package/dist/core/code/engine/mcp/local/local-backend.js +4142 -0
- package/dist/core/code/engine/storage/branch-index.js +72 -0
- package/dist/core/code/engine/storage/file-hash.js +95 -0
- package/dist/core/code/engine/storage/fs-atomic.js +34 -0
- package/dist/core/code/engine/storage/git.js +555 -0
- package/dist/core/code/engine/storage/index-lock.js +664 -0
- package/dist/core/code/engine/storage/parse-cache.js +650 -0
- package/dist/core/code/engine/storage/parsedfile-store.js +620 -0
- package/dist/core/code/engine/storage/repo-manager.js +1061 -0
- package/dist/core/code/engine/storage/scope-index-store.js +247 -0
- package/dist/core/code/engine/types/pipeline.js +2 -0
- package/dist/core/code/scripts/install-duckdb-extension.mjs +125 -0
- package/dist/core/code/scripts/resolve-analyze-cmd.cjs +346 -0
- package/dist/core/code/shared/graph/types.js +8 -0
- package/dist/core/code/shared/index.js +105 -0
- package/dist/core/code/shared/integrations/circuit-breaker.js +242 -0
- package/dist/core/code/shared/integrations/resilient-fetch.js +224 -0
- package/dist/core/code/shared/integrations/retry.js +70 -0
- package/dist/core/code/shared/integrations/understand-quickly.js +145 -0
- package/dist/core/code/shared/language-detection.js +162 -0
- package/dist/core/code/shared/languages.js +27 -0
- package/dist/core/code/shared/lbug/schema-constants.js +98 -0
- package/dist/core/code/shared/mro-strategy.js +2 -0
- package/dist/core/code/shared/pipeline.js +5 -0
- package/dist/core/code/shared/scope-resolution/callable-flow-site.js +11 -0
- package/dist/core/code/shared/scope-resolution/def-index.js +53 -0
- package/dist/core/code/shared/scope-resolution/evidence-weights.js +87 -0
- package/dist/core/code/shared/scope-resolution/finalize-algorithm.js +807 -0
- package/dist/core/code/shared/scope-resolution/language-classification.js +46 -0
- package/dist/core/code/shared/scope-resolution/method-dispatch-index.js +100 -0
- package/dist/core/code/shared/scope-resolution/module-scope-index.js +59 -0
- package/dist/core/code/shared/scope-resolution/origin-priority.js +23 -0
- package/dist/core/code/shared/scope-resolution/parsed-file.js +54 -0
- package/dist/core/code/shared/scope-resolution/position-index.js +136 -0
- package/dist/core/code/shared/scope-resolution/qualified-name-index.js +77 -0
- package/dist/core/code/shared/scope-resolution/reference-site.js +24 -0
- package/dist/core/code/shared/scope-resolution/registries/class-registry.js +32 -0
- package/dist/core/code/shared/scope-resolution/registries/context.js +52 -0
- package/dist/core/code/shared/scope-resolution/registries/evidence.js +152 -0
- package/dist/core/code/shared/scope-resolution/registries/field-registry.js +33 -0
- package/dist/core/code/shared/scope-resolution/registries/lookup-core.js +392 -0
- package/dist/core/code/shared/scope-resolution/registries/lookup-qualified.js +58 -0
- package/dist/core/code/shared/scope-resolution/registries/macro-registry.js +34 -0
- package/dist/core/code/shared/scope-resolution/registries/method-registry.js +34 -0
- package/dist/core/code/shared/scope-resolution/registries/tie-breaks.js +63 -0
- package/dist/core/code/shared/scope-resolution/resolve-type-ref.js +128 -0
- package/dist/core/code/shared/scope-resolution/scope-id.js +49 -0
- package/dist/core/code/shared/scope-resolution/scope-tree.js +225 -0
- package/dist/core/code/shared/scope-resolution/symbol-definition.js +12 -0
- package/dist/core/code/shared/scope-resolution/types.js +25 -0
- package/dist/core/code/shared/test-helpers.js +17 -0
- package/dist/core/code/vendor/leiden/index.cjs +355 -0
- package/dist/core/code/vendor/leiden/utils.cjs +419 -0
- package/dist/core/dbquery/cli.d.ts.map +1 -1
- package/dist/core/dbquery/cli.js +5 -4
- package/dist/core/dbquery/cli.js.map +1 -1
- package/dist/core/dbquery/config.d.ts.map +1 -1
- package/dist/core/dbquery/config.js +39 -3
- package/dist/core/dbquery/config.js.map +1 -1
- package/dist/core/dbquery/drivers/http.d.ts +23 -0
- package/dist/core/dbquery/drivers/http.d.ts.map +1 -0
- package/dist/core/dbquery/drivers/http.js +125 -0
- package/dist/core/dbquery/drivers/http.js.map +1 -0
- package/dist/core/dbquery/drivers/mysql.js +1 -1
- package/dist/core/dbquery/drivers/mysql.js.map +1 -1
- package/dist/core/dbquery/drivers/postgres.js +1 -1
- package/dist/core/dbquery/drivers/postgres.js.map +1 -1
- package/dist/core/dbquery/executor.d.ts.map +1 -1
- package/dist/core/dbquery/executor.js +46 -12
- package/dist/core/dbquery/executor.js.map +1 -1
- package/dist/core/dbquery/format.d.ts.map +1 -1
- package/dist/core/dbquery/format.js +2 -1
- package/dist/core/dbquery/format.js.map +1 -1
- package/dist/core/dbquery/init.d.ts.map +1 -1
- package/dist/core/dbquery/init.js +7 -0
- package/dist/core/dbquery/init.js.map +1 -1
- package/dist/core/dbquery/types.d.ts +55 -7
- package/dist/core/dbquery/types.d.ts.map +1 -1
- package/dist/core/directory.d.ts +17 -0
- package/dist/core/directory.d.ts.map +1 -1
- package/dist/core/directory.js +37 -0
- package/dist/core/directory.js.map +1 -1
- package/dist/core/features/cli.d.ts.map +1 -1
- package/dist/core/features/cli.js +3 -2
- package/dist/core/features/cli.js.map +1 -1
- package/dist/core/features/scanner.d.ts +1 -1
- package/dist/core/features/scanner.d.ts.map +1 -1
- package/dist/core/features/scanner.js +20 -4
- package/dist/core/features/scanner.js.map +1 -1
- package/dist/core/markdown/cli.d.ts.map +1 -1
- package/dist/core/markdown/cli.js +9 -8
- package/dist/core/markdown/cli.js.map +1 -1
- package/dist/core/timeline/cli.d.ts.map +1 -1
- package/dist/core/timeline/cli.js +13 -6
- package/dist/core/timeline/cli.js.map +1 -1
- package/dist/core/timeline/debris.d.ts +20 -0
- package/dist/core/timeline/debris.d.ts.map +1 -0
- package/dist/core/timeline/debris.js +124 -0
- package/dist/core/timeline/debris.js.map +1 -0
- package/dist/core/timeline/hook-runner.d.ts.map +1 -1
- package/dist/core/timeline/hook-runner.js +3 -1
- package/dist/core/timeline/hook-runner.js.map +1 -1
- package/dist/core/timeline/hooks.d.ts.map +1 -1
- package/dist/core/timeline/hooks.js +13 -5
- package/dist/core/timeline/hooks.js.map +1 -1
- package/dist/core/timeline/installer.d.ts +2 -0
- package/dist/core/timeline/installer.d.ts.map +1 -1
- package/dist/core/timeline/installer.js +12 -0
- package/dist/core/timeline/installer.js.map +1 -1
- package/dist/core/timeline/project-root.d.ts +21 -0
- package/dist/core/timeline/project-root.d.ts.map +1 -0
- package/dist/core/timeline/project-root.js +83 -0
- package/dist/core/timeline/project-root.js.map +1 -0
- package/dist/web/register.d.ts.map +1 -1
- package/dist/web/register.js +2 -1
- package/dist/web/register.js.map +1 -1
- package/package.json +1 -1
- package/dist/.claude-template/.cgraphx/timeline-current-turn.json +0 -1
- package/dist/.claude-template/skills/.cgraphx/timeline-current-turn.json +0 -1
- package/dist/.claude-template/skills/handdrawn-deck/.cgraphx/timeline-current-turn.json +0 -1
- package/dist/.claude-template/skills/handdrawn-deck/references/.cgraphx/timeline-current-turn.json +0 -1
- package/dist/.claude-template/skills/handdrawn-sketch-engine/.cgraphx/timeline-current-turn.json +0 -1
- /package/dist/.claude-template/skills/run-api-test/assets/{template-test-verify.jsonl → template-/346/216/245/345/217/243/346/265/213/350/257/225/351/252/214/350/257/201.jsonl"} +0 -0
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUBY_FUNCTION_TYPES = void 0;
|
|
4
|
+
exports.createRubyCfgVisitor = createRubyCfgVisitor;
|
|
5
|
+
const cfg_builder_js_1 = require("../cfg-builder.js");
|
|
6
|
+
const control_flow_context_js_1 = require("../control-flow-context.js");
|
|
7
|
+
const ruby_harvest_js_1 = require("./ruby-harvest.js");
|
|
8
|
+
/** Ruby node types that own a CFG-bearing function/closure body. */
|
|
9
|
+
const RUBY_FUNCTION_TYPES = new Set(['method', 'singleton_method', 'do_block', 'block', 'lambda']);
|
|
10
|
+
exports.RUBY_FUNCTION_TYPES = RUBY_FUNCTION_TYPES;
|
|
11
|
+
/** Statement node types that break a basic block (everything else coalesces). */
|
|
12
|
+
const CONTROL_FLOW_TYPES = new Set([
|
|
13
|
+
'if',
|
|
14
|
+
'unless',
|
|
15
|
+
'if_modifier',
|
|
16
|
+
'unless_modifier',
|
|
17
|
+
'while',
|
|
18
|
+
'until',
|
|
19
|
+
'while_modifier',
|
|
20
|
+
'until_modifier',
|
|
21
|
+
'for',
|
|
22
|
+
'case',
|
|
23
|
+
'case_match',
|
|
24
|
+
'begin',
|
|
25
|
+
'return',
|
|
26
|
+
'break',
|
|
27
|
+
'next',
|
|
28
|
+
'redo',
|
|
29
|
+
'retry',
|
|
30
|
+
'body_statement',
|
|
31
|
+
'block_body',
|
|
32
|
+
]);
|
|
33
|
+
/**
|
|
34
|
+
* Value-position branch constructs (#2205). When one of these is an `assignment`
|
|
35
|
+
* RHS (`x = if … / case …`) or a `return` value, it is modeled as control flow
|
|
36
|
+
* (its arms carry control dependence) instead of coalescing inline. `if`/`unless`
|
|
37
|
+
* always branch (the condition gates the then-arm even without `else`).
|
|
38
|
+
*/
|
|
39
|
+
const VALUE_BRANCH_EXPR_TYPES = new Set(['if', 'unless', 'case', 'case_match']);
|
|
40
|
+
const startLineOf = (n) => n.startPosition.row + 1;
|
|
41
|
+
const endLineOf = (n) => n.endPosition.row + 1;
|
|
42
|
+
/**
|
|
43
|
+
* Per-function Ruby walk state. One instance per function so the
|
|
44
|
+
* {@link ControlFlowContext}, the exception-handler stack, and the `begin`
|
|
45
|
+
* re-enter stack (for `retry`) are scoped to that function and never leak.
|
|
46
|
+
*/
|
|
47
|
+
class RubyCfgWalk {
|
|
48
|
+
builder;
|
|
49
|
+
harvest;
|
|
50
|
+
cfc = new control_flow_context_js_1.ControlFlowContext();
|
|
51
|
+
/** Stack of exception-handler entry blocks (rescue / ensure) a raise jumps to. */
|
|
52
|
+
handlers = [];
|
|
53
|
+
/** Stack of nearest-enclosing `begin` protected-body entry blocks (for `retry`). */
|
|
54
|
+
beginEntries = [];
|
|
55
|
+
/**
|
|
56
|
+
* For a block / lambda function (`do … end`, `{ … }`, `->(){}`), the body entry
|
|
57
|
+
* a `redo` re-enters when there is no enclosing real loop. A bare block is
|
|
58
|
+
* implicitly re-runnable by `redo`; set once the body's first block is known.
|
|
59
|
+
*/
|
|
60
|
+
blockRedoTarget;
|
|
61
|
+
/** Record the block-function body entry that a bare `redo` re-enters. */
|
|
62
|
+
setBlockRedoTarget(entry) {
|
|
63
|
+
this.blockRedoTarget = entry;
|
|
64
|
+
}
|
|
65
|
+
constructor(builder, harvest) {
|
|
66
|
+
this.builder = builder;
|
|
67
|
+
this.harvest = harvest;
|
|
68
|
+
}
|
|
69
|
+
/** Statements of a body node (`then`/`do`/`else`/`ensure`/`body_statement`/…), no comments. */
|
|
70
|
+
statementsOf(body) {
|
|
71
|
+
return body.namedChildren.filter((c) => c.type !== 'comment');
|
|
72
|
+
}
|
|
73
|
+
/** Visit a body that may be a wrapper (`then`/`do`/`block_body`/`body_statement`) or a single statement. */
|
|
74
|
+
visitBody(node) {
|
|
75
|
+
return this.builder.withNesting(() => {
|
|
76
|
+
if (!node)
|
|
77
|
+
return null;
|
|
78
|
+
if (this.isBodyWrapper(node))
|
|
79
|
+
return this.visitSeq(this.statementsOf(node));
|
|
80
|
+
return this.visitStmt(node);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
isBodyWrapper(node) {
|
|
84
|
+
return (node.type === 'then' ||
|
|
85
|
+
node.type === 'do' ||
|
|
86
|
+
node.type === 'else' ||
|
|
87
|
+
node.type === 'ensure' ||
|
|
88
|
+
node.type === 'body_statement' ||
|
|
89
|
+
node.type === 'block_body');
|
|
90
|
+
}
|
|
91
|
+
/** Wire a sequence of statements, coalescing straight-line runs into blocks. */
|
|
92
|
+
visitSeq(stmts) {
|
|
93
|
+
return this.builder.withNesting(() => {
|
|
94
|
+
let entry;
|
|
95
|
+
let dangling = [];
|
|
96
|
+
let openSimple;
|
|
97
|
+
for (const stmt of stmts) {
|
|
98
|
+
// A value-position branch on an assignment RHS (`x = if …`) is NOT in
|
|
99
|
+
// CONTROL_FLOW_TYPES (its node is `assignment`), so route it out of the
|
|
100
|
+
// coalescing path explicitly so visitStmt models its arms (#2205).
|
|
101
|
+
if (CONTROL_FLOW_TYPES.has(stmt.type) || this.isValueBranchAssignment(stmt)) {
|
|
102
|
+
openSimple = undefined; // close any open straight-line block
|
|
103
|
+
const res = this.visitStmt(stmt);
|
|
104
|
+
if (res === null)
|
|
105
|
+
continue; // transparent (empty nested block)
|
|
106
|
+
if (entry === undefined)
|
|
107
|
+
entry = res.entry;
|
|
108
|
+
else
|
|
109
|
+
this.builder.connect(dangling, res.entry, 'seq');
|
|
110
|
+
dangling = [...res.exits];
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
if (openSimple === undefined) {
|
|
114
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text, 'normal', this.harvest.facts(stmt));
|
|
115
|
+
if (entry === undefined)
|
|
116
|
+
entry = idx;
|
|
117
|
+
else
|
|
118
|
+
this.builder.connect(dangling, idx, 'seq');
|
|
119
|
+
openSimple = idx;
|
|
120
|
+
dangling = [idx];
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.builder.extendBlock(openSimple, endLineOf(stmt), stmt.text, this.harvest.facts(stmt));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (entry === undefined)
|
|
128
|
+
return null;
|
|
129
|
+
return { entry, exits: dangling };
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/** Dispatch one statement to its handler. Non-null except for empty blocks. */
|
|
133
|
+
visitStmt(stmt) {
|
|
134
|
+
switch (stmt.type) {
|
|
135
|
+
case 'if':
|
|
136
|
+
case 'unless':
|
|
137
|
+
return this.visitIf(stmt);
|
|
138
|
+
case 'if_modifier':
|
|
139
|
+
case 'unless_modifier':
|
|
140
|
+
return this.visitIfModifier(stmt);
|
|
141
|
+
case 'while':
|
|
142
|
+
case 'until':
|
|
143
|
+
return this.visitWhile(stmt);
|
|
144
|
+
case 'while_modifier':
|
|
145
|
+
case 'until_modifier':
|
|
146
|
+
return this.visitWhileModifier(stmt);
|
|
147
|
+
case 'for':
|
|
148
|
+
return this.visitFor(stmt);
|
|
149
|
+
case 'case':
|
|
150
|
+
return this.visitCase(stmt);
|
|
151
|
+
case 'case_match':
|
|
152
|
+
return this.visitCaseMatch(stmt);
|
|
153
|
+
case 'begin':
|
|
154
|
+
return this.visitBegin(stmt);
|
|
155
|
+
case 'return':
|
|
156
|
+
return this.visitReturn(stmt);
|
|
157
|
+
case 'break':
|
|
158
|
+
return this.visitBreak(stmt);
|
|
159
|
+
case 'next':
|
|
160
|
+
return this.visitNext(stmt);
|
|
161
|
+
case 'redo':
|
|
162
|
+
return this.visitRedo(stmt);
|
|
163
|
+
case 'retry':
|
|
164
|
+
return this.visitRetry(stmt);
|
|
165
|
+
case 'body_statement':
|
|
166
|
+
return this.visitImplicitBegin(stmt);
|
|
167
|
+
case 'block_body':
|
|
168
|
+
return this.visitSeq(this.statementsOf(stmt));
|
|
169
|
+
case 'assignment': {
|
|
170
|
+
// `x = if c then a else b end` / `x = case … end` (#2205): model the RHS
|
|
171
|
+
// branch as control flow and bind the LHS on the rejoin.
|
|
172
|
+
const branch = this.assignmentBranch(stmt);
|
|
173
|
+
if (branch)
|
|
174
|
+
return this.visitBindBranch(stmt, branch);
|
|
175
|
+
return this.visitSimple(stmt);
|
|
176
|
+
}
|
|
177
|
+
default:
|
|
178
|
+
return this.visitSimple(stmt);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
visitSimple(stmt) {
|
|
182
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text, 'normal', this.harvest.facts(stmt));
|
|
183
|
+
return { entry: idx, exits: [idx] };
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* `return [expr]` — threads through EVERY active `ensure` before EXIT.
|
|
187
|
+
* (A value-position branch RETURN is handled the idiomatic Ruby way already:
|
|
188
|
+
* `def f; if c then a else b end; end` is the implicit last-expression and is
|
|
189
|
+
* modeled as statement position. Bare `return if … end` is not a clean
|
|
190
|
+
* grammar shape — tree-sitter-ruby drops the value — so it stays a plain
|
|
191
|
+
* return; the assignment carrier is the value-branch fix here, #2205.)
|
|
192
|
+
*/
|
|
193
|
+
visitReturn(stmt) {
|
|
194
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text, 'normal', this.harvest.facts(stmt));
|
|
195
|
+
(0, control_flow_context_js_1.wireJumpThroughFinalizers)(this.builder, idx, this.cfc.finalizersForReturn(), this.builder.exitIndex, 'return');
|
|
196
|
+
return { entry: idx, exits: [] };
|
|
197
|
+
}
|
|
198
|
+
/** `break [expr]` — exits the nearest loop/block; threads through any `ensure`. */
|
|
199
|
+
visitBreak(stmt) {
|
|
200
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text, 'normal', this.harvest.facts(stmt));
|
|
201
|
+
const res = this.cfc.resolveBreak();
|
|
202
|
+
const { target, finalizers } = res ?? {
|
|
203
|
+
target: this.builder.exitIndex,
|
|
204
|
+
finalizers: this.cfc.finalizersForReturn(),
|
|
205
|
+
};
|
|
206
|
+
(0, control_flow_context_js_1.wireJumpThroughFinalizers)(this.builder, idx, finalizers, target, 'break');
|
|
207
|
+
return { entry: idx, exits: [] };
|
|
208
|
+
}
|
|
209
|
+
/** `next [expr]` ≈ continue — re-tests the nearest loop header; threads `ensure`. */
|
|
210
|
+
visitNext(stmt) {
|
|
211
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text, 'normal', this.harvest.facts(stmt));
|
|
212
|
+
const res = this.cfc.resolveContinue();
|
|
213
|
+
const { target, finalizers } = res ?? {
|
|
214
|
+
target: this.builder.exitIndex,
|
|
215
|
+
finalizers: this.cfc.finalizersForReturn(),
|
|
216
|
+
};
|
|
217
|
+
(0, control_flow_context_js_1.wireJumpThroughFinalizers)(this.builder, idx, finalizers, target, 'continue');
|
|
218
|
+
return { entry: idx, exits: [] };
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* `redo` — re-run the current loop/block body WITHOUT re-evaluating the
|
|
222
|
+
* condition. Modeled as a `loop-back` to the nearest loop's continue target
|
|
223
|
+
* (the loop header in the visitor's model). Outside a loop it routes to EXIT.
|
|
224
|
+
*/
|
|
225
|
+
visitRedo(stmt) {
|
|
226
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text);
|
|
227
|
+
// A `redo` inside a real loop re-runs that loop's body (its continue target);
|
|
228
|
+
// a `redo` inside a bare block re-enters the block body. Falls back to EXIT
|
|
229
|
+
// when neither exists (single-exit preserved).
|
|
230
|
+
const target = this.cfc.continueTarget() ?? this.blockRedoTarget;
|
|
231
|
+
if (target !== undefined)
|
|
232
|
+
this.builder.edge(idx, target, 'loop-back');
|
|
233
|
+
else
|
|
234
|
+
this.builder.edge(idx, this.builder.exitIndex, 'seq');
|
|
235
|
+
return { entry: idx, exits: [] };
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* `retry` — re-enter the nearest enclosing `begin`'s protected body. Modeled as
|
|
239
|
+
* a `loop-back` to that begin's entry block. Outside any begin it routes to
|
|
240
|
+
* EXIT (single-exit preserved) — a documented approximation.
|
|
241
|
+
*/
|
|
242
|
+
visitRetry(stmt) {
|
|
243
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text);
|
|
244
|
+
const begin = this.beginEntries[this.beginEntries.length - 1];
|
|
245
|
+
if (begin !== undefined)
|
|
246
|
+
this.builder.edge(idx, begin, 'loop-back');
|
|
247
|
+
else
|
|
248
|
+
this.builder.edge(idx, this.builder.exitIndex, 'seq');
|
|
249
|
+
return { entry: idx, exits: [] };
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* `if cond … elsif cond … else …` and `unless cond … else …`. Ruby has no
|
|
253
|
+
* nested-if else chain: an `if`/`unless` carries `condition`/`consequence`(then)
|
|
254
|
+
* plus an optional `alternative` that is an `elsif` (its own
|
|
255
|
+
* condition/consequence/alternative) or a trailing `else`. `unless` inverts the
|
|
256
|
+
* sense — its consequence is the cond-FALSE arm.
|
|
257
|
+
*/
|
|
258
|
+
/** The value-position branch on an `assignment` RHS (`x = if … / case …`), or
|
|
259
|
+
* undefined when the RHS is anything else (#2205). */
|
|
260
|
+
assignmentBranch(stmt) {
|
|
261
|
+
if (stmt.type !== 'assignment')
|
|
262
|
+
return undefined;
|
|
263
|
+
const right = stmt.childForFieldName('right');
|
|
264
|
+
return right && VALUE_BRANCH_EXPR_TYPES.has(right.type) ? right : undefined;
|
|
265
|
+
}
|
|
266
|
+
/** Whether a statement is an `assignment` with a value-position-branch RHS —
|
|
267
|
+
* routes it out of `visitSeq`'s coalescing path so its arms are modeled. */
|
|
268
|
+
isValueBranchAssignment(stmt) {
|
|
269
|
+
return this.assignmentBranch(stmt) !== undefined;
|
|
270
|
+
}
|
|
271
|
+
/** Model a value-position `if`/`unless`/`case`/`case_match` as control flow,
|
|
272
|
+
* bypassing the statement/value-position distinction (#2205). */
|
|
273
|
+
visitBranchExpr(node) {
|
|
274
|
+
switch (node.type) {
|
|
275
|
+
case 'if':
|
|
276
|
+
case 'unless':
|
|
277
|
+
return this.visitIf(node);
|
|
278
|
+
case 'case':
|
|
279
|
+
return this.visitCase(node);
|
|
280
|
+
case 'case_match':
|
|
281
|
+
return this.visitCaseMatch(node);
|
|
282
|
+
default:
|
|
283
|
+
return this.visitSimple(node); // unreachable — guarded by VALUE_BRANCH_EXPR_TYPES
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* `x = if … / case …` (#2205): visit the RHS branch as control flow, then rejoin
|
|
288
|
+
* its arms at a facts-only continuation carrying ONLY the LHS target def (the
|
|
289
|
+
* condition + arm-value uses are already harvested onto the branch's blocks).
|
|
290
|
+
* The arms are now control-dependent on the branch condition, and `x` is defined
|
|
291
|
+
* at the join — mirrors the Rust visitor's value-position `let` handling.
|
|
292
|
+
*/
|
|
293
|
+
visitBindBranch(stmt, branch) {
|
|
294
|
+
const res = this.visitBranchExpr(branch);
|
|
295
|
+
const cont = this.builder.newBlock(startLineOf(stmt), startLineOf(stmt), '', 'normal', this.harvest.assignmentDefFacts(stmt));
|
|
296
|
+
this.builder.connect(res.exits, cont, 'seq');
|
|
297
|
+
return { entry: res.entry, exits: [cont] };
|
|
298
|
+
}
|
|
299
|
+
visitIf(stmt) {
|
|
300
|
+
const inverted = stmt.type === 'unless';
|
|
301
|
+
const cond = stmt.childForFieldName('condition') ?? stmt;
|
|
302
|
+
const header = this.builder.newBlock(startLineOf(stmt), endLineOf(cond), cond.text, 'normal', this.harvest.facts(cond));
|
|
303
|
+
const thenKind = inverted ? 'cond-false' : 'cond-true';
|
|
304
|
+
const elseKind = inverted ? 'cond-true' : 'cond-false';
|
|
305
|
+
const exits = [];
|
|
306
|
+
const thenRes = this.visitBody(stmt.childForFieldName('consequence'));
|
|
307
|
+
if (thenRes) {
|
|
308
|
+
this.builder.edge(header, thenRes.entry, thenKind);
|
|
309
|
+
exits.push(...thenRes.exits);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
exits.push(header); // empty consequence — that path falls through
|
|
313
|
+
}
|
|
314
|
+
const alt = stmt.childForFieldName('alternative');
|
|
315
|
+
if (alt) {
|
|
316
|
+
const { exits: altExits } = this.visitIfAlternative(alt, header, elseKind);
|
|
317
|
+
exits.push(...altExits);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
exits.push(header); // no else — the complement path falls through to the join
|
|
321
|
+
}
|
|
322
|
+
return { entry: header, exits: [...new Set(exits)] };
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Thread an `if`/`unless` alternative: an `elsif` (its own condition chained on
|
|
326
|
+
* the parent's false edge) or a trailing `else`. Returns the dangling exits.
|
|
327
|
+
*/
|
|
328
|
+
visitIfAlternative(alt, falseFrom, falseKind) {
|
|
329
|
+
const exits = [];
|
|
330
|
+
if (alt.type === 'elsif') {
|
|
331
|
+
const cond = alt.childForFieldName('condition') ?? alt;
|
|
332
|
+
const elifHeader = this.builder.newBlock(startLineOf(alt), endLineOf(cond), cond.text, 'normal', this.harvest.facts(cond));
|
|
333
|
+
this.builder.edge(falseFrom, elifHeader, falseKind);
|
|
334
|
+
const thenRes = this.visitBody(alt.childForFieldName('consequence'));
|
|
335
|
+
if (thenRes) {
|
|
336
|
+
this.builder.edge(elifHeader, thenRes.entry, 'cond-true');
|
|
337
|
+
exits.push(...thenRes.exits);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
exits.push(elifHeader);
|
|
341
|
+
}
|
|
342
|
+
const nested = alt.childForFieldName('alternative');
|
|
343
|
+
if (nested) {
|
|
344
|
+
exits.push(...this.visitIfAlternative(nested, elifHeader, 'cond-false').exits);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
exits.push(elifHeader); // elsif with no further alternative falls through
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
// a trailing `else` (consumes the false path entirely).
|
|
352
|
+
const elseRes = this.visitBody(alt);
|
|
353
|
+
if (elseRes) {
|
|
354
|
+
this.builder.edge(falseFrom, elseRes.entry, falseKind);
|
|
355
|
+
exits.push(...elseRes.exits);
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
exits.push(falseFrom);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return { exits };
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* `expr if cond` / `expr unless cond` — the modifier statement-form. The body
|
|
365
|
+
* runs on the taken branch; the complement falls straight through to the join.
|
|
366
|
+
*/
|
|
367
|
+
visitIfModifier(stmt) {
|
|
368
|
+
const inverted = stmt.type === 'unless_modifier';
|
|
369
|
+
const cond = stmt.childForFieldName('condition');
|
|
370
|
+
const body = stmt.childForFieldName('body');
|
|
371
|
+
const header = this.builder.newBlock(startLineOf(stmt), cond ? endLineOf(cond) : startLineOf(stmt), cond ? cond.text : stmt.text, 'normal', cond ? this.harvest.facts(cond) : undefined);
|
|
372
|
+
const takenKind = inverted ? 'cond-false' : 'cond-true';
|
|
373
|
+
const exits = [header]; // the complement path falls through
|
|
374
|
+
const bodyRes = body ? this.visitStmt(body) : null;
|
|
375
|
+
if (bodyRes) {
|
|
376
|
+
this.builder.edge(header, bodyRes.entry, takenKind);
|
|
377
|
+
exits.push(...bodyRes.exits);
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
this.builder.edge(header, header, takenKind === 'cond-true' ? 'cond-true' : 'cond-false');
|
|
381
|
+
}
|
|
382
|
+
return { entry: header, exits: [...new Set(exits)] };
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* `while cond … end` / `until cond … end`. `until` inverts (its body runs while
|
|
386
|
+
* the condition is FALSE); both are modeled with `cond-true` to the body and
|
|
387
|
+
* `cond-false` to the loop exit (the inversion is a semantic note, not a
|
|
388
|
+
* structural change — the header is a single control point either way).
|
|
389
|
+
*/
|
|
390
|
+
visitWhile(stmt) {
|
|
391
|
+
const cond = stmt.childForFieldName('condition') ?? stmt;
|
|
392
|
+
const header = this.builder.newBlock(startLineOf(stmt), endLineOf(cond), cond.text, 'normal', this.harvest.facts(cond));
|
|
393
|
+
const loopExit = this.builder.newBlock(endLineOf(stmt), endLineOf(stmt), '');
|
|
394
|
+
this.cfc.pushLoop(header, loopExit, []);
|
|
395
|
+
const body = this.visitBody(stmt.childForFieldName('body'));
|
|
396
|
+
this.cfc.pop();
|
|
397
|
+
if (body) {
|
|
398
|
+
this.builder.edge(header, body.entry, 'cond-true');
|
|
399
|
+
this.builder.connect(body.exits, header, 'loop-back');
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
this.builder.edge(header, header, 'loop-back'); // empty body re-tests
|
|
403
|
+
}
|
|
404
|
+
// Always emit the structural exit edge — even `while true` keeps EXIT
|
|
405
|
+
// reverse-reachable for the post-dominator / CDG pass.
|
|
406
|
+
this.builder.edge(header, loopExit, 'cond-false');
|
|
407
|
+
return { entry: header, exits: [loopExit] };
|
|
408
|
+
}
|
|
409
|
+
/** `expr while cond` / `expr until cond` — the modifier loop-form. */
|
|
410
|
+
visitWhileModifier(stmt) {
|
|
411
|
+
const cond = stmt.childForFieldName('condition') ?? stmt;
|
|
412
|
+
const body = stmt.childForFieldName('body');
|
|
413
|
+
const header = this.builder.newBlock(startLineOf(stmt), endLineOf(cond), cond.text, 'normal', this.harvest.facts(cond));
|
|
414
|
+
const loopExit = this.builder.newBlock(endLineOf(stmt), endLineOf(stmt), '');
|
|
415
|
+
this.cfc.pushLoop(header, loopExit, []);
|
|
416
|
+
const bodyRes = body ? this.visitStmt(body) : null;
|
|
417
|
+
this.cfc.pop();
|
|
418
|
+
if (bodyRes) {
|
|
419
|
+
this.builder.edge(header, bodyRes.entry, 'cond-true');
|
|
420
|
+
this.builder.connect(bodyRes.exits, header, 'loop-back');
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
this.builder.edge(header, header, 'loop-back');
|
|
424
|
+
}
|
|
425
|
+
this.builder.edge(header, loopExit, 'cond-false');
|
|
426
|
+
return { entry: header, exits: [loopExit] };
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* `for PATTERN in VALUE … end`. Header = the iteration test (a def of the
|
|
430
|
+
* pattern target(s) + a use of the iterable).
|
|
431
|
+
*/
|
|
432
|
+
visitFor(stmt) {
|
|
433
|
+
const value = stmt.childForFieldName('value');
|
|
434
|
+
const header = this.builder.newBlock(startLineOf(stmt), value ? endLineOf(value) : startLineOf(stmt), this.forHeaderText(stmt), 'normal', this.harvest.loopHeadFacts(stmt));
|
|
435
|
+
const loopExit = this.builder.newBlock(endLineOf(stmt), endLineOf(stmt), '');
|
|
436
|
+
this.cfc.pushLoop(header, loopExit, []);
|
|
437
|
+
const body = this.visitBody(stmt.childForFieldName('body'));
|
|
438
|
+
this.cfc.pop();
|
|
439
|
+
if (body) {
|
|
440
|
+
this.builder.edge(header, body.entry, 'cond-true');
|
|
441
|
+
this.builder.connect(body.exits, header, 'loop-back');
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
this.builder.edge(header, header, 'loop-back');
|
|
445
|
+
}
|
|
446
|
+
this.builder.edge(header, loopExit, 'cond-false');
|
|
447
|
+
return { entry: header, exits: [loopExit] };
|
|
448
|
+
}
|
|
449
|
+
forHeaderText(stmt) {
|
|
450
|
+
const pattern = stmt.childForFieldName('pattern')?.text ?? '';
|
|
451
|
+
const value = stmt.childForFieldName('value')?.text ?? '';
|
|
452
|
+
return pattern || value ? `for ${pattern} ${value}` : stmt.text.split('\n')[0];
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* `case VALUE; when P; … else; … end`. Cases do NOT fall through (like Go /
|
|
456
|
+
* Python match). The subject block fans a `switch-case` edge to each `when`
|
|
457
|
+
* body; a `case` with no `else` also reaches the join directly (no-match path),
|
|
458
|
+
* keeping EXIT reverse-reachable.
|
|
459
|
+
*/
|
|
460
|
+
visitCase(stmt) {
|
|
461
|
+
const value = stmt.childForFieldName('value');
|
|
462
|
+
const dispatch = this.builder.newBlock(startLineOf(stmt), value ? endLineOf(value) : startLineOf(stmt), value ? `case ${value.text}` : 'case', 'normal', value ? this.harvest.facts(value) : undefined);
|
|
463
|
+
const caseExit = this.builder.newBlock(endLineOf(stmt), endLineOf(stmt), '');
|
|
464
|
+
const whenClauses = stmt.namedChildren.filter((c) => c.type === 'when');
|
|
465
|
+
const elseClause = stmt.namedChildren.find((c) => c.type === 'else');
|
|
466
|
+
// Each `when` pattern evaluates conditionally before its body — harvest its
|
|
467
|
+
// uses onto the dispatch block (a later case only tests when earlier
|
|
468
|
+
// patterns did not match).
|
|
469
|
+
for (const w of whenClauses) {
|
|
470
|
+
for (const pat of this.whenPatterns(w)) {
|
|
471
|
+
this.builder.attachFacts(dispatch, this.harvest.factsConditional(pat));
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
this.cfc.pushSwitch(caseExit, []);
|
|
475
|
+
for (const w of whenClauses) {
|
|
476
|
+
const bodyRes = this.visitBody(w.childForFieldName('body'));
|
|
477
|
+
const entry = bodyRes?.entry ?? caseExit;
|
|
478
|
+
this.builder.edge(dispatch, entry, 'switch-case');
|
|
479
|
+
if (bodyRes)
|
|
480
|
+
this.builder.connect(bodyRes.exits, caseExit, 'seq');
|
|
481
|
+
}
|
|
482
|
+
if (elseClause) {
|
|
483
|
+
const elseRes = this.visitBody(elseClause);
|
|
484
|
+
const entry = elseRes?.entry ?? caseExit;
|
|
485
|
+
this.builder.edge(dispatch, entry, 'switch-case');
|
|
486
|
+
if (elseRes)
|
|
487
|
+
this.builder.connect(elseRes.exits, caseExit, 'seq');
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
// No `else` → a no-match path reaches the exit directly (keeps EXIT
|
|
491
|
+
// reverse-reachable even when every when body jumps).
|
|
492
|
+
this.builder.edge(dispatch, caseExit, 'switch-case');
|
|
493
|
+
}
|
|
494
|
+
this.cfc.pop();
|
|
495
|
+
return { entry: dispatch, exits: [caseExit] };
|
|
496
|
+
}
|
|
497
|
+
/** The `pattern`-field children of a `when` clause (a `when` may list several). */
|
|
498
|
+
whenPatterns(whenClause) {
|
|
499
|
+
const out = [];
|
|
500
|
+
for (let i = 0; i < whenClause.childCount; i++) {
|
|
501
|
+
if (whenClause.fieldNameForChild(i) === 'pattern') {
|
|
502
|
+
const c = whenClause.child(i);
|
|
503
|
+
if (c)
|
|
504
|
+
out.push(c);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
return out;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* `case VALUE; in PATTERN [if guard]; … else; … end` — the pattern-matching
|
|
511
|
+
* form (`case_match`). Same no-fallthrough dispatch as `case`/`when`; each
|
|
512
|
+
* `in_clause` body is dispatched with a `switch-case` edge and an `in_clause`
|
|
513
|
+
* guard is harvested as a conditional use on the dispatch.
|
|
514
|
+
*/
|
|
515
|
+
visitCaseMatch(stmt) {
|
|
516
|
+
const value = stmt.childForFieldName('value');
|
|
517
|
+
const dispatch = this.builder.newBlock(startLineOf(stmt), value ? endLineOf(value) : startLineOf(stmt), value ? `case ${value.text}` : 'case', 'normal', value ? this.harvest.facts(value) : undefined);
|
|
518
|
+
const caseExit = this.builder.newBlock(endLineOf(stmt), endLineOf(stmt), '');
|
|
519
|
+
const clauses = stmt.namedChildren.filter((c) => c.type === 'in_clause');
|
|
520
|
+
const elseClause = stmt.childForFieldName('else') ?? stmt.namedChildren.find((c) => c.type === 'else');
|
|
521
|
+
// An `in`-clause guard (`in P if g`) evaluates conditionally on the dispatch.
|
|
522
|
+
for (const c of clauses) {
|
|
523
|
+
const guard = c.childForFieldName('guard');
|
|
524
|
+
if (guard)
|
|
525
|
+
this.builder.attachFacts(dispatch, this.harvest.factsConditional(guard));
|
|
526
|
+
}
|
|
527
|
+
this.cfc.pushSwitch(caseExit, []);
|
|
528
|
+
for (const c of clauses) {
|
|
529
|
+
const bodyRes = this.visitBody(c.childForFieldName('body'));
|
|
530
|
+
const entry = bodyRes?.entry ?? caseExit;
|
|
531
|
+
this.builder.edge(dispatch, entry, 'switch-case');
|
|
532
|
+
if (bodyRes)
|
|
533
|
+
this.builder.connect(bodyRes.exits, caseExit, 'seq');
|
|
534
|
+
}
|
|
535
|
+
if (elseClause) {
|
|
536
|
+
const elseRes = this.visitBody(elseClause);
|
|
537
|
+
const entry = elseRes?.entry ?? caseExit;
|
|
538
|
+
this.builder.edge(dispatch, entry, 'switch-case');
|
|
539
|
+
if (elseRes)
|
|
540
|
+
this.builder.connect(elseRes.exits, caseExit, 'seq');
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
// A `case … in` with no `else` raises NoMatchingPatternError on no match,
|
|
544
|
+
// but the structural no-match edge keeps EXIT reverse-reachable.
|
|
545
|
+
this.builder.edge(dispatch, caseExit, 'switch-case');
|
|
546
|
+
}
|
|
547
|
+
this.cfc.pop();
|
|
548
|
+
return { entry: dispatch, exits: [caseExit] };
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* `begin … [rescue …]* [else …] [ensure …] end`. Mirrors the Python
|
|
552
|
+
* try-route-through:
|
|
553
|
+
* - `ensure` runs on every exit (normal, exception, early jumps) — a finalizer
|
|
554
|
+
* frame for early-exit threading + a normal/exceptional join.
|
|
555
|
+
* - each `rescue` handler catches from the protected body.
|
|
556
|
+
* - `else` runs only if the body completed with no exception.
|
|
557
|
+
*/
|
|
558
|
+
visitBegin(stmt) {
|
|
559
|
+
const children = this.statementsOf(stmt);
|
|
560
|
+
return this.buildProtected(stmt, children);
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* A method `body_statement` is an implicit `begin` — its trailing
|
|
564
|
+
* `rescue`/`else`/`ensure` children behave exactly like a `begin`'s. When there
|
|
565
|
+
* are none, this is just a straight statement sequence.
|
|
566
|
+
*/
|
|
567
|
+
visitImplicitBegin(stmt) {
|
|
568
|
+
const children = this.statementsOf(stmt);
|
|
569
|
+
const hasHandlers = children.some((c) => c.type === 'rescue' || c.type === 'else' || c.type === 'ensure');
|
|
570
|
+
if (!hasHandlers)
|
|
571
|
+
return this.visitSeq(children);
|
|
572
|
+
return this.buildProtected(stmt, children);
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Shared begin/rescue/else/ensure builder. `children` is the construct's
|
|
576
|
+
* ordered named children: leading protected statements, then the typed
|
|
577
|
+
* `rescue` / `else` / `ensure` clauses.
|
|
578
|
+
*/
|
|
579
|
+
buildProtected(span, children) {
|
|
580
|
+
const protectedStmts = [];
|
|
581
|
+
const rescueClauses = [];
|
|
582
|
+
let elseClause;
|
|
583
|
+
let ensureClause;
|
|
584
|
+
for (const c of children) {
|
|
585
|
+
if (c.type === 'rescue')
|
|
586
|
+
rescueClauses.push(c);
|
|
587
|
+
else if (c.type === 'else')
|
|
588
|
+
elseClause = c;
|
|
589
|
+
else if (c.type === 'ensure')
|
|
590
|
+
ensureClause = c;
|
|
591
|
+
else
|
|
592
|
+
protectedStmts.push(c);
|
|
593
|
+
}
|
|
594
|
+
// Build ensure first — it is both a normal join and a handler target. It runs
|
|
595
|
+
// OUTSIDE this begin's finalizer frame (a return inside ensure threads only
|
|
596
|
+
// OUTER ensures).
|
|
597
|
+
const ensureRes = ensureClause ? this.visitSeq(this.statementsOf(ensureClause)) : null;
|
|
598
|
+
const finFrame = ensureRes ? this.cfc.pushFinalizer(ensureRes.entry) : null;
|
|
599
|
+
// Pre-create each rescue's facts-only HEAD block (`rescue Exc => e` binds `e`
|
|
600
|
+
// once, on handler entry) so the protected body knows its handler target
|
|
601
|
+
// BEFORE either body is walked — this lets a `retry` inside a rescue handler
|
|
602
|
+
// re-enter the protected body's real entry (which is walked next).
|
|
603
|
+
const handlerEntries = rescueClauses.map((clause) => this.builder.newBlock(startLineOf(clause), startLineOf(clause), '', 'normal', this.harvest.rescueHeadFacts(clause)));
|
|
604
|
+
// Handler for the protected body: the first rescue if present, else ensure,
|
|
605
|
+
// else the outer handler.
|
|
606
|
+
const tryHandler = handlerEntries[0] ?? ensureRes?.entry ?? this.currentHandler();
|
|
607
|
+
const protectedStart = this.builder.blockCount;
|
|
608
|
+
this.handlers.push(tryHandler);
|
|
609
|
+
const bodyRes = this.visitSeq(protectedStmts);
|
|
610
|
+
this.handlers.pop();
|
|
611
|
+
// Block range covering ONLY the protected body (rescue handler bodies are
|
|
612
|
+
// walked afterward and must NOT get the conservative per-block throw edge).
|
|
613
|
+
const protectedEnd = this.builder.blockCount;
|
|
614
|
+
// The protected body's entry is where a `retry` re-enters (a `loop-back`).
|
|
615
|
+
// Push it for BOTH the rescue-handler bodies AND already-walked body (already
|
|
616
|
+
// done above — a `retry` in the body itself is a non-idiom, but harmless).
|
|
617
|
+
const beginEntry = bodyRes?.entry ?? handlerEntries[0] ?? this.builder.exitIndex;
|
|
618
|
+
this.beginEntries.push(beginEntry);
|
|
619
|
+
// Walk each rescue handler body now (within the begin-entry scope so a
|
|
620
|
+
// `retry` re-enters the protected body). A raise inside a handler propagates
|
|
621
|
+
// to ensure (if any), else the outer handler.
|
|
622
|
+
const handlerExits = [];
|
|
623
|
+
rescueClauses.forEach((clause, i) => {
|
|
624
|
+
if (ensureRes)
|
|
625
|
+
this.handlers.push(ensureRes.entry);
|
|
626
|
+
const headBlock = handlerEntries[i];
|
|
627
|
+
const handlerBodyRes = this.visitBody(clause.childForFieldName('body'));
|
|
628
|
+
if (handlerBodyRes) {
|
|
629
|
+
this.builder.edge(headBlock, handlerBodyRes.entry, 'seq');
|
|
630
|
+
handlerExits.push(...handlerBodyRes.exits);
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
handlerExits.push(headBlock); // empty handler — header is the exit
|
|
634
|
+
}
|
|
635
|
+
if (ensureRes)
|
|
636
|
+
this.handlers.pop();
|
|
637
|
+
});
|
|
638
|
+
this.beginEntries.pop();
|
|
639
|
+
// Conservative exceptional edges: ANY protected-region block may raise to
|
|
640
|
+
// EACH handler (an unmatched exception type tries the next handler).
|
|
641
|
+
if (rescueClauses.length > 0 || ensureClause) {
|
|
642
|
+
const targets = handlerEntries.length > 0 ? handlerEntries : ensureRes ? [ensureRes.entry] : [];
|
|
643
|
+
for (let b = protectedStart; b < protectedEnd; b++) {
|
|
644
|
+
for (const h of targets)
|
|
645
|
+
this.builder.edge(b, h, 'throw');
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
// The `else` runs only on no-exception normal completion of the body.
|
|
649
|
+
let normalAfterBody = bodyRes ? [...bodyRes.exits] : [];
|
|
650
|
+
if (elseClause) {
|
|
651
|
+
const elseRes = this.visitBody(elseClause);
|
|
652
|
+
if (elseRes && bodyRes) {
|
|
653
|
+
this.builder.connect(bodyRes.exits, elseRes.entry, 'seq');
|
|
654
|
+
normalAfterBody = [...elseRes.exits];
|
|
655
|
+
}
|
|
656
|
+
else if (elseRes) {
|
|
657
|
+
normalAfterBody = [...elseRes.exits];
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
// Close the finalizer frame; wire crossing-jump completion legs.
|
|
661
|
+
if (finFrame && ensureRes) {
|
|
662
|
+
this.cfc.pop();
|
|
663
|
+
(0, control_flow_context_js_1.drainFinalizerPending)(this.builder, finFrame, ensureRes.exits);
|
|
664
|
+
}
|
|
665
|
+
const exits = [];
|
|
666
|
+
if (ensureRes) {
|
|
667
|
+
// Normal completion of (body→else) AND each handler flows through ensure.
|
|
668
|
+
this.builder.connect(normalAfterBody, ensureRes.entry, 'seq');
|
|
669
|
+
this.builder.connect(handlerExits, ensureRes.entry, 'seq');
|
|
670
|
+
exits.push(...ensureRes.exits);
|
|
671
|
+
// A begin with no rescue → an uncaught exception re-propagates after ensure.
|
|
672
|
+
if (handlerEntries.length === 0) {
|
|
673
|
+
this.builder.connect(ensureRes.exits, this.currentHandler(), 'throw');
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
else {
|
|
677
|
+
exits.push(...normalAfterBody);
|
|
678
|
+
exits.push(...handlerExits);
|
|
679
|
+
}
|
|
680
|
+
const entry = bodyRes?.entry ?? ensureRes?.entry ?? handlerEntries[0];
|
|
681
|
+
if (entry === undefined) {
|
|
682
|
+
void span;
|
|
683
|
+
return null;
|
|
684
|
+
}
|
|
685
|
+
return { entry, exits: [...new Set(exits)] };
|
|
686
|
+
}
|
|
687
|
+
/** Nearest enclosing exception handler, or the function EXIT. */
|
|
688
|
+
currentHandler() {
|
|
689
|
+
return this.handlers.length ? this.handlers[this.handlers.length - 1] : this.builder.exitIndex;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
/** The body node of a Ruby function/block/lambda (a `block` for `lambda` unwraps once). */
|
|
693
|
+
function functionBody(fnNode) {
|
|
694
|
+
const body = fnNode.childForFieldName('body');
|
|
695
|
+
if (!body)
|
|
696
|
+
return undefined;
|
|
697
|
+
// A `lambda`'s `body` is a `block` wrapping a `block_body` — unwrap to the
|
|
698
|
+
// inner body so the walk sees the statement sequence.
|
|
699
|
+
if (fnNode.type === 'lambda' && body.type === 'block') {
|
|
700
|
+
return body.childForFieldName('body') ?? body;
|
|
701
|
+
}
|
|
702
|
+
return body;
|
|
703
|
+
}
|
|
704
|
+
/** Build the CFG for one Ruby function/block/lambda node, or `undefined` if not modelable. */
|
|
705
|
+
function buildFunctionCfg(fnNode, filePath) {
|
|
706
|
+
try {
|
|
707
|
+
if (!RUBY_FUNCTION_TYPES.has(fnNode.type))
|
|
708
|
+
return undefined;
|
|
709
|
+
const startLine = startLineOf(fnNode);
|
|
710
|
+
const endLine = endLineOf(fnNode);
|
|
711
|
+
const startColumn = fnNode.startPosition.column;
|
|
712
|
+
const body = functionBody(fnNode);
|
|
713
|
+
if (!body) {
|
|
714
|
+
// No body — an empty `def f; end` still gets a trivial ENTRY → EXIT CFG so
|
|
715
|
+
// it is not silently dropped.
|
|
716
|
+
const builder = new cfg_builder_js_1.CfgBuilder(filePath, startLine, endLine, startColumn);
|
|
717
|
+
const harvest = new ruby_harvest_js_1.RubyHarvester(fnNode);
|
|
718
|
+
const paramFacts = harvest.paramFacts();
|
|
719
|
+
if (paramFacts)
|
|
720
|
+
builder.attachFacts(builder.entryIndex, paramFacts);
|
|
721
|
+
builder.edge(builder.entryIndex, builder.exitIndex, 'seq');
|
|
722
|
+
return builder.finish(harvest.bindingTable());
|
|
723
|
+
}
|
|
724
|
+
const builder = new cfg_builder_js_1.CfgBuilder(filePath, startLine, endLine, startColumn);
|
|
725
|
+
const harvest = new ruby_harvest_js_1.RubyHarvester(fnNode);
|
|
726
|
+
const paramFacts = harvest.paramFacts();
|
|
727
|
+
if (paramFacts)
|
|
728
|
+
builder.attachFacts(builder.entryIndex, paramFacts);
|
|
729
|
+
const walk = new RubyCfgWalk(builder, harvest);
|
|
730
|
+
// For a bare block / lambda, a `redo` re-enters the block body. The body's
|
|
731
|
+
// first block is the NEXT index the builder will allocate (entry + exit are
|
|
732
|
+
// already taken). Set it so a top-level `redo` inside the block loops back.
|
|
733
|
+
if (fnNode.type !== 'method' && fnNode.type !== 'singleton_method') {
|
|
734
|
+
walk.setBlockRedoTarget(builder.blockCount);
|
|
735
|
+
}
|
|
736
|
+
const res = walk.visitStmt(body);
|
|
737
|
+
if (!res) {
|
|
738
|
+
builder.edge(builder.entryIndex, builder.exitIndex, 'seq'); // empty body
|
|
739
|
+
return builder.finish(harvest.bindingTable());
|
|
740
|
+
}
|
|
741
|
+
builder.edge(builder.entryIndex, res.entry, 'seq');
|
|
742
|
+
builder.connect(res.exits, builder.exitIndex, 'seq'); // normal fall-off → EXIT
|
|
743
|
+
return builder.finish(harvest.bindingTable());
|
|
744
|
+
}
|
|
745
|
+
catch (err) {
|
|
746
|
+
// Never throw out of buildFunctionCfg — a malformed AST shape must skip only
|
|
747
|
+
// this one function's CFG, never drop the whole file's language group (R4).
|
|
748
|
+
// eslint-disable-next-line no-console
|
|
749
|
+
console.warn(`[cfg] Ruby buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);
|
|
750
|
+
return undefined;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
/** Whether a node is a Ruby function/closure this visitor builds a CFG for. */
|
|
754
|
+
function isFunction(node) {
|
|
755
|
+
return RUBY_FUNCTION_TYPES.has(node.type);
|
|
756
|
+
}
|
|
757
|
+
/** The Ruby CFG visitor. */
|
|
758
|
+
function createRubyCfgVisitor() {
|
|
759
|
+
return { buildFunctionCfg, isFunction };
|
|
760
|
+
}
|