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,791 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SWIFT_FUNCTION_TYPES = void 0;
|
|
4
|
+
exports.createSwiftCfgVisitor = createSwiftCfgVisitor;
|
|
5
|
+
const cfg_builder_js_1 = require("../cfg-builder.js");
|
|
6
|
+
const control_flow_context_js_1 = require("../control-flow-context.js");
|
|
7
|
+
const control_flow_context_js_2 = require("../control-flow-context.js");
|
|
8
|
+
const swift_harvest_js_1 = require("./swift-harvest.js");
|
|
9
|
+
/** Swift node types that own a CFG-bearing function body. */
|
|
10
|
+
const SWIFT_FUNCTION_TYPES = new Set([
|
|
11
|
+
'function_declaration',
|
|
12
|
+
'init_declaration',
|
|
13
|
+
'deinit_declaration',
|
|
14
|
+
'lambda_literal',
|
|
15
|
+
]);
|
|
16
|
+
exports.SWIFT_FUNCTION_TYPES = SWIFT_FUNCTION_TYPES;
|
|
17
|
+
/** Statement node types that break a basic block (everything else coalesces). */
|
|
18
|
+
const CONTROL_FLOW_TYPES = new Set([
|
|
19
|
+
'if_statement',
|
|
20
|
+
'guard_statement',
|
|
21
|
+
'for_statement',
|
|
22
|
+
'while_statement',
|
|
23
|
+
'repeat_while_statement',
|
|
24
|
+
'switch_statement',
|
|
25
|
+
'do_statement',
|
|
26
|
+
'control_transfer_statement',
|
|
27
|
+
'statements',
|
|
28
|
+
]);
|
|
29
|
+
const startLineOf = (n) => n.startPosition.row + 1;
|
|
30
|
+
const endLineOf = (n) => n.endPosition.row + 1;
|
|
31
|
+
/**
|
|
32
|
+
* Per-function Swift walk state. One instance per function so the
|
|
33
|
+
* {@link ControlFlowContext}, the `defer` finalizer chain, and the label tables
|
|
34
|
+
* are scoped to that function and never leak across functions.
|
|
35
|
+
*/
|
|
36
|
+
class SwiftCfgWalk {
|
|
37
|
+
builder;
|
|
38
|
+
harvest;
|
|
39
|
+
cfc = new control_flow_context_js_1.ControlFlowContext();
|
|
40
|
+
/** Stack of `do`/`catch` handler entry blocks a `throw`/`try` jumps to. */
|
|
41
|
+
handlers = [];
|
|
42
|
+
/** Label(s) pending attachment to the NEXT pushed loop/switch frame. */
|
|
43
|
+
pendingLabels = [];
|
|
44
|
+
/**
|
|
45
|
+
* Active `defer` finalizer frames in source (push) order. Innermost-LIFO is the
|
|
46
|
+
* REVERSE of this list. Frames stay active for the whole function tail and are
|
|
47
|
+
* drained once at the top-level walk's end (mirrors the Go visitor).
|
|
48
|
+
*/
|
|
49
|
+
deferFrames = [];
|
|
50
|
+
constructor(builder, harvest) {
|
|
51
|
+
this.builder = builder;
|
|
52
|
+
this.harvest = harvest;
|
|
53
|
+
}
|
|
54
|
+
/** Statements of a `statements` node, ignoring comments. */
|
|
55
|
+
statementsOf(block) {
|
|
56
|
+
return block.namedChildren.filter((c) => c.type !== 'comment' && c.type !== 'multiline_comment');
|
|
57
|
+
}
|
|
58
|
+
/** The body `statements` of a loop/branch node (the LAST `statements` child). */
|
|
59
|
+
bodyStatements(node) {
|
|
60
|
+
const all = node.namedChildren.filter((c) => c.type === 'statements');
|
|
61
|
+
return all.length ? all[all.length - 1] : undefined;
|
|
62
|
+
}
|
|
63
|
+
/** Visit a body that is a `statements` node (or a single statement). */
|
|
64
|
+
visitBody(node) {
|
|
65
|
+
return this.builder.withNesting(() => {
|
|
66
|
+
if (!node)
|
|
67
|
+
return null;
|
|
68
|
+
if (node.type === 'statements')
|
|
69
|
+
return this.visitSeq(this.statementsOf(node));
|
|
70
|
+
return this.visitStmt(node);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/** Wire a sequence of statements, coalescing straight-line runs into blocks. */
|
|
74
|
+
visitSeq(stmts) {
|
|
75
|
+
return this.builder.withNesting(() => {
|
|
76
|
+
let entry;
|
|
77
|
+
let dangling = [];
|
|
78
|
+
let openSimple;
|
|
79
|
+
for (const stmt of stmts) {
|
|
80
|
+
if (this.isControlFlow(stmt)) {
|
|
81
|
+
openSimple = undefined; // close any open straight-line block
|
|
82
|
+
const res = this.visitStmt(stmt);
|
|
83
|
+
if (res === null)
|
|
84
|
+
continue; // transparent (empty nested block / label)
|
|
85
|
+
if (entry === undefined)
|
|
86
|
+
entry = res.entry;
|
|
87
|
+
else
|
|
88
|
+
this.builder.connect(dangling, res.entry, 'seq');
|
|
89
|
+
dangling = [...res.exits];
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
if (openSimple === undefined) {
|
|
93
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text, 'normal', this.harvest.facts(stmt));
|
|
94
|
+
if (entry === undefined)
|
|
95
|
+
entry = idx;
|
|
96
|
+
else
|
|
97
|
+
this.builder.connect(dangling, idx, 'seq');
|
|
98
|
+
openSimple = idx;
|
|
99
|
+
dangling = [idx];
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.builder.extendBlock(openSimple, endLineOf(stmt), stmt.text, this.harvest.facts(stmt));
|
|
103
|
+
}
|
|
104
|
+
// A straight-line statement may contain a `try` — it can error-return.
|
|
105
|
+
this.wireTryExits(stmt, openSimple);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (entry === undefined)
|
|
109
|
+
return null;
|
|
110
|
+
return { entry, exits: dangling };
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/** Whether a statement node breaks the current straight-line block. */
|
|
114
|
+
isControlFlow(stmt) {
|
|
115
|
+
if (stmt.type === 'statement_label')
|
|
116
|
+
return true; // queue label, emit no block
|
|
117
|
+
if (this.isDeferCall(stmt))
|
|
118
|
+
return true;
|
|
119
|
+
// `let x = if … / switch …` (Swift 5.9, #2207): a value-position branch breaks
|
|
120
|
+
// so `visitStmt` models the arms as control flow instead of coalescing.
|
|
121
|
+
if (stmt.type === 'property_declaration') {
|
|
122
|
+
const v = this.directValue(stmt);
|
|
123
|
+
return v !== undefined && this.isModelableValueBranch(v);
|
|
124
|
+
}
|
|
125
|
+
return CONTROL_FLOW_TYPES.has(stmt.type);
|
|
126
|
+
}
|
|
127
|
+
/** Dispatch one statement to its handler. Non-null except for empty / label-only. */
|
|
128
|
+
visitStmt(stmt) {
|
|
129
|
+
if (stmt.type === 'statement_label') {
|
|
130
|
+
// A label preceding its loop/switch — queue it; the construct picks it up.
|
|
131
|
+
const name = this.labelName(stmt);
|
|
132
|
+
if (name !== undefined)
|
|
133
|
+
this.pendingLabels = [...this.pendingLabels, name];
|
|
134
|
+
return null; // emits no block of its own
|
|
135
|
+
}
|
|
136
|
+
if (this.isDeferCall(stmt))
|
|
137
|
+
return this.visitDefer(stmt);
|
|
138
|
+
switch (stmt.type) {
|
|
139
|
+
case 'property_declaration': {
|
|
140
|
+
// `let x = if … / switch …` (Swift 5.9, #2207): the value is a value-
|
|
141
|
+
// position branch — model it as control flow and bind on the rejoin.
|
|
142
|
+
const value = this.directValue(stmt);
|
|
143
|
+
if (value && this.isModelableValueBranch(value))
|
|
144
|
+
return this.visitBindBranch(stmt, value);
|
|
145
|
+
return this.visitSimple(stmt);
|
|
146
|
+
}
|
|
147
|
+
case 'if_statement':
|
|
148
|
+
return this.visitIf(stmt);
|
|
149
|
+
case 'guard_statement':
|
|
150
|
+
return this.visitGuard(stmt);
|
|
151
|
+
case 'for_statement':
|
|
152
|
+
return this.visitFor(stmt);
|
|
153
|
+
case 'while_statement':
|
|
154
|
+
return this.visitWhile(stmt);
|
|
155
|
+
case 'repeat_while_statement':
|
|
156
|
+
return this.visitRepeatWhile(stmt);
|
|
157
|
+
case 'switch_statement':
|
|
158
|
+
return this.visitSwitch(stmt);
|
|
159
|
+
case 'do_statement':
|
|
160
|
+
return this.visitDo(stmt);
|
|
161
|
+
case 'control_transfer_statement':
|
|
162
|
+
return this.visitControlTransfer(stmt);
|
|
163
|
+
case 'statements':
|
|
164
|
+
return this.visitSeq(this.statementsOf(stmt));
|
|
165
|
+
default:
|
|
166
|
+
return this.visitSimple(stmt);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
visitSimple(stmt) {
|
|
170
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text, 'normal', this.harvest.facts(stmt));
|
|
171
|
+
this.wireTryExits(stmt, idx);
|
|
172
|
+
return { entry: idx, exits: [idx] };
|
|
173
|
+
}
|
|
174
|
+
// ── control transfer (break / continue / return / throw) ─────────────────
|
|
175
|
+
/** The leading keyword of a `control_transfer_statement` decides its kind. */
|
|
176
|
+
transferKeyword(stmt) {
|
|
177
|
+
const first = stmt.child(0);
|
|
178
|
+
return first?.text ?? '';
|
|
179
|
+
}
|
|
180
|
+
visitControlTransfer(stmt) {
|
|
181
|
+
const kw = this.transferKeyword(stmt);
|
|
182
|
+
switch (kw) {
|
|
183
|
+
case 'return':
|
|
184
|
+
return this.visitReturn(stmt);
|
|
185
|
+
case 'throw':
|
|
186
|
+
return this.visitThrow(stmt);
|
|
187
|
+
case 'break':
|
|
188
|
+
return this.visitBreak(stmt);
|
|
189
|
+
case 'continue':
|
|
190
|
+
return this.visitContinue(stmt);
|
|
191
|
+
default:
|
|
192
|
+
// `fallthrough` standalone (rare outside a switch) / unknown — straight
|
|
193
|
+
// through (the switch handler treats the in-case `fallthrough` keyword).
|
|
194
|
+
return this.visitSimple(stmt);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/** `return [expr]` — threads through every active `defer` (LIFO) before EXIT. */
|
|
198
|
+
visitReturn(stmt) {
|
|
199
|
+
// `return if … / switch …` (Swift 5.9, #2207): the returned value is a value-
|
|
200
|
+
// position branch — model it as control flow, with each arm returning (its
|
|
201
|
+
// value IS the function result), threading every active finalizer per arm.
|
|
202
|
+
const branch = stmt.namedChildren.find((c) => c.type === 'if_statement' || c.type === 'switch_statement');
|
|
203
|
+
if (branch && this.isModelableValueBranch(branch)) {
|
|
204
|
+
const res = this.visitBranchExpr(branch);
|
|
205
|
+
const finalizers = this.cfc.finalizersForReturn();
|
|
206
|
+
for (const ex of res.exits) {
|
|
207
|
+
(0, control_flow_context_js_1.wireJumpThroughFinalizers)(this.builder, ex, finalizers, this.builder.exitIndex, 'return');
|
|
208
|
+
}
|
|
209
|
+
return { entry: res.entry, exits: [] };
|
|
210
|
+
}
|
|
211
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text, 'normal', this.harvest.facts(stmt));
|
|
212
|
+
this.wireTryExits(stmt, idx);
|
|
213
|
+
(0, control_flow_context_js_1.wireJumpThroughFinalizers)(this.builder, idx, this.cfc.finalizersForReturn(), this.builder.exitIndex, 'return');
|
|
214
|
+
return { entry: idx, exits: [] };
|
|
215
|
+
}
|
|
216
|
+
/** `throw e` — routes to the nearest enclosing `catch` handler, else EXIT. */
|
|
217
|
+
visitThrow(stmt) {
|
|
218
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text, 'normal', this.harvest.facts(stmt));
|
|
219
|
+
this.builder.edge(idx, this.currentHandler(), 'throw');
|
|
220
|
+
return { entry: idx, exits: [] };
|
|
221
|
+
}
|
|
222
|
+
visitBreak(stmt) {
|
|
223
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text);
|
|
224
|
+
const label = this.jumpLabel(stmt);
|
|
225
|
+
const res = this.cfc.resolveBreak(label);
|
|
226
|
+
const { target, finalizers } = res ?? {
|
|
227
|
+
target: this.builder.exitIndex,
|
|
228
|
+
finalizers: this.cfc.finalizersForReturn(),
|
|
229
|
+
};
|
|
230
|
+
(0, control_flow_context_js_1.wireJumpThroughFinalizers)(this.builder, idx, finalizers, target, 'break');
|
|
231
|
+
return { entry: idx, exits: [] };
|
|
232
|
+
}
|
|
233
|
+
visitContinue(stmt) {
|
|
234
|
+
const idx = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text);
|
|
235
|
+
const label = this.jumpLabel(stmt);
|
|
236
|
+
const res = this.cfc.resolveContinue(label);
|
|
237
|
+
const { target, finalizers } = res ?? {
|
|
238
|
+
target: this.builder.exitIndex,
|
|
239
|
+
finalizers: this.cfc.finalizersForReturn(),
|
|
240
|
+
};
|
|
241
|
+
(0, control_flow_context_js_1.wireJumpThroughFinalizers)(this.builder, idx, finalizers, target, 'continue');
|
|
242
|
+
return { entry: idx, exits: [] };
|
|
243
|
+
}
|
|
244
|
+
/** The `result` label of a `break outer` / `continue outer`, if any. */
|
|
245
|
+
jumpLabel(stmt) {
|
|
246
|
+
const result = stmt.childForFieldName('result');
|
|
247
|
+
return result?.type === 'simple_identifier' ? result.text : undefined;
|
|
248
|
+
}
|
|
249
|
+
/** The bare name of a `statement_label` (`outer:` ⇒ `outer`). */
|
|
250
|
+
labelName(label) {
|
|
251
|
+
const id = label.namedChildren.find((c) => c.type === 'simple_identifier');
|
|
252
|
+
if (id?.text)
|
|
253
|
+
return id.text;
|
|
254
|
+
const stripped = label.text.replace(/:\s*$/, '').trim();
|
|
255
|
+
return stripped || undefined;
|
|
256
|
+
}
|
|
257
|
+
/** Take and clear the labels queued by a preceding `statement_label`. */
|
|
258
|
+
takeLabels() {
|
|
259
|
+
const labels = this.pendingLabels;
|
|
260
|
+
this.pendingLabels = [];
|
|
261
|
+
return labels;
|
|
262
|
+
}
|
|
263
|
+
// ── value-position branches (#2207) ─────────────────────────────────────────
|
|
264
|
+
/**
|
|
265
|
+
* The value-position branch of a `property_declaration` (`let x = if … / switch
|
|
266
|
+
* …`, Swift 5.9): the direct `if_statement` / `switch_statement` child (the value
|
|
267
|
+
* after `=`), or undefined. tree-sitter-swift reuses the statement nodes for the
|
|
268
|
+
* value form — there is no separate `if_expression` / `switch_expression`.
|
|
269
|
+
*/
|
|
270
|
+
directValue(stmt) {
|
|
271
|
+
return stmt.namedChildren.find((c) => c.type === 'if_statement' || c.type === 'switch_statement');
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Whether `node` is a value-position branch worth modeling as control flow
|
|
275
|
+
* (#2207): an `if` with an `else` (a value-position `if` always has one), or a
|
|
276
|
+
* `switch` with ≥2 entries — a real dispatch. The ternary `?:` and `??` are
|
|
277
|
+
* excluded by design (micro-branches, like the Kotlin elvis).
|
|
278
|
+
*/
|
|
279
|
+
isModelableValueBranch(node) {
|
|
280
|
+
if (node.type === 'if_statement')
|
|
281
|
+
return this.elseNodeOf(node) !== undefined;
|
|
282
|
+
if (node.type === 'switch_statement') {
|
|
283
|
+
return node.namedChildren.filter((c) => c.type === 'switch_entry').length >= 2;
|
|
284
|
+
}
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
/** Model a value-position `if`/`switch` as control flow, bypassing position. */
|
|
288
|
+
visitBranchExpr(node) {
|
|
289
|
+
return node.type === 'switch_statement' ? this.visitSwitch(node) : this.visitIf(node);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* `let x = if … / switch …` (#2207): visit the branch as control flow, then
|
|
293
|
+
* rejoin its arms at a facts-only continuation carrying ONLY the bound name's
|
|
294
|
+
* def (the condition + arm-value uses are already on the branch's blocks). The
|
|
295
|
+
* arms are now control-dependent on the branch — mirrors Kotlin / Rust.
|
|
296
|
+
*/
|
|
297
|
+
visitBindBranch(stmt, branch) {
|
|
298
|
+
const res = this.visitBranchExpr(branch);
|
|
299
|
+
const cont = this.builder.newBlock(startLineOf(stmt), startLineOf(stmt), '', 'normal', this.harvest.bindingDefFacts(stmt));
|
|
300
|
+
this.builder.connect(res.exits, cont, 'seq');
|
|
301
|
+
return { entry: res.entry, exits: [cont] };
|
|
302
|
+
}
|
|
303
|
+
// ── branches ──────────────────────────────────────────────────────────────
|
|
304
|
+
/**
|
|
305
|
+
* `if COND { … } [else { … } | else if …]`. COND may be a plain expression or
|
|
306
|
+
* an optional binding (`if let y = opt`). The else is the node AFTER the `else`
|
|
307
|
+
* keyword — a nested `if_statement` (`else if`) or the else-body `statements`.
|
|
308
|
+
*/
|
|
309
|
+
visitIf(stmt) {
|
|
310
|
+
const header = this.builder.newBlock(startLineOf(stmt), this.conditionEndLine(stmt), this.conditionText(stmt), 'normal', this.harvest.conditionFacts(stmt, false));
|
|
311
|
+
const exits = [];
|
|
312
|
+
const thenRes = this.visitBody(this.thenStatements(stmt));
|
|
313
|
+
if (thenRes) {
|
|
314
|
+
this.builder.edge(header, thenRes.entry, 'cond-true');
|
|
315
|
+
exits.push(...thenRes.exits);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
exits.push(header); // empty then — true path falls through
|
|
319
|
+
}
|
|
320
|
+
const elseNode = this.elseNodeOf(stmt);
|
|
321
|
+
if (elseNode) {
|
|
322
|
+
const elseRes = this.visitBody(elseNode);
|
|
323
|
+
if (elseRes) {
|
|
324
|
+
this.builder.edge(header, elseRes.entry, 'cond-false');
|
|
325
|
+
exits.push(...elseRes.exits);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
exits.push(header);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
exits.push(header); // no else — false path falls through to the join
|
|
333
|
+
}
|
|
334
|
+
return { entry: header, exits: [...new Set(exits)] };
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* `guard COND else { … }` — the inverse of `if`. The `else` body runs when COND
|
|
338
|
+
* is false and (per Swift) MUST diverge (return/throw/break/continue); it is
|
|
339
|
+
* branched with a `cond-false` edge. The guard body CONTINUES straight-line on
|
|
340
|
+
* the true path (`cond-true`).
|
|
341
|
+
*/
|
|
342
|
+
visitGuard(stmt) {
|
|
343
|
+
const header = this.builder.newBlock(startLineOf(stmt), this.conditionEndLine(stmt), this.conditionText(stmt), 'normal', this.harvest.conditionFacts(stmt, false));
|
|
344
|
+
// The else body is the guard's `statements` (after the `else` keyword).
|
|
345
|
+
const elseNode = this.elseNodeOf(stmt) ?? this.bodyStatements(stmt);
|
|
346
|
+
if (elseNode) {
|
|
347
|
+
const elseRes = this.visitBody(elseNode);
|
|
348
|
+
if (elseRes) {
|
|
349
|
+
this.builder.edge(header, elseRes.entry, 'cond-false');
|
|
350
|
+
// The else MUST diverge; any normal exit it leaves rejoins EXIT-bound
|
|
351
|
+
// flow conservatively (Swift forbids fall-through, but stay robust).
|
|
352
|
+
this.builder.connect(elseRes.exits, this.builder.exitIndex, 'seq');
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
this.builder.edge(header, this.builder.exitIndex, 'cond-false');
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
this.builder.edge(header, this.builder.exitIndex, 'cond-false');
|
|
360
|
+
}
|
|
361
|
+
// The true path continues straight-line after the guard.
|
|
362
|
+
return { entry: header, exits: [header] };
|
|
363
|
+
}
|
|
364
|
+
/** The THEN body `statements` of an `if`/`guard` (the first `statements` child). */
|
|
365
|
+
thenStatements(stmt) {
|
|
366
|
+
return stmt.namedChildren.find((c) => c.type === 'statements');
|
|
367
|
+
}
|
|
368
|
+
/** The node after the `else` keyword: a nested `if_statement` or the else `statements`. */
|
|
369
|
+
elseNodeOf(stmt) {
|
|
370
|
+
let sawElse = false;
|
|
371
|
+
for (let i = 0; i < stmt.childCount; i++) {
|
|
372
|
+
const c = stmt.child(i);
|
|
373
|
+
if (!c)
|
|
374
|
+
continue;
|
|
375
|
+
if (sawElse && c.isNamed)
|
|
376
|
+
return c;
|
|
377
|
+
if (c.type === 'else')
|
|
378
|
+
sawElse = true;
|
|
379
|
+
}
|
|
380
|
+
return undefined;
|
|
381
|
+
}
|
|
382
|
+
/** End line of a construct's condition (the last `condition`-field child). */
|
|
383
|
+
conditionEndLine(stmt) {
|
|
384
|
+
let line = startLineOf(stmt);
|
|
385
|
+
for (let i = 0; i < stmt.childCount; i++) {
|
|
386
|
+
const field = stmt.fieldNameForChild(i);
|
|
387
|
+
const c = stmt.child(i);
|
|
388
|
+
if (c && (field === 'condition' || field === 'bound_identifier'))
|
|
389
|
+
line = endLineOf(c);
|
|
390
|
+
}
|
|
391
|
+
return line;
|
|
392
|
+
}
|
|
393
|
+
/** Display text for a construct's condition (joined `condition`-field children). */
|
|
394
|
+
conditionText(stmt) {
|
|
395
|
+
const parts = [];
|
|
396
|
+
const kw = stmt.child(0);
|
|
397
|
+
if (kw && !kw.isNamed)
|
|
398
|
+
parts.push(kw.text);
|
|
399
|
+
for (let i = 0; i < stmt.childCount; i++) {
|
|
400
|
+
const field = stmt.fieldNameForChild(i);
|
|
401
|
+
const c = stmt.child(i);
|
|
402
|
+
if (c && (field === 'condition' || field === 'bound_identifier'))
|
|
403
|
+
parts.push(c.text);
|
|
404
|
+
}
|
|
405
|
+
return parts.join(' ') || stmt.text;
|
|
406
|
+
}
|
|
407
|
+
// ── loops ───────────────────────────────────────────────────────────────
|
|
408
|
+
/** `for item in COLLECTION [where …] { … }`. */
|
|
409
|
+
visitFor(stmt) {
|
|
410
|
+
const labels = this.takeLabels();
|
|
411
|
+
const collection = stmt.childForFieldName('collection');
|
|
412
|
+
const header = this.builder.newBlock(startLineOf(stmt), collection ? endLineOf(collection) : startLineOf(stmt), this.forHeaderText(stmt), 'normal', this.harvest.forHeadFacts(stmt));
|
|
413
|
+
const loopExit = this.builder.newBlock(endLineOf(stmt), endLineOf(stmt), '');
|
|
414
|
+
this.cfc.pushLoop(header, loopExit, labels);
|
|
415
|
+
const body = this.visitBody(this.bodyStatements(stmt));
|
|
416
|
+
this.cfc.pop();
|
|
417
|
+
if (body) {
|
|
418
|
+
this.builder.edge(header, body.entry, 'cond-true');
|
|
419
|
+
this.builder.connect(body.exits, header, 'loop-back');
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
this.builder.edge(header, header, 'loop-back'); // empty body re-iterates
|
|
423
|
+
}
|
|
424
|
+
this.builder.edge(header, loopExit, 'cond-false');
|
|
425
|
+
return { entry: header, exits: [loopExit] };
|
|
426
|
+
}
|
|
427
|
+
forHeaderText(stmt) {
|
|
428
|
+
const item = stmt.childForFieldName('item')?.text ?? '';
|
|
429
|
+
const collection = stmt.childForFieldName('collection')?.text ?? '';
|
|
430
|
+
return item || collection ? `for ${item} in ${collection}` : 'for';
|
|
431
|
+
}
|
|
432
|
+
/** `while COND { … }` (and `while let PAT = e { … }`). */
|
|
433
|
+
visitWhile(stmt) {
|
|
434
|
+
const labels = this.takeLabels();
|
|
435
|
+
const header = this.builder.newBlock(startLineOf(stmt), this.conditionEndLine(stmt), this.conditionText(stmt), 'normal', this.harvest.conditionFacts(stmt, true));
|
|
436
|
+
const loopExit = this.builder.newBlock(endLineOf(stmt), endLineOf(stmt), '');
|
|
437
|
+
this.cfc.pushLoop(header, loopExit, labels);
|
|
438
|
+
const body = this.visitBody(this.bodyStatements(stmt));
|
|
439
|
+
this.cfc.pop();
|
|
440
|
+
if (body) {
|
|
441
|
+
this.builder.edge(header, body.entry, 'cond-true');
|
|
442
|
+
this.builder.connect(body.exits, header, 'loop-back');
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
this.builder.edge(header, header, 'loop-back'); // empty body re-tests
|
|
446
|
+
}
|
|
447
|
+
// Structural exit edge — even `while true {}` keeps EXIT reverse-reachable.
|
|
448
|
+
this.builder.edge(header, loopExit, 'cond-false');
|
|
449
|
+
return { entry: header, exits: [loopExit] };
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* `repeat { … } while COND` — BOTTOM-TEST: the body runs at least once, THEN
|
|
453
|
+
* the condition decides whether to loop back. The body entry is the loop entry;
|
|
454
|
+
* the condition block is the loop-back / exit decision.
|
|
455
|
+
*/
|
|
456
|
+
visitRepeatWhile(stmt) {
|
|
457
|
+
const labels = this.takeLabels();
|
|
458
|
+
const cond = stmt.childForFieldName('condition');
|
|
459
|
+
const condBlock = this.builder.newBlock(cond ? startLineOf(cond) : endLineOf(stmt), cond ? endLineOf(cond) : endLineOf(stmt), cond ? `while ${cond.text}` : 'while', 'normal', cond ? this.harvest.facts(cond) : undefined);
|
|
460
|
+
const loopExit = this.builder.newBlock(endLineOf(stmt), endLineOf(stmt), '');
|
|
461
|
+
// `continue` re-tests the condition; `break` leaves the loop.
|
|
462
|
+
this.cfc.pushLoop(condBlock, loopExit, labels);
|
|
463
|
+
const body = this.visitBody(this.bodyStatements(stmt));
|
|
464
|
+
this.cfc.pop();
|
|
465
|
+
const backTarget = body ? body.entry : condBlock;
|
|
466
|
+
if (body)
|
|
467
|
+
this.builder.connect(body.exits, condBlock, 'seq');
|
|
468
|
+
this.builder.edge(condBlock, backTarget, 'loop-back'); // cond true → run body again
|
|
469
|
+
// Structural exit edge — even `repeat {} while true` keeps EXIT reachable.
|
|
470
|
+
this.builder.edge(condBlock, loopExit, 'cond-false');
|
|
471
|
+
return { entry: backTarget, exits: [loopExit] };
|
|
472
|
+
}
|
|
473
|
+
// ── switch ───────────────────────────────────────────────────────────────
|
|
474
|
+
/**
|
|
475
|
+
* `switch EXPR { case … : … fallthrough? … default: … }`. Cases do NOT fall
|
|
476
|
+
* through implicitly (the opposite of C); an explicit `fallthrough` keyword at
|
|
477
|
+
* the end of a `switch_entry` spills into the NEXT entry's body. A `where` guard
|
|
478
|
+
* on a case is harvested conditionally onto the dispatch block.
|
|
479
|
+
*/
|
|
480
|
+
visitSwitch(stmt) {
|
|
481
|
+
const labels = this.takeLabels();
|
|
482
|
+
const value = stmt.childForFieldName('expr');
|
|
483
|
+
const dispatch = this.builder.newBlock(startLineOf(stmt), value ? endLineOf(value) : startLineOf(stmt), value ? `switch ${value.text}` : 'switch', 'normal', value ? this.harvest.facts(value) : undefined);
|
|
484
|
+
const switchExit = this.builder.newBlock(endLineOf(stmt), endLineOf(stmt), '');
|
|
485
|
+
this.cfc.pushSwitch(switchExit, labels);
|
|
486
|
+
const entries = stmt.namedChildren.filter((c) => c.type === 'switch_entry');
|
|
487
|
+
// A case `where` guard evaluates conditionally before the body — harvest its
|
|
488
|
+
// uses onto the dispatch block (a later case tests only when earlier ones
|
|
489
|
+
// didn't match; any def there is a may-def).
|
|
490
|
+
for (const entry of entries) {
|
|
491
|
+
// `case let n` value bindings are may-defs on the dispatch block (the case
|
|
492
|
+
// may not match) — propagated into the body where the name is read.
|
|
493
|
+
const pat = this.entryPattern(entry);
|
|
494
|
+
if (pat)
|
|
495
|
+
this.builder.attachFacts(dispatch, this.harvest.switchPatternFacts(pat));
|
|
496
|
+
const guard = this.entryGuard(entry);
|
|
497
|
+
if (guard)
|
|
498
|
+
this.builder.attachFacts(dispatch, this.harvest.factsConditional(guard));
|
|
499
|
+
}
|
|
500
|
+
const entryResults = entries.map((e) => this.visitBody(this.entryBody(e)));
|
|
501
|
+
const hasDefault = entries.some((e) => this.entryIsDefault(e));
|
|
502
|
+
const entryOf = new Array(entries.length);
|
|
503
|
+
let after = switchExit;
|
|
504
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
505
|
+
entryOf[i] = entryResults[i]?.entry ?? after;
|
|
506
|
+
after = entryOf[i];
|
|
507
|
+
}
|
|
508
|
+
for (let i = 0; i < entries.length; i++) {
|
|
509
|
+
this.builder.edge(dispatch, entryOf[i], 'switch-case');
|
|
510
|
+
}
|
|
511
|
+
if (!hasDefault)
|
|
512
|
+
this.builder.edge(dispatch, switchExit, 'switch-case'); // no-match path
|
|
513
|
+
// A case body rejoins AFTER the switch (no implicit fallthrough) UNLESS the
|
|
514
|
+
// entry ends in an explicit `fallthrough`, which spills into the next entry.
|
|
515
|
+
for (let i = 0; i < entries.length; i++) {
|
|
516
|
+
const res = entryResults[i];
|
|
517
|
+
if (!res)
|
|
518
|
+
continue;
|
|
519
|
+
const fallsThrough = this.entryFallsThrough(entries[i]);
|
|
520
|
+
const fallTarget = i + 1 < entries.length ? entryOf[i + 1] : switchExit;
|
|
521
|
+
if (fallsThrough)
|
|
522
|
+
this.builder.connect(res.exits, fallTarget, 'fallthrough');
|
|
523
|
+
else
|
|
524
|
+
this.builder.connect(res.exits, switchExit, 'seq');
|
|
525
|
+
}
|
|
526
|
+
this.cfc.pop();
|
|
527
|
+
return { entry: dispatch, exits: [switchExit] };
|
|
528
|
+
}
|
|
529
|
+
/** The `switch_pattern` of a `switch_entry` (absent for `default:`). */
|
|
530
|
+
entryPattern(entry) {
|
|
531
|
+
return entry.namedChildren.find((c) => c.type === 'switch_pattern');
|
|
532
|
+
}
|
|
533
|
+
/** The `where` guard expression of a `switch_entry`, if any. */
|
|
534
|
+
entryGuard(entry) {
|
|
535
|
+
let sawWhere = false;
|
|
536
|
+
for (let i = 0; i < entry.childCount; i++) {
|
|
537
|
+
const c = entry.child(i);
|
|
538
|
+
if (!c)
|
|
539
|
+
continue;
|
|
540
|
+
if (sawWhere && c.isNamed)
|
|
541
|
+
return c;
|
|
542
|
+
if (c.type === 'where_keyword')
|
|
543
|
+
sawWhere = true;
|
|
544
|
+
}
|
|
545
|
+
return undefined;
|
|
546
|
+
}
|
|
547
|
+
/** The body `statements` of a `switch_entry`. */
|
|
548
|
+
entryBody(entry) {
|
|
549
|
+
return entry.namedChildren.find((c) => c.type === 'statements');
|
|
550
|
+
}
|
|
551
|
+
entryIsDefault(entry) {
|
|
552
|
+
return (entry.namedChildren.some((c) => c.type === 'default_keyword') ||
|
|
553
|
+
entry.children.some((c) => c.type === 'default_keyword'));
|
|
554
|
+
}
|
|
555
|
+
/** A `switch_entry` ends in an explicit `fallthrough` keyword child. */
|
|
556
|
+
entryFallsThrough(entry) {
|
|
557
|
+
for (let i = 0; i < entry.childCount; i++) {
|
|
558
|
+
if (entry.child(i)?.type === 'fallthrough')
|
|
559
|
+
return true;
|
|
560
|
+
}
|
|
561
|
+
return false;
|
|
562
|
+
}
|
|
563
|
+
// ── do / catch (error handling) ──────────────────────────────────────────
|
|
564
|
+
/**
|
|
565
|
+
* `do { … } catch [pat] { … }`. Conservative exceptional flow (mirrors the C++
|
|
566
|
+
* `try`/`catch` over-approximation): every block created while walking the
|
|
567
|
+
* protected `do` body edges to the FIRST catch handler — a `try`/`throw` may
|
|
568
|
+
* fire mid-block. Each `catch_block`'s normal completion joins the post-`do`
|
|
569
|
+
* continuation.
|
|
570
|
+
*/
|
|
571
|
+
visitDo(stmt) {
|
|
572
|
+
const bodyNode = stmt.namedChildren.find((c) => c.type === 'statements');
|
|
573
|
+
const catchBlocks = stmt.namedChildren.filter((c) => c.type === 'catch_block');
|
|
574
|
+
// Build each catch handler. The handler entry is the error-binding block (a
|
|
575
|
+
// facts-only block) in front of the body, so the binding happens once on entry.
|
|
576
|
+
const handlerEntries = [];
|
|
577
|
+
const handlerExits = [];
|
|
578
|
+
for (const clause of catchBlocks) {
|
|
579
|
+
const clauseBody = clause.namedChildren.find((c) => c.type === 'statements');
|
|
580
|
+
let res = clauseBody ? this.visitSeq(this.statementsOf(clauseBody)) : null;
|
|
581
|
+
if (res === null) {
|
|
582
|
+
// Empty catch body still CATCHES — synthesize one block so the error
|
|
583
|
+
// lands somewhere and post-`do` code stays reachable.
|
|
584
|
+
const idx = this.builder.newBlock(startLineOf(clause), endLineOf(clause), '');
|
|
585
|
+
res = { entry: idx, exits: [idx] };
|
|
586
|
+
}
|
|
587
|
+
const errFacts = this.harvest.catchErrorFacts(clause);
|
|
588
|
+
if (errFacts) {
|
|
589
|
+
const errBlock = this.builder.newBlock(startLineOf(clause), startLineOf(clause), '', 'normal', errFacts);
|
|
590
|
+
this.builder.edge(errBlock, res.entry, 'seq');
|
|
591
|
+
res = { entry: errBlock, exits: res.exits };
|
|
592
|
+
}
|
|
593
|
+
handlerEntries.push(res.entry);
|
|
594
|
+
handlerExits.push(...res.exits);
|
|
595
|
+
}
|
|
596
|
+
// The protected body's handler is the FIRST catch (if any), else the outer.
|
|
597
|
+
const doHandler = handlerEntries[0] ?? this.currentHandler();
|
|
598
|
+
const protectedStart = this.builder.blockCount;
|
|
599
|
+
this.handlers.push(doHandler);
|
|
600
|
+
const bodyRes = bodyNode ? this.visitSeq(this.statementsOf(bodyNode)) : null;
|
|
601
|
+
this.handlers.pop();
|
|
602
|
+
// Conservative exceptional edges: every protected-region block → EACH catch
|
|
603
|
+
// handler. Swift tries the catch clauses in order until one matches; the
|
|
604
|
+
// thrown type is unknown at CFG time, so any protected block may reach ANY
|
|
605
|
+
// clause. Edging only the first handler orphaned the 2nd..Nth catch blocks
|
|
606
|
+
// (unreachable from ENTRY, stranding their error bindings + def/use facts).
|
|
607
|
+
if (handlerEntries.length > 0) {
|
|
608
|
+
for (let b = protectedStart; b < this.builder.blockCount; b++) {
|
|
609
|
+
for (const handler of handlerEntries)
|
|
610
|
+
this.builder.edge(b, handler, 'throw');
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
const exits = [];
|
|
614
|
+
if (bodyRes)
|
|
615
|
+
exits.push(...bodyRes.exits);
|
|
616
|
+
exits.push(...handlerExits);
|
|
617
|
+
// No catch at all — a `do {}` without `catch` is just a scope: the body
|
|
618
|
+
// flows straight through to its own normal exits (no extra edge needed).
|
|
619
|
+
const entry = bodyRes?.entry ?? handlerEntries[0];
|
|
620
|
+
if (entry === undefined)
|
|
621
|
+
return null;
|
|
622
|
+
return { entry, exits: [...new Set(exits)] };
|
|
623
|
+
}
|
|
624
|
+
/** Nearest enclosing `catch` handler, or the function EXIT. */
|
|
625
|
+
currentHandler() {
|
|
626
|
+
return this.handlers.length ? this.handlers[this.handlers.length - 1] : this.builder.exitIndex;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Emit a `throw` edge to the nearest handler (or EXIT) for every `try`/`try?`/
|
|
630
|
+
* `try!` operator inside a straight-line statement's subtree (excluding nested
|
|
631
|
+
* function bodies). A `try` can propagate an error mid-statement; routing it
|
|
632
|
+
* keeps the error path represented while the success path falls through.
|
|
633
|
+
* Deduped by the builder, so repeated `try` in a statement emit one edge.
|
|
634
|
+
*/
|
|
635
|
+
wireTryExits(stmt, fromBlock) {
|
|
636
|
+
if (this.containsTry(stmt))
|
|
637
|
+
this.builder.edge(fromBlock, this.currentHandler(), 'throw');
|
|
638
|
+
}
|
|
639
|
+
containsTry(node) {
|
|
640
|
+
if (node.type === 'try_expression') {
|
|
641
|
+
// `try?` / `try!` handle the error in-place (optional / trap), so only a
|
|
642
|
+
// bare `try` propagates — but conservatively any `try` may error in a
|
|
643
|
+
// throwing context; route all to the handler (deduped, low cost).
|
|
644
|
+
return true;
|
|
645
|
+
}
|
|
646
|
+
if (SWIFT_FUNCTION_TYPES.has(node.type))
|
|
647
|
+
return false; // opaque nested fn
|
|
648
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
649
|
+
const c = node.namedChild(i);
|
|
650
|
+
if (c && this.containsTry(c))
|
|
651
|
+
return true;
|
|
652
|
+
}
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
// ── defer ──────────────────────────────────────────────────────────────
|
|
656
|
+
/**
|
|
657
|
+
* `defer { … }` is parsed as a `call_expression` whose callee is a bare
|
|
658
|
+
* `defer` identifier carrying a trailing-closure `lambda_literal`. Detect that
|
|
659
|
+
* exact shape so the deferred body threads the function-exit completion chain.
|
|
660
|
+
*/
|
|
661
|
+
isDeferCall(stmt) {
|
|
662
|
+
if (stmt.type !== 'call_expression')
|
|
663
|
+
return false;
|
|
664
|
+
const callee = stmt.namedChild(0);
|
|
665
|
+
if (!callee || callee.type !== 'simple_identifier' || callee.text !== 'defer')
|
|
666
|
+
return false;
|
|
667
|
+
return this.deferClosure(stmt) !== undefined;
|
|
668
|
+
}
|
|
669
|
+
/** The trailing-closure `lambda_literal` body of a `defer { … }` call. */
|
|
670
|
+
deferClosure(stmt) {
|
|
671
|
+
for (let i = 0; i < stmt.namedChildCount; i++) {
|
|
672
|
+
const c = stmt.namedChild(i);
|
|
673
|
+
if (c?.type === 'call_suffix') {
|
|
674
|
+
const lambda = c.namedChildren.find((x) => x.type === 'lambda_literal');
|
|
675
|
+
if (lambda)
|
|
676
|
+
return lambda;
|
|
677
|
+
}
|
|
678
|
+
if (c?.type === 'lambda_literal')
|
|
679
|
+
return c;
|
|
680
|
+
}
|
|
681
|
+
return undefined;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* `defer { … }` — register the deferred body as a finalizer frame that stays
|
|
685
|
+
* active for the rest of the function tail (mirrors the Go visitor). Every later
|
|
686
|
+
* `return` AND the normal fall-off thread through it; LIFO across multiple
|
|
687
|
+
* defers falls out of `finalizersForReturn()` yielding innermost-first. The
|
|
688
|
+
* deferred block carries the closure body's def/use facts. The `defer` itself is
|
|
689
|
+
* a no-op at its source position — control falls straight through.
|
|
690
|
+
*/
|
|
691
|
+
visitDefer(stmt) {
|
|
692
|
+
const lambda = this.deferClosure(stmt);
|
|
693
|
+
const deferBlock = this.builder.newBlock(startLineOf(stmt), endLineOf(stmt), stmt.text, 'normal', lambda ? this.harvest.facts(lambda) : undefined);
|
|
694
|
+
const frame = this.cfc.pushFinalizer(deferBlock);
|
|
695
|
+
this.deferFrames.push(frame);
|
|
696
|
+
// The `defer` statement is a no-op inline — return a SEPARATE marker block as
|
|
697
|
+
// the source position so the deferred block stays out of straight-line flow.
|
|
698
|
+
const marker = this.builder.newBlock(startLineOf(stmt), startLineOf(stmt), '');
|
|
699
|
+
return { entry: marker, exits: [marker] };
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Drain the active `defer` chain at function end (mirrors the Go visitor). The
|
|
703
|
+
* chain runs innermost-first (LIFO). Returns the block set control reaches AFTER
|
|
704
|
+
* the whole defer chain runs (to be wired to EXIT by the caller), or
|
|
705
|
+
* `normalExits` unchanged when there are no defers.
|
|
706
|
+
*/
|
|
707
|
+
finishDefers(normalExits) {
|
|
708
|
+
if (this.deferFrames.length === 0)
|
|
709
|
+
return normalExits;
|
|
710
|
+
const lifo = [...this.deferFrames].reverse();
|
|
711
|
+
for (let i = 0; i < lifo.length; i++)
|
|
712
|
+
this.cfc.pop();
|
|
713
|
+
for (const frame of lifo)
|
|
714
|
+
(0, control_flow_context_js_2.drainFinalizerPending)(this.builder, frame, [frame.entry]);
|
|
715
|
+
if (normalExits.length > 0) {
|
|
716
|
+
this.builder.connect(normalExits, lifo[0].entry, 'return');
|
|
717
|
+
for (let i = 0; i + 1 < lifo.length; i++) {
|
|
718
|
+
this.builder.edge(lifo[i].entry, lifo[i + 1].entry, 'finally-return');
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return [lifo[lifo.length - 1].entry];
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
/** Build the CFG for one Swift function node, or `undefined` if not modelable. */
|
|
725
|
+
function buildFunctionCfg(fnNode, filePath) {
|
|
726
|
+
try {
|
|
727
|
+
if (!SWIFT_FUNCTION_TYPES.has(fnNode.type))
|
|
728
|
+
return undefined;
|
|
729
|
+
const startLine = startLineOf(fnNode);
|
|
730
|
+
const endLine = endLineOf(fnNode);
|
|
731
|
+
const startColumn = fnNode.startPosition.column;
|
|
732
|
+
// A function/init/deinit must own a `function_body`; a lambda owns its
|
|
733
|
+
// `statements` directly. Absence ⇒ a protocol requirement / signature-only
|
|
734
|
+
// declaration with no body to model (return undefined). A PRESENT-but-empty
|
|
735
|
+
// body is a valid empty function (ENTRY → EXIT), distinct from "no body".
|
|
736
|
+
const hasBodyContainer = fnNode.childForFieldName('body') !== null ||
|
|
737
|
+
fnNode.namedChildren.some((c) => c.type === 'function_body') ||
|
|
738
|
+
(fnNode.type === 'lambda_literal' &&
|
|
739
|
+
fnNode.namedChildren.some((c) => c.type === 'statements')) ||
|
|
740
|
+
fnNode.type === 'lambda_literal';
|
|
741
|
+
if (!hasBodyContainer)
|
|
742
|
+
return undefined;
|
|
743
|
+
const body = bodyStatementsOf(fnNode); // may be undefined for an empty body
|
|
744
|
+
const builder = new cfg_builder_js_1.CfgBuilder(filePath, startLine, endLine, startColumn);
|
|
745
|
+
const harvest = new swift_harvest_js_1.SwiftHarvester(fnNode);
|
|
746
|
+
const paramFacts = harvest.paramFacts();
|
|
747
|
+
if (paramFacts)
|
|
748
|
+
builder.attachFacts(builder.entryIndex, paramFacts);
|
|
749
|
+
const walk = new SwiftCfgWalk(builder, harvest);
|
|
750
|
+
const res = body
|
|
751
|
+
? walk.visitSeq(body.namedChildren.filter((c) => c.type !== 'comment' && c.type !== 'multiline_comment'))
|
|
752
|
+
: null;
|
|
753
|
+
builder.edge(builder.entryIndex, res ? res.entry : builder.exitIndex, 'seq');
|
|
754
|
+
// Normal fall-off threads through the active `defer` chain (LIFO) → EXIT.
|
|
755
|
+
const normalExits = res ? res.exits : [builder.entryIndex];
|
|
756
|
+
const afterDefers = walk.finishDefers(normalExits);
|
|
757
|
+
builder.connect(afterDefers, builder.exitIndex, 'seq');
|
|
758
|
+
return builder.finish(harvest.bindingTable());
|
|
759
|
+
}
|
|
760
|
+
catch (err) {
|
|
761
|
+
// Never throw out of buildFunctionCfg — a malformed AST shape must skip only
|
|
762
|
+
// this one function's CFG, never drop the whole file's language group (R4).
|
|
763
|
+
// eslint-disable-next-line no-console
|
|
764
|
+
console.warn(`[cfg] Swift buildFunctionCfg skipped a function in ${filePath}: ${String(err)}`);
|
|
765
|
+
return undefined;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* The function's body `statements` node. A `function_declaration` / `init_` /
|
|
770
|
+
* `deinit_declaration` wraps it in a `function_body`; a `lambda_literal` carries
|
|
771
|
+
* the `statements` directly (after an optional `lambda_function_type` + `in`).
|
|
772
|
+
*/
|
|
773
|
+
function bodyStatementsOf(fnNode) {
|
|
774
|
+
const fb = fnNode.childForFieldName('body') ??
|
|
775
|
+
fnNode.namedChildren.find((c) => c.type === 'function_body');
|
|
776
|
+
if (fb && fb.type === 'function_body') {
|
|
777
|
+
return fb.namedChildren.find((c) => c.type === 'statements');
|
|
778
|
+
}
|
|
779
|
+
if (fnNode.type === 'lambda_literal') {
|
|
780
|
+
return fnNode.namedChildren.find((c) => c.type === 'statements');
|
|
781
|
+
}
|
|
782
|
+
return undefined;
|
|
783
|
+
}
|
|
784
|
+
/** Whether a node is a Swift function/closure this visitor builds a CFG for. */
|
|
785
|
+
function isFunction(node) {
|
|
786
|
+
return SWIFT_FUNCTION_TYPES.has(node.type);
|
|
787
|
+
}
|
|
788
|
+
/** The Swift CFG visitor. */
|
|
789
|
+
function createSwiftCfgVisitor() {
|
|
790
|
+
return { buildFunctionCfg, isFunction };
|
|
791
|
+
}
|