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,956 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* `emitScopeCaptures` for TypeScript.
|
|
4
|
+
*
|
|
5
|
+
* Drives the TypeScript scope query against tree-sitter-typescript and groups
|
|
6
|
+
* raw matches into `CaptureMatch[]` for the central extractor. Layers
|
|
7
|
+
* synthesized streams on top:
|
|
8
|
+
*
|
|
9
|
+
* 1. **Import decomposition** — each `import_statement` / re-export is
|
|
10
|
+
* re-emitted with `@import.kind/source/name/alias/typeOnly` markers so
|
|
11
|
+
* `interpretTsImport` can recover the `ParsedImport` shape without
|
|
12
|
+
* re-parsing raw text (see `import-decomposer.ts`). Unit 2 adds this;
|
|
13
|
+
* until then, raw `@import.statement` matches flow through as-is.
|
|
14
|
+
* 2. **Dynamic imports** — `import('./m')` is re-emitted as a
|
|
15
|
+
* decomposed `@import.statement` with `@import.kind=dynamic` so the
|
|
16
|
+
* central extractor treats it uniformly with static imports.
|
|
17
|
+
* 3. **Function-decl arity metadata** (Unit 5) — `@declaration.parameter-count`
|
|
18
|
+
* / `@declaration.required-parameter-count` / `@declaration.parameter-types`
|
|
19
|
+
* synthesized onto function-like declarations so the registry can narrow
|
|
20
|
+
* overloads.
|
|
21
|
+
* 4. **Callsite arity metadata** (Unit 5) — `@reference.arity` /
|
|
22
|
+
* `@reference.parameter-types` on every callsite.
|
|
23
|
+
* 5. **Receiver-binding synthesis** (Unit 3) — `this` type anchors on
|
|
24
|
+
* instance methods, with arrow-function lexical-this walk-up.
|
|
25
|
+
*
|
|
26
|
+
* Pure given the input source text. No I/O, no globals consulted.
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.TS_CLASS_FIELD_DEFINITION_TYPES = exports.FUNCTION_NODE_TYPES = void 0;
|
|
30
|
+
exports.isStaticClassFieldBinding = isStaticClassFieldBinding;
|
|
31
|
+
exports.emitTsScopeCaptures = emitTsScopeCaptures;
|
|
32
|
+
const ast_helpers_js_1 = require("../../utils/ast-helpers.js");
|
|
33
|
+
const import_decomposer_js_1 = require("./import-decomposer.js");
|
|
34
|
+
const query_js_1 = require("./query.js");
|
|
35
|
+
const cache_stats_js_1 = require("./cache-stats.js");
|
|
36
|
+
const receiver_binding_js_1 = require("./receiver-binding.js");
|
|
37
|
+
const arity_metadata_js_1 = require("./arity-metadata.js");
|
|
38
|
+
const array_callback_js_1 = require("./array-callback.js");
|
|
39
|
+
const cjs_export_assignment_js_1 = require("./cjs-export-assignment.js");
|
|
40
|
+
const helpers_js_1 = require("../../field-extractors/configs/helpers.js");
|
|
41
|
+
const constants_js_1 = require("../../constants.js");
|
|
42
|
+
const safe_parse_js_1 = require("../../../tree-sitter/safe-parse.js");
|
|
43
|
+
const callable_flow_captures_js_1 = require("../../utils/callable-flow-captures.js");
|
|
44
|
+
const cjs_module_exports_js_1 = require("./cjs-module-exports.js");
|
|
45
|
+
const receiver_chain_captures_js_1 = require("../../utils/receiver-chain-captures.js");
|
|
46
|
+
const ts_js_hoc_utils_js_1 = require("../../ts-js-hoc-utils.js");
|
|
47
|
+
/** tree-sitter-typescript node types for function-like scopes that may
|
|
48
|
+
* carry a synthesized `this` binding. Kept in sync with the
|
|
49
|
+
* `@scope.function` patterns in `query.ts`. */
|
|
50
|
+
exports.FUNCTION_NODE_TYPES = [
|
|
51
|
+
'method_definition',
|
|
52
|
+
'method_signature',
|
|
53
|
+
'abstract_method_signature',
|
|
54
|
+
'arrow_function',
|
|
55
|
+
'function_expression',
|
|
56
|
+
'function_declaration',
|
|
57
|
+
'generator_function_declaration',
|
|
58
|
+
// The EXPRESSION form (`const g = function* () {}`). Both queries capture it
|
|
59
|
+
// as `@scope.function`, and both `this`-boundary lists already carry it, but
|
|
60
|
+
// this list did not — so callable-flow synthesis and the body-block filter
|
|
61
|
+
// treated a generator expression as a non-function.
|
|
62
|
+
//
|
|
63
|
+
// Measured: adding it changes no graph output today. A generator-expression
|
|
64
|
+
// binding still emits a `Const` node rather than a `Function` one, so the
|
|
65
|
+
// call never resolves either way — that label comes from the definition
|
|
66
|
+
// rules, not from here, and closing it is a separate change. This entry is
|
|
67
|
+
// list consistency, enforced by
|
|
68
|
+
// `test/unit/ts-js-function-node-type-lists.test.ts`.
|
|
69
|
+
'generator_function',
|
|
70
|
+
'function_signature',
|
|
71
|
+
];
|
|
72
|
+
/** Nodes whose `statement_block` child is their BODY, not a nested block.
|
|
73
|
+
* Such a block duplicates the enclosing Function scope — see the emit-side
|
|
74
|
+
* filter in `emitTsScopeCaptures`. */
|
|
75
|
+
const FUNCTION_BODY_OWNER_TYPES = new Set(exports.FUNCTION_NODE_TYPES);
|
|
76
|
+
/** Direct-child node types that create a BINDING in their enclosing block.
|
|
77
|
+
* `variable_declaration` (`var`) is deliberately absent: it hoists past the
|
|
78
|
+
* block to the function, so a block containing only `var` binds nothing. */
|
|
79
|
+
const BLOCK_BINDING_CHILD_TYPES = new Set([
|
|
80
|
+
'lexical_declaration',
|
|
81
|
+
'class_declaration',
|
|
82
|
+
'function_declaration',
|
|
83
|
+
'generator_function_declaration',
|
|
84
|
+
]);
|
|
85
|
+
/** True when `block` directly declares a name, i.e. it is a real environment
|
|
86
|
+
* record rather than punctuation. A block that binds nothing is transparent to
|
|
87
|
+
* every scope-chain walk — a lookup finds nothing in it and continues to the
|
|
88
|
+
* parent — so emitting a scope for it costs tree size and walk depth and buys
|
|
89
|
+
* exactly nothing. Only DIRECT children count: a declaration in a nested block
|
|
90
|
+
* belongs to that block, which gets its own scope by the same rule. */
|
|
91
|
+
const blockDeclaresBinding = (block) => {
|
|
92
|
+
for (let i = 0; i < block.namedChildCount; i++) {
|
|
93
|
+
const child = block.namedChild(i);
|
|
94
|
+
if (child !== null && BLOCK_BINDING_CHILD_TYPES.has(child.type))
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
};
|
|
99
|
+
/** Declaration anchors that carry function-like arity metadata. */
|
|
100
|
+
const FUNCTION_DECL_TAGS = ['@declaration.method', '@declaration.function'];
|
|
101
|
+
/** Callsite anchors that should carry `@reference.arity` + param types. */
|
|
102
|
+
const CALL_TAGS = [
|
|
103
|
+
'@reference.call.free',
|
|
104
|
+
'@reference.call.member',
|
|
105
|
+
'@reference.call.constructor',
|
|
106
|
+
];
|
|
107
|
+
const TS_CALLABLE_CAPTURE_OPTIONS = {
|
|
108
|
+
functionNodeTypes: new Set(exports.FUNCTION_NODE_TYPES),
|
|
109
|
+
callNodeTypes: new Set(['call_expression']),
|
|
110
|
+
parameterListNodeTypes: new Set(['formal_parameters', 'arguments']),
|
|
111
|
+
parameterNodeTypes: new Set([
|
|
112
|
+
'required_parameter',
|
|
113
|
+
'optional_parameter',
|
|
114
|
+
'rest_pattern',
|
|
115
|
+
'identifier',
|
|
116
|
+
]),
|
|
117
|
+
bindingNodeTypes: new Set(['variable_declarator']),
|
|
118
|
+
assignmentNodeTypes: new Set(['assignment_expression', 'augmented_assignment_expression']),
|
|
119
|
+
identifierNodeTypes: new Set([
|
|
120
|
+
'identifier',
|
|
121
|
+
'property_identifier',
|
|
122
|
+
'shorthand_property_identifier_pattern',
|
|
123
|
+
'private_property_identifier',
|
|
124
|
+
]),
|
|
125
|
+
};
|
|
126
|
+
function pickFirstCapture(grouped, tags) {
|
|
127
|
+
for (const tag of tags) {
|
|
128
|
+
const cap = grouped[tag];
|
|
129
|
+
if (cap !== undefined)
|
|
130
|
+
return cap;
|
|
131
|
+
}
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
function pickFirstNode(grouped, tags) {
|
|
135
|
+
for (const tag of tags) {
|
|
136
|
+
const node = grouped[tag];
|
|
137
|
+
if (node !== undefined)
|
|
138
|
+
return node;
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Drop `@reference.read.member` matches whose underlying `member_expression`
|
|
144
|
+
* is NOT actually a read context:
|
|
145
|
+
*
|
|
146
|
+
* 1. The member_expression is the `function:` of a `call_expression`
|
|
147
|
+
* (it's a call, already captured as `@reference.call.member`).
|
|
148
|
+
* 2. The member_expression is the `constructor:` of a `new_expression`
|
|
149
|
+
* (already captured as `@reference.call.constructor.qualified`).
|
|
150
|
+
* 3. The member_expression is the `left:` of an `assignment_expression` /
|
|
151
|
+
* `augmented_assignment_expression` (it's a write, already captured
|
|
152
|
+
* as `@reference.write.member`).
|
|
153
|
+
* 4. The member_expression is the `function:` of an `await_expression`
|
|
154
|
+
* being called (handled by the member-call capture).
|
|
155
|
+
* 5. The member_expression is the `name:` of a `jsx_self_closing_element`
|
|
156
|
+
* or `jsx_opening_element` (it's a JSX component invocation, already
|
|
157
|
+
* captured as `@reference.call.member` by the TSX-only query suffix).
|
|
158
|
+
* Without this filter, `<Foo.Bar />` would emit a phantom ACCESSES
|
|
159
|
+
* edge to `Foo.Bar` IN ADDITION to the CALLS edge.
|
|
160
|
+
*
|
|
161
|
+
* Returns `true` when the capture should be kept as a read reference,
|
|
162
|
+
* `false` when it should be dropped.
|
|
163
|
+
*/
|
|
164
|
+
function shouldEmitReadMember(memberNode) {
|
|
165
|
+
const parent = memberNode.parent;
|
|
166
|
+
if (parent === null)
|
|
167
|
+
return true;
|
|
168
|
+
switch (parent.type) {
|
|
169
|
+
case 'call_expression':
|
|
170
|
+
return parent.childForFieldName('function')?.id !== memberNode.id;
|
|
171
|
+
case 'new_expression':
|
|
172
|
+
return parent.childForFieldName('constructor')?.id !== memberNode.id;
|
|
173
|
+
case 'assignment_expression':
|
|
174
|
+
case 'augmented_assignment_expression':
|
|
175
|
+
return parent.childForFieldName('left')?.id !== memberNode.id;
|
|
176
|
+
case 'jsx_self_closing_element':
|
|
177
|
+
case 'jsx_opening_element':
|
|
178
|
+
return parent.childForFieldName('name')?.id !== memberNode.id;
|
|
179
|
+
default:
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Is this `(this)` node the `this` of a STATIC method?
|
|
185
|
+
*
|
|
186
|
+
* `this` in a static method is the class object, so `this.x = new Y()` there
|
|
187
|
+
* assigns a STATIC property and must never type the instance field of the same
|
|
188
|
+
* name (#2807). Every other context that rebinds `this` is excluded
|
|
189
|
+
* structurally, by the query's `class_body → method_definition →
|
|
190
|
+
* statement_block → expression_statement` nesting; `static` is the one
|
|
191
|
+
* constraint tree-sitter cannot carry, because it is an ANONYMOUS token with no
|
|
192
|
+
* field name and patterns cannot negate one.
|
|
193
|
+
*
|
|
194
|
+
* The caller only reaches here for a capture the query already pinned inside a
|
|
195
|
+
* class method, so the `method_definition` lookup is a short walk. Detection is
|
|
196
|
+
* the shared `hasKeyword`, which is what the TypeScript METHOD EXTRACTOR already
|
|
197
|
+
* uses to decide the same question — matching on child TEXT, and skipping the
|
|
198
|
+
* `name` field so a method literally called `static()` is not misread.
|
|
199
|
+
*
|
|
200
|
+
* Text, not node type: `static` reaches the tree as an anonymous token in some
|
|
201
|
+
* grammar versions and as a keyword node in others (see `isStaticMember` in
|
|
202
|
+
* `receiver-binding.ts`), so a `child.type === 'static'` test silently stops
|
|
203
|
+
* firing on a grammar bump and every static `this.x = new Y()` starts typing the
|
|
204
|
+
* instance field of that name. `hasKeyword` scans the whole `method_definition`
|
|
205
|
+
* rather than stopping at the name, which is safe here because a
|
|
206
|
+
* `method_definition`'s own children are its modifiers, name, parameters and
|
|
207
|
+
* body — a mention of `static` inside the BODY is a descendant of the body node,
|
|
208
|
+
* never a direct child.
|
|
209
|
+
*/
|
|
210
|
+
function isStaticMethodThis(thisNode) {
|
|
211
|
+
const method = findSelfOrAncestorOfType(thisNode, 'method_definition');
|
|
212
|
+
if (method === null)
|
|
213
|
+
return false;
|
|
214
|
+
return (0, helpers_js_1.hasKeyword)(method, 'static');
|
|
215
|
+
}
|
|
216
|
+
/** The class-field declaration node a field `@type-binding.*` match anchors on
|
|
217
|
+
* in TypeScript/TSX. JavaScript spells the same construct `field_definition`
|
|
218
|
+
* and passes its own set in — the predicate below is shared because both
|
|
219
|
+
* grammars carry `static` identically, but each language must NAME its own
|
|
220
|
+
* node type. Listing both here made `field_definition` a dead literal in the
|
|
221
|
+
* typescript grammar, which `grammar-literal-validation` fails on: the gate
|
|
222
|
+
* checks every literal against the grammar of the FILE it appears in, and a
|
|
223
|
+
* node type that is dead there is exactly how a guard silently stops firing. */
|
|
224
|
+
exports.TS_CLASS_FIELD_DEFINITION_TYPES = new Set([
|
|
225
|
+
'public_field_definition',
|
|
226
|
+
]);
|
|
227
|
+
/**
|
|
228
|
+
* Is this type-binding anchored on a **`static`** class field?
|
|
229
|
+
*
|
|
230
|
+
* A static member belongs to the CLASS OBJECT; an instance field belongs to
|
|
231
|
+
* instances. JavaScript and TypeScript keep the two in separate namespaces, so
|
|
232
|
+
* one class may legally declare both under one name:
|
|
233
|
+
*
|
|
234
|
+
* class Host {
|
|
235
|
+
* p = new Right();
|
|
236
|
+
* static p = new Wrong(); // legal — a different member
|
|
237
|
+
* hit() { return this.p.hit(); } // `this.p` is Right
|
|
238
|
+
* }
|
|
239
|
+
*
|
|
240
|
+
* Both field patterns anchor their binding on the same CLASS scope with the
|
|
241
|
+
* same `constructor-inferred` source, and `scope-extractor` breaks a
|
|
242
|
+
* same-strength tie with `>=` — last match wins. So the static field silently
|
|
243
|
+
* RETYPED the instance field of that name and `this.p.hit()` resolved to
|
|
244
|
+
* `Wrong.hit`: not a missing edge but a wrong one, the failure mode
|
|
245
|
+
* `scope-resolution/passes/compound-receiver.ts` exists to avoid. The scope
|
|
246
|
+
* tree has one `typeBindings` map per scope with no static/instance split, so a
|
|
247
|
+
* static field cannot be recorded separately — it is dropped instead.
|
|
248
|
+
*
|
|
249
|
+
* WHAT THAT COSTS, MEASURED rather than assumed (#2807 review, S7). An earlier
|
|
250
|
+
* version of this comment called the cost "a missed edge beats a wrong one".
|
|
251
|
+
* Only half of that is true, and the false half is the one that matters:
|
|
252
|
+
*
|
|
253
|
+
* shape with the drop without it
|
|
254
|
+
* -------------------------- ---------------- ----------------
|
|
255
|
+
* `this.p` (instance twin) Right ✓ Wrong ✗
|
|
256
|
+
* `Host.p` (static twin) Right ✗ WRONG Wrong ✓
|
|
257
|
+
* `Host.q` (static, no twin) — none, missed Wrong ✓
|
|
258
|
+
*
|
|
259
|
+
* For a class declaring BOTH twins the wrong edge does not disappear, it MOVES:
|
|
260
|
+
* `Host.p` now reads the INSTANCE twin's binding, because that is what is left
|
|
261
|
+
* in the map under that name. Only the no-twin case — the common static shape —
|
|
262
|
+
* is a true missed edge.
|
|
263
|
+
*
|
|
264
|
+
* The trade is still the right one, since `this.p` is overwhelmingly the more
|
|
265
|
+
* common access and a `Host.p` static chain is the cheaper place to be wrong.
|
|
266
|
+
* It is recorded here as a wrong edge rather than described as a missing one so
|
|
267
|
+
* that the next person weighing it is weighing the real thing. Closing it
|
|
268
|
+
* properly needs a static/instance split that the shared receiver fold cannot
|
|
269
|
+
* express today — `foldReceiverChain` in
|
|
270
|
+
* `scope-resolution/passes/compound-receiver.ts` explicitly discards whether a
|
|
271
|
+
* chain's base was a class reference or a value — so it is a separate change
|
|
272
|
+
* with a `SCHEMA_BUMP`, not a tweak here. Both shapes are pinned by rows in
|
|
273
|
+
* `test/integration/resolvers/inferred-field-receiver-matrix.test.ts`
|
|
274
|
+
* (`static-read-of-a-same-name-twin-picks-up-the-instance-type`,
|
|
275
|
+
* `static-read-without-a-twin-loses-its-type`), so the cost moves visibly.
|
|
276
|
+
*
|
|
277
|
+
* Sibling of {@link isStaticMethodThis}, which drops the ASSIGNMENT form
|
|
278
|
+
* (`this.x = new Y()` inside a static method). Together they cover both ways a
|
|
279
|
+
* static member can reach the field-typing path. This is an emit-side filter
|
|
280
|
+
* for the same reason that one is: `static` is an ANONYMOUS token on the
|
|
281
|
+
* declaration node, and a tree-sitter pattern cannot negate one.
|
|
282
|
+
*
|
|
283
|
+
* Detection is the shared `hasKeyword` — matching on child TEXT, never
|
|
284
|
+
* `child.type === 'static'`, because the token reaches the tree as an anonymous
|
|
285
|
+
* token in some grammar versions and a keyword node in others (see
|
|
286
|
+
* `isStaticMember` in `receiver-binding.ts`); a node-type test silently stops
|
|
287
|
+
* firing on a grammar bump and every static field starts retyping its instance
|
|
288
|
+
* twin again. Verified against both grammars in use here: `static` is an
|
|
289
|
+
* anonymous direct child of the caller's field-definition node —
|
|
290
|
+
* `public_field_definition` in TypeScript, `field_definition` in JavaScript —
|
|
291
|
+
* ahead of the name. Each language passes its OWN node-type set rather than the
|
|
292
|
+
* predicate holding both: a literal is only valid in the grammar of the file it
|
|
293
|
+
* appears in, and `grammar-literal-validation` fails a dead one.
|
|
294
|
+
*
|
|
295
|
+
* One deliberate over-fire: `hasKeyword` skips the node's `name` FIELD, and the
|
|
296
|
+
* JavaScript grammar names a field's name `property:`, not `name:` — so the
|
|
297
|
+
* legal-but-rare JavaScript field literally called `static`
|
|
298
|
+
* (`class C { static = new Right(); }`) reads as static and goes untyped. That
|
|
299
|
+
* is a declined binding, the safe direction of the same trade.
|
|
300
|
+
*/
|
|
301
|
+
function isStaticClassFieldBinding(anchorNode, fieldDefinitionTypes) {
|
|
302
|
+
if (anchorNode === undefined)
|
|
303
|
+
return false;
|
|
304
|
+
if (!fieldDefinitionTypes.has(anchorNode.type))
|
|
305
|
+
return false;
|
|
306
|
+
return (0, helpers_js_1.hasKeyword)(anchorNode, 'static');
|
|
307
|
+
}
|
|
308
|
+
/** Walks the parent chain from `node` (inclusive), returning the first node
|
|
309
|
+
* whose type matches, or null. Faster than `findNodeAtRange` when the caller
|
|
310
|
+
* already holds the anchor node — avoids re-scanning the tree from the root. */
|
|
311
|
+
function findSelfOrAncestorOfType(node, type) {
|
|
312
|
+
if (node === undefined)
|
|
313
|
+
return null;
|
|
314
|
+
let current = node;
|
|
315
|
+
while (current !== null) {
|
|
316
|
+
if (current.type === type)
|
|
317
|
+
return current;
|
|
318
|
+
current = current.parent;
|
|
319
|
+
}
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
/** Walks the parent chain from `node` (inclusive), returning the first node
|
|
323
|
+
* whose type is in the set, or null. Plural form of {@link findSelfOrAncestorOfType}. */
|
|
324
|
+
function findSelfOrAncestorOfTypes(node, types) {
|
|
325
|
+
if (node === undefined)
|
|
326
|
+
return null;
|
|
327
|
+
let current = node;
|
|
328
|
+
while (current !== null) {
|
|
329
|
+
if (types.includes(current.type))
|
|
330
|
+
return current;
|
|
331
|
+
current = current.parent;
|
|
332
|
+
}
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
function emitTsScopeCaptures(sourceText, filePath, cachedTree) {
|
|
336
|
+
// Reuse a pre-parsed Tree when the caller passes one via `cachedTree`; a
|
|
337
|
+
// miss re-parses. (The cache is currently always empty — its only producer,
|
|
338
|
+
// the sequential parser, was removed — so this re-parses in practice.) The
|
|
339
|
+
// cachedTree parameter is typed `unknown` at the LanguageProvider contract
|
|
340
|
+
// layer; cast here at the use site.
|
|
341
|
+
//
|
|
342
|
+
// Grammar selection: `.tsx` files are parsed with the TSX grammar,
|
|
343
|
+
// `.ts` files with the TypeScript grammar. The two grammars have
|
|
344
|
+
// separate node-type id spaces, so a Query compiled against one
|
|
345
|
+
// cannot match a Tree produced by the other. We validate the cached
|
|
346
|
+
// tree's grammar against the file extension and fall back to a
|
|
347
|
+
// fresh parse if they disagree (e.g. a worker-mode parse landed
|
|
348
|
+
// with the wrong grammar pinned).
|
|
349
|
+
let tree = cachedTree;
|
|
350
|
+
if (tree !== undefined && !(0, query_js_1.tsCachedTreeMatchesGrammar)(tree, filePath)) {
|
|
351
|
+
tree = undefined;
|
|
352
|
+
}
|
|
353
|
+
if (tree === undefined) {
|
|
354
|
+
tree = (0, safe_parse_js_1.parseSourceSafe)((0, query_js_1.getTsParser)(filePath), sourceText, undefined, {
|
|
355
|
+
bufferSize: (0, constants_js_1.getTreeSitterBufferSize)(sourceText),
|
|
356
|
+
});
|
|
357
|
+
(0, cache_stats_js_1.recordCacheMiss)();
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
(0, cache_stats_js_1.recordCacheHit)();
|
|
361
|
+
}
|
|
362
|
+
const rawMatches = (0, query_js_1.getTsScopeQuery)(filePath).matches(tree.rootNode);
|
|
363
|
+
const out = [];
|
|
364
|
+
for (const m of rawMatches) {
|
|
365
|
+
// Group captures by their tag name. Tree-sitter strips the leading
|
|
366
|
+
// `@`; we put it back so the central extractor's prefix lookups
|
|
367
|
+
// (`@scope.`, `@declaration.`, …) work.
|
|
368
|
+
const grouped = {};
|
|
369
|
+
const groupedNodes = {};
|
|
370
|
+
for (const c of m.captures) {
|
|
371
|
+
const tag = '@' + c.name;
|
|
372
|
+
grouped[tag] = (0, ast_helpers_js_1.nodeToCapture)(tag, c.node);
|
|
373
|
+
groupedNodes[tag] = c.node;
|
|
374
|
+
}
|
|
375
|
+
if (Object.keys(grouped).length === 0)
|
|
376
|
+
continue;
|
|
377
|
+
// Decompose each `import_statement` / re-export `export_statement`
|
|
378
|
+
// so `interpretTsImport` sees the kind/source/name/alias markers
|
|
379
|
+
// it consumes. The raw query anchor carries only @import.statement.
|
|
380
|
+
// Side-effect imports emit a non-binding marker so finalize can keep
|
|
381
|
+
// the file-level dependency.
|
|
382
|
+
if (grouped['@import.statement'] !== undefined) {
|
|
383
|
+
const stmtCapture = grouped['@import.statement'];
|
|
384
|
+
const stmtNode = findSelfOrAncestorOfTypes(groupedNodes['@import.statement'], [
|
|
385
|
+
'import_statement',
|
|
386
|
+
'export_statement',
|
|
387
|
+
]) ??
|
|
388
|
+
(0, ast_helpers_js_1.findNodeAtRange)(tree.rootNode, stmtCapture.range, 'import_statement') ??
|
|
389
|
+
(0, ast_helpers_js_1.findNodeAtRange)(tree.rootNode, stmtCapture.range, 'export_statement');
|
|
390
|
+
if (stmtNode !== null) {
|
|
391
|
+
const decomposed = (0, import_decomposer_js_1.splitImportStatement)(stmtNode);
|
|
392
|
+
for (const d of decomposed)
|
|
393
|
+
out.push(d);
|
|
394
|
+
}
|
|
395
|
+
// If decomposition yielded nothing (malformed/bare anchor), drop
|
|
396
|
+
// the match. Emitting a bare
|
|
397
|
+
// @import.statement without kind/source would confuse the
|
|
398
|
+
// central extractor.
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
// Dynamic imports — decompose via the same path. `@import.dynamic`
|
|
402
|
+
// is anchored on a `call_expression`, which the decomposer's
|
|
403
|
+
// `splitDynamicImport` branch consumes.
|
|
404
|
+
if (grouped['@import.dynamic'] !== undefined) {
|
|
405
|
+
const dynCapture = grouped['@import.dynamic'];
|
|
406
|
+
const callNode = findSelfOrAncestorOfType(groupedNodes['@import.dynamic'], 'call_expression') ??
|
|
407
|
+
(0, ast_helpers_js_1.findNodeAtRange)(tree.rootNode, dynCapture.range, 'call_expression');
|
|
408
|
+
if (callNode !== null) {
|
|
409
|
+
const decomposed = (0, import_decomposer_js_1.splitImportStatement)(callNode);
|
|
410
|
+
for (const d of decomposed)
|
|
411
|
+
out.push(d);
|
|
412
|
+
}
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
// A `statement_block` that IS a function body adds nothing: the enclosing
|
|
416
|
+
// Function scope already provides that environment record, so emitting one
|
|
417
|
+
// here just puts a redundant level inside EVERY function for every
|
|
418
|
+
// scope-chain walk to step through. Measured on a 762-file TypeScript
|
|
419
|
+
// corpus, keeping them cost ~6% of total analyze wall time; dropping them
|
|
420
|
+
// keeps the block scopes that matter (if/else/for/while/try/bare blocks,
|
|
421
|
+
// where `let`/`const` genuinely shadow) at no measurable cost.
|
|
422
|
+
//
|
|
423
|
+
// Semantically safe: nothing can be declared between a function and its
|
|
424
|
+
// own body, so a binding in either resolves identically.
|
|
425
|
+
if (grouped['@scope.block'] !== undefined) {
|
|
426
|
+
const blockNode = groupedNodes['@scope.block'];
|
|
427
|
+
const parentType = blockNode?.parent?.type;
|
|
428
|
+
if (parentType !== undefined && FUNCTION_BODY_OWNER_TYPES.has(parentType))
|
|
429
|
+
continue;
|
|
430
|
+
if (blockNode === undefined || !blockDeclaresBinding(blockNode))
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
// Filter out `@reference.read.member` matches whose AST parent tells
|
|
434
|
+
// us they are actually calls / writes / constructor invocations. The
|
|
435
|
+
// tree-sitter pattern is context-free and matches every member_expression;
|
|
436
|
+
// we rely on this emit-side filter so the query stays simple.
|
|
437
|
+
if (grouped['@reference.read.member'] !== undefined) {
|
|
438
|
+
const anchor = grouped['@reference.read.member'];
|
|
439
|
+
const memberNode = findSelfOrAncestorOfType(groupedNodes['@reference.read.member'], 'member_expression') ??
|
|
440
|
+
(0, ast_helpers_js_1.findNodeAtRange)(tree.rootNode, anchor.range, 'member_expression');
|
|
441
|
+
if (memberNode === null || !shouldEmitReadMember(memberNode)) {
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
// `this.<field> = new …` inside a STATIC method types a static property,
|
|
446
|
+
// not the instance field of the same name (#2807). Every other `this`-
|
|
447
|
+
// rebinding context is already excluded by the pattern's nesting — see the
|
|
448
|
+
// note on it in `query.ts`; `static` is an anonymous token, so no pattern
|
|
449
|
+
// can negate it and the last case is dropped here.
|
|
450
|
+
const thisFieldNode = groupedNodes['@type-binding.this-field'];
|
|
451
|
+
if (thisFieldNode !== undefined && isStaticMethodThis(thisFieldNode)) {
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
// …and a `static` FIELD is a member of the class object, not of instances,
|
|
455
|
+
// so it must not type the instance field of the same name either — see
|
|
456
|
+
// `isStaticClassFieldBinding`. Both class-field anchors are tested: the
|
|
457
|
+
// initializer form (`static p = new Wrong()`, `@type-binding.constructor`)
|
|
458
|
+
// and the annotated form (`static p: Wrong`, `@type-binding.annotation`),
|
|
459
|
+
// which collide on the Class scope the same way. The predicate self-gates on
|
|
460
|
+
// the anchor's node type, so the local `variable_declarator` patterns that
|
|
461
|
+
// share these tags are untouched.
|
|
462
|
+
if (isStaticClassFieldBinding(groupedNodes['@type-binding.constructor'], exports.TS_CLASS_FIELD_DEFINITION_TYPES) ||
|
|
463
|
+
isStaticClassFieldBinding(groupedNodes['@type-binding.annotation'], exports.TS_CLASS_FIELD_DEFINITION_TYPES)) {
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
// #1876: drop @declaration.function for array higher-order-method
|
|
467
|
+
// callbacks (`const x = arr.map(a => …)`). The HOC-wrapped-arrow
|
|
468
|
+
// pattern matches them, but the binding holds a value, not a callable.
|
|
469
|
+
// The binding keeps its separate @declaration.const / .variable match,
|
|
470
|
+
// and the arrow's own @scope.function match (a different pattern) is
|
|
471
|
+
// untouched, so inner-call attribution falls through to the enclosing
|
|
472
|
+
// scope instead of a phantom Function.
|
|
473
|
+
const fnDeclAnchor = grouped['@declaration.function'];
|
|
474
|
+
if (fnDeclAnchor !== undefined) {
|
|
475
|
+
const arrowNode = findFunctionNode(tree.rootNode, fnDeclAnchor.range, groupedNodes['@declaration.function']);
|
|
476
|
+
if (arrowNode !== null && (0, array_callback_js_1.isArrayMethodCallbackArrow)(arrowNode)) {
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
if (arrowNode !== null && (0, ts_js_hoc_utils_js_1.isBlockedDefaultExportHoc)(arrowNode)) {
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
// #2723: a CJS export assignment must not register a SECOND module-scope
|
|
483
|
+
// declaration for a name the file already declares lexically — the name
|
|
484
|
+
// would become ambiguous and the resolver would drop the intra-module
|
|
485
|
+
// edge that resolved before #2723.
|
|
486
|
+
if (arrowNode !== null && (0, cjs_export_assignment_js_1.isShadowedCjsExportAssignment)(arrowNode, tree.rootNode)) {
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
// #2723 follow-up: the member-assignment rule matches ANY identifier
|
|
490
|
+
// receiver so an `exports` alias can be recognised. A receiver that is
|
|
491
|
+
// not the exports object declares nothing at module scope — drop it, or
|
|
492
|
+
// every `obj.handler = fn` would bind `handler` as a module symbol.
|
|
493
|
+
if (arrowNode !== null && (0, cjs_export_assignment_js_1.isUnexportedMemberAssignmentValue)(arrowNode, tree.rootNode)) {
|
|
494
|
+
continue;
|
|
495
|
+
}
|
|
496
|
+
// A `this.X = fn` declares a module symbol ONLY at the top level of a
|
|
497
|
+
// CommonJS file, where `this` is `module.exports`. Inside a function it
|
|
498
|
+
// is an instance member (a Method with an owner, no module binding), and
|
|
499
|
+
// in ESM top-level `this` is undefined and exports nothing.
|
|
500
|
+
if (arrowNode !== null && (0, cjs_export_assignment_js_1.isUndeclarableThisMemberValue)(arrowNode, tree.rootNode)) {
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (fnDeclAnchor !== undefined) {
|
|
505
|
+
const fnNode = findFunctionNode(tree.rootNode, fnDeclAnchor.range, groupedNodes['@declaration.function']);
|
|
506
|
+
if (fnNode !== null && (0, ts_js_hoc_utils_js_1.isDefaultExportHocFunctionNode)(fnNode)) {
|
|
507
|
+
grouped['@declaration.name'] = (0, ast_helpers_js_1.syntheticCapture)('@declaration.name', fnNode, (0, ts_js_hoc_utils_js_1.deriveDefaultExportHocName)(filePath));
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
// Synthesize arity metadata on function-like declaration anchors
|
|
511
|
+
// before pushing the match. The registry uses these to narrow
|
|
512
|
+
// overloads — TypeScript supports overload signatures via
|
|
513
|
+
// function_signature, so `parameterTypes` is populated when
|
|
514
|
+
// available.
|
|
515
|
+
const declAnchor = pickFirstCapture(grouped, FUNCTION_DECL_TAGS);
|
|
516
|
+
const declAnchorNode = pickFirstNode(groupedNodes, FUNCTION_DECL_TAGS);
|
|
517
|
+
if (declAnchor !== undefined) {
|
|
518
|
+
const fnNode = findFunctionNode(tree.rootNode, declAnchor.range, declAnchorNode);
|
|
519
|
+
if (fnNode !== null) {
|
|
520
|
+
const arity = (0, arity_metadata_js_1.computeTsArityMetadata)(fnNode);
|
|
521
|
+
if (arity.parameterCount !== undefined) {
|
|
522
|
+
grouped['@declaration.parameter-count'] = (0, ast_helpers_js_1.syntheticCapture)('@declaration.parameter-count', fnNode, String(arity.parameterCount));
|
|
523
|
+
}
|
|
524
|
+
if (arity.requiredParameterCount !== undefined) {
|
|
525
|
+
grouped['@declaration.required-parameter-count'] = (0, ast_helpers_js_1.syntheticCapture)('@declaration.required-parameter-count', fnNode, String(arity.requiredParameterCount));
|
|
526
|
+
}
|
|
527
|
+
if (arity.parameterTypes !== undefined) {
|
|
528
|
+
grouped['@declaration.parameter-types'] = (0, ast_helpers_js_1.syntheticCapture)('@declaration.parameter-types', fnNode, JSON.stringify(arity.parameterTypes));
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
// Synthesize `@reference.arity` on every callsite so the registry's
|
|
533
|
+
// arity filter can narrow overloads. Count the `argument` named
|
|
534
|
+
// children of the backing `arguments` node. TypeScript constructor
|
|
535
|
+
// calls use `new_expression`; regular calls use `call_expression`.
|
|
536
|
+
//
|
|
537
|
+
// JSX call anchors (`jsx_self_closing_element` / `jsx_opening_element`
|
|
538
|
+
// captured by the TSX-only suffix in `query.ts`) intentionally do NOT carry
|
|
539
|
+
// arity metadata. A JSX component used as a call argument (e.g.
|
|
540
|
+
// `render(<Foo .../>)`) is itself a @reference.call.* anchor; without a guard
|
|
541
|
+
// the ascent below would climb from it into the enclosing call_expression and
|
|
542
|
+
// mis-attribute that call's arity to the component. The early guard skips
|
|
543
|
+
// arity synthesis for JSX anchors — restoring the pre-#1951 range-based
|
|
544
|
+
// behavior (the old findNodeAtRange found no call_expression at the JSX
|
|
545
|
+
// element's range). The guard lives here, not inside findSelfOrAncestorOfTypes
|
|
546
|
+
// (shared with the import-statement and function-scope ascents). This is
|
|
547
|
+
// acceptable for React: components are virtually never overloaded in the
|
|
548
|
+
// current GitNexus graph model, so name-only dispatch matches the single
|
|
549
|
+
// component definition. A future props-arity-aware synthesizer would count
|
|
550
|
+
// `jsx_attribute` children of the opening tag instead of `arguments`.
|
|
551
|
+
const callAnchor = pickFirstCapture(grouped, CALL_TAGS);
|
|
552
|
+
const callAnchorNode = pickFirstNode(groupedNodes, CALL_TAGS);
|
|
553
|
+
const anchorIsJsxElement = callAnchorNode?.type === 'jsx_self_closing_element' ||
|
|
554
|
+
callAnchorNode?.type === 'jsx_opening_element';
|
|
555
|
+
if (callAnchor !== undefined &&
|
|
556
|
+
grouped['@reference.arity'] === undefined &&
|
|
557
|
+
!anchorIsJsxElement) {
|
|
558
|
+
const callNode = findSelfOrAncestorOfTypes(callAnchorNode, ['call_expression', 'new_expression']) ??
|
|
559
|
+
(0, ast_helpers_js_1.findNodeAtRange)(tree.rootNode, callAnchor.range, 'call_expression') ??
|
|
560
|
+
(0, ast_helpers_js_1.findNodeAtRange)(tree.rootNode, callAnchor.range, 'new_expression');
|
|
561
|
+
if (callNode !== null) {
|
|
562
|
+
const argList = callNode.childForFieldName('arguments');
|
|
563
|
+
const args = argList === null
|
|
564
|
+
? []
|
|
565
|
+
: argList.namedChildren.filter((c) => c !== null && c.type !== 'comment');
|
|
566
|
+
grouped['@reference.arity'] = (0, ast_helpers_js_1.syntheticCapture)('@reference.arity', callNode, String(args.length));
|
|
567
|
+
const argTypes = args.map((arg) => inferArgType(arg));
|
|
568
|
+
grouped['@reference.parameter-types'] = (0, ast_helpers_js_1.syntheticCapture)('@reference.parameter-types', callNode, JSON.stringify(argTypes));
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
// Structural receiver chain for a call whose receiver is itself an
|
|
572
|
+
// expression, so resolution can type it by folding over structure
|
|
573
|
+
// instead of re-parsing the receiver's source text. Self-gating: a
|
|
574
|
+
// non-call match, an absent receiver, or a chain with no nameable base
|
|
575
|
+
// all leave `grouped` untouched.
|
|
576
|
+
(0, receiver_chain_captures_js_1.synthesizeReceiverChainCapture)(grouped, groupedNodes['@reference.receiver']);
|
|
577
|
+
out.push(grouped);
|
|
578
|
+
// Synthesize `this` receiver type-bindings on every function-like
|
|
579
|
+
// scope that is structurally a class member. `receiver-binding.ts`
|
|
580
|
+
// handles the walk-up (method, method_signature, abstract
|
|
581
|
+
// signature, arrow/function-expression assigned to a class field).
|
|
582
|
+
// Arrow functions nested inside method bodies rely on scope-chain
|
|
583
|
+
// lookup instead of synthesis — covered by `tsReceiverBinding`.
|
|
584
|
+
const scopeFnAnchor = grouped['@scope.function'];
|
|
585
|
+
if (scopeFnAnchor !== undefined) {
|
|
586
|
+
const fnNode = findFunctionNode(tree.rootNode, scopeFnAnchor.range, groupedNodes['@scope.function']);
|
|
587
|
+
if (fnNode !== null) {
|
|
588
|
+
const synth = (0, receiver_binding_js_1.synthesizeTsReceiverBinding)(fnNode);
|
|
589
|
+
if (synth !== null)
|
|
590
|
+
out.push(synth);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
// Synthesize object-destructuring type bindings. The tree-sitter query
|
|
595
|
+
// alone can't express "give me the field NAME and the RHS identifier
|
|
596
|
+
// together" in a way that produces usable @type-binding.name /
|
|
597
|
+
// @type-binding.type captures, so we walk `variable_declarator` nodes
|
|
598
|
+
// whose `name:` is an `object_pattern` and synthesize per-field
|
|
599
|
+
// bindings keyed to the receiver-path `rhsName.fieldName`. The
|
|
600
|
+
// compound-receiver resolver's Case 3b then walks that path when the
|
|
601
|
+
// destructured local is used as a receiver (e.g. `address.save()`).
|
|
602
|
+
synthesizeDestructuringBindings(tree.rootNode, out);
|
|
603
|
+
synthesizeForOfMapTupleBindings(tree.rootNode, out);
|
|
604
|
+
synthesizeInstanceofNarrowings(tree.rootNode, out);
|
|
605
|
+
synthesizeTsInheritanceReferences(tree.rootNode, out);
|
|
606
|
+
out.push(...(0, callable_flow_captures_js_1.synthesizeCallableFlowCaptures)(tree.rootNode, TS_CALLABLE_CAPTURE_OPTIONS));
|
|
607
|
+
// CommonJS module-export declarations (#2723). Shared with the JavaScript
|
|
608
|
+
// emitter: a `.ts` file in a CommonJS package uses the same forms, and
|
|
609
|
+
// without this the default-export NODE was emitted with nothing declaring it
|
|
610
|
+
// — the "found, zero callers" state this work exists to remove (#2729 F7).
|
|
611
|
+
(0, cjs_module_exports_js_1.synthesizeCjsModuleExports)(tree.rootNode, filePath, out);
|
|
612
|
+
return out;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Synthesize `@reference.inherits` captures from TypeScript class heritage so
|
|
616
|
+
* the registry-primary scope-resolution path emits EXTENDS / IMPLEMENTS edges
|
|
617
|
+
* (mirrors C# `synthesizeCsharpInheritanceReferences` / JS
|
|
618
|
+
* `synthesizeJsInheritanceReferences`). Without this, TS inheritance edges came
|
|
619
|
+
* only from the legacy heritage-capture leg (removed in #942), which the worker
|
|
620
|
+
* pipeline drops for registry-primary languages — yielding 0 inheritance edges
|
|
621
|
+
* in worker mode (issue #1951).
|
|
622
|
+
*
|
|
623
|
+
* Scope is intentionally limited to a `class_declaration`'s `class_heritage`
|
|
624
|
+
* `extends_clause` value + `implements_clause` types, matching the legacy
|
|
625
|
+
* TypeScript heritage query's class scope (TYPESCRIPT_QUERIES). Generic
|
|
626
|
+
* bases agree across both paths: `extends Base<T>` is captured by the legacy
|
|
627
|
+
* `extends_clause value: (identifier)` already (the `type_arguments` are a
|
|
628
|
+
* sibling field), and `implements IFoo<T>` is captured by a legacy clause
|
|
629
|
+
* widened to read the `generic_type`'s `name:` identifier — so the registry
|
|
630
|
+
* path keeps parity on SIMPLE (unqualified) generic bases too (#1951).
|
|
631
|
+
* Qualified bases (`ns.Base`, `ns.Base<T>`, `ns.IFoo<T>`) are ALSO now at parity
|
|
632
|
+
* (#1956 tri-review U2): the synth resolves them by their member_expression /
|
|
633
|
+
* nested_type_identifier tail, and the legacy heritage query was widened with
|
|
634
|
+
* matching arms (member_expression for extends, nested_type_identifier plain +
|
|
635
|
+
* generic-wrapped for implements).
|
|
636
|
+
*
|
|
637
|
+
* `interface_declaration` and `abstract_class_declaration` heritage IS emitted
|
|
638
|
+
* (#2842 review; both were silently skipped before, so `interface B extends A`
|
|
639
|
+
* and `abstract class X implements I` produced no edge and every dispatch walk
|
|
640
|
+
* dead-ended on a bodiless declaration). They reach their bases by different
|
|
641
|
+
* shapes: an abstract class carries the same `class_heritage` child a concrete
|
|
642
|
+
* one does, while an interface's bases hang off `extends_type_clause` directly. The EXTENDS-vs-IMPLEMENTS split is decided downstream from the
|
|
643
|
+
* resolved target's symbol kind in `preEmitInheritanceEdges` (class-extends →
|
|
644
|
+
* EXTENDS, implements-interface / interface-target → IMPLEMENTS), so all bases
|
|
645
|
+
* are emitted with the same `inherits` kind here. The base lookup name is
|
|
646
|
+
* normalized to its bare simple identifier (`BaseModel<string>` → `BaseModel`,
|
|
647
|
+
* `models.Base` → `Base`) so `findClassBindingInScope` resolves it.
|
|
648
|
+
*/
|
|
649
|
+
function synthesizeTsInheritanceReferences(root, out) {
|
|
650
|
+
const stack = [root];
|
|
651
|
+
for (;;) {
|
|
652
|
+
const node = stack.pop();
|
|
653
|
+
if (node === undefined)
|
|
654
|
+
break;
|
|
655
|
+
for (const child of node.namedChildren) {
|
|
656
|
+
if (child !== null)
|
|
657
|
+
stack.push(child);
|
|
658
|
+
}
|
|
659
|
+
// `interface B extends A, C` hangs its bases off an `extends_type_clause`
|
|
660
|
+
// DIRECTLY on the interface — there is no `class_heritage` wrapper, so the
|
|
661
|
+
// class path below cannot reach them (#2842 review). The clause's `type`
|
|
662
|
+
// field is `multiple: true`, so `childForFieldName('type')` would silently
|
|
663
|
+
// return only `A` and drop `C`; iterate the named children instead.
|
|
664
|
+
if (node.type === 'interface_declaration') {
|
|
665
|
+
for (const child of node.namedChildren) {
|
|
666
|
+
if (child === null || child.type !== 'extends_type_clause')
|
|
667
|
+
continue;
|
|
668
|
+
for (const base of child.namedChildren) {
|
|
669
|
+
emitTsInheritanceBase(base, out);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
// `abstract class X implements I` carries an identical `class_heritage`
|
|
675
|
+
// child, so the existing body handles it once the node type is admitted.
|
|
676
|
+
// Omitting it severed the only link between an interface and the concrete
|
|
677
|
+
// classes below an abstract base — a whole subtree, not a leaf.
|
|
678
|
+
if (node.type !== 'class_declaration' && node.type !== 'abstract_class_declaration')
|
|
679
|
+
continue;
|
|
680
|
+
// Find the `class_heritage` child (holds extends / implements clauses).
|
|
681
|
+
let heritage = null;
|
|
682
|
+
for (const child of node.namedChildren) {
|
|
683
|
+
if (child !== null && child.type === 'class_heritage') {
|
|
684
|
+
heritage = child;
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (heritage === null)
|
|
689
|
+
continue;
|
|
690
|
+
for (const clause of heritage.namedChildren) {
|
|
691
|
+
if (clause === null)
|
|
692
|
+
continue;
|
|
693
|
+
if (clause.type === 'extends_clause') {
|
|
694
|
+
// `extends Foo` / `extends Foo<T>` — the base is the `value:` field
|
|
695
|
+
// (an identifier; generics live in a sibling `type_arguments`).
|
|
696
|
+
const value = clause.childForFieldName('value') ?? clause.firstNamedChild;
|
|
697
|
+
emitTsInheritanceBase(value, out);
|
|
698
|
+
}
|
|
699
|
+
else if (clause.type === 'implements_clause') {
|
|
700
|
+
// `implements IFoo, IBar<T>` — each base type is a direct named child.
|
|
701
|
+
for (const base of clause.namedChildren) {
|
|
702
|
+
emitTsInheritanceBase(base, out);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
/** Emit one `@reference.inherits` match for a TS heritage base, normalizing
|
|
709
|
+
* the lookup name to its bare simple identifier. No-ops on null / non-type
|
|
710
|
+
* nodes or when the bare name can't be derived. */
|
|
711
|
+
function emitTsInheritanceBase(base, out) {
|
|
712
|
+
if (base === null)
|
|
713
|
+
return;
|
|
714
|
+
const nameNode = terminalTsTypeNameNode(base);
|
|
715
|
+
if (nameNode === null)
|
|
716
|
+
return;
|
|
717
|
+
out.push({
|
|
718
|
+
'@reference.inherits': (0, ast_helpers_js_1.nodeToCapture)('@reference.inherits', base),
|
|
719
|
+
'@reference.name': (0, ast_helpers_js_1.nodeToCapture)('@reference.name', nameNode),
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
/** Resolve a TypeScript heritage base node to its bare simple-identifier node.
|
|
723
|
+
* `Foo` → `Foo`, `Foo<T>` (generic_type) → `Foo`, `models.Base`
|
|
724
|
+
* (nested_type_identifier / member_expression) → `Base`. Mirrors C#'s
|
|
725
|
+
* `terminalTypeNameNode`; returns null when no leaf identifier is reachable. */
|
|
726
|
+
function terminalTsTypeNameNode(node) {
|
|
727
|
+
switch (node.type) {
|
|
728
|
+
case 'identifier':
|
|
729
|
+
case 'type_identifier':
|
|
730
|
+
// `extends ns.Base` parses as a member_expression whose tail is a
|
|
731
|
+
// `property_identifier` (not a type_identifier) — treat it as a leaf name.
|
|
732
|
+
case 'property_identifier':
|
|
733
|
+
return node;
|
|
734
|
+
case 'generic_type': {
|
|
735
|
+
// generic_type has a `name:` field (type_identifier / nested_type_identifier);
|
|
736
|
+
// recurse to strip the type_arguments and reach the bare base identifier.
|
|
737
|
+
const name = node.childForFieldName('name') ?? node.firstNamedChild;
|
|
738
|
+
return name === null ? null : terminalTsTypeNameNode(name);
|
|
739
|
+
}
|
|
740
|
+
case 'nested_type_identifier':
|
|
741
|
+
case 'member_expression': {
|
|
742
|
+
// Qualified `A.B.Base` → tail identifier `Base`.
|
|
743
|
+
const tail = node.lastNamedChild;
|
|
744
|
+
return tail === null ? null : terminalTsTypeNameNode(tail);
|
|
745
|
+
}
|
|
746
|
+
default:
|
|
747
|
+
return null;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Walk the AST and synthesize type-binding captures for object
|
|
752
|
+
* destructuring of the form `const { field } = rhs` or
|
|
753
|
+
* `const { field: alias } = rhs`. Pushes one synthetic CaptureMatch
|
|
754
|
+
* per destructured identifier with:
|
|
755
|
+
*
|
|
756
|
+
* - `@type-binding.name` → the local identifier
|
|
757
|
+
* - `@type-binding.type` → the compound path `rhs.field`
|
|
758
|
+
* - `@type-binding.destructured` anchor
|
|
759
|
+
*
|
|
760
|
+
* Only fires when the RHS is a bare identifier — more complex RHS
|
|
761
|
+
* shapes (call_expression, member_expression) resolve via the normal
|
|
762
|
+
* type-alias + chain-follow paths on the RHS first, then the field
|
|
763
|
+
* walk catches the destructured identifier on a second fixpoint pass.
|
|
764
|
+
* Left as a follow-up optimization.
|
|
765
|
+
*/
|
|
766
|
+
function synthesizeDestructuringBindings(root, out) {
|
|
767
|
+
const stack = [root];
|
|
768
|
+
for (;;) {
|
|
769
|
+
const node = stack.pop();
|
|
770
|
+
if (node === undefined)
|
|
771
|
+
break;
|
|
772
|
+
for (const child of node.namedChildren) {
|
|
773
|
+
if (child !== null)
|
|
774
|
+
stack.push(child);
|
|
775
|
+
}
|
|
776
|
+
if (node.type !== 'variable_declarator')
|
|
777
|
+
continue;
|
|
778
|
+
const nameNode = node.childForFieldName('name');
|
|
779
|
+
const valueNode = node.childForFieldName('value');
|
|
780
|
+
if (nameNode === null || valueNode === null)
|
|
781
|
+
continue;
|
|
782
|
+
if (nameNode.type !== 'object_pattern')
|
|
783
|
+
continue;
|
|
784
|
+
if (valueNode.type !== 'identifier')
|
|
785
|
+
continue;
|
|
786
|
+
const rhsName = valueNode.text;
|
|
787
|
+
for (const fieldNode of nameNode.namedChildren) {
|
|
788
|
+
if (fieldNode === null)
|
|
789
|
+
continue;
|
|
790
|
+
if (fieldNode.type === 'shorthand_property_identifier_pattern') {
|
|
791
|
+
// `const { address } = user`
|
|
792
|
+
const localName = fieldNode.text;
|
|
793
|
+
out.push({
|
|
794
|
+
'@type-binding.name': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.name', fieldNode, localName),
|
|
795
|
+
'@type-binding.type': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.type', fieldNode, `${rhsName}.${localName}`),
|
|
796
|
+
'@type-binding.destructured': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.destructured', fieldNode, fieldNode.text),
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
else if (fieldNode.type === 'pair_pattern') {
|
|
800
|
+
// `const { address: addr } = user`
|
|
801
|
+
const key = fieldNode.childForFieldName('key');
|
|
802
|
+
const value = fieldNode.childForFieldName('value');
|
|
803
|
+
if (key === null || value === null)
|
|
804
|
+
continue;
|
|
805
|
+
if (value.type !== 'identifier')
|
|
806
|
+
continue;
|
|
807
|
+
const fieldName = key.text;
|
|
808
|
+
const localName = value.text;
|
|
809
|
+
out.push({
|
|
810
|
+
'@type-binding.name': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.name', value, localName),
|
|
811
|
+
'@type-binding.type': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.type', fieldNode, `${rhsName}.${fieldName}`),
|
|
812
|
+
'@type-binding.destructured': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.destructured', fieldNode, fieldNode.text),
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* `for (const [k, v] of mapId)` over a `Map<K,V>` — synthesize per-slot
|
|
820
|
+
* type bindings so `v` resolves like a `Map` iterator tuple element.
|
|
821
|
+
* Uses sentinel `__MAP_TUPLE_i__:rhs` consumed by compound-receiver.
|
|
822
|
+
*/
|
|
823
|
+
function synthesizeForOfMapTupleBindings(root, out) {
|
|
824
|
+
const stack = [root];
|
|
825
|
+
for (;;) {
|
|
826
|
+
const node = stack.pop();
|
|
827
|
+
if (node === undefined)
|
|
828
|
+
break;
|
|
829
|
+
for (const child of node.namedChildren) {
|
|
830
|
+
if (child !== null)
|
|
831
|
+
stack.push(child);
|
|
832
|
+
}
|
|
833
|
+
if (node.type !== 'for_in_statement')
|
|
834
|
+
continue;
|
|
835
|
+
const left = node.childForFieldName('left');
|
|
836
|
+
const right = node.childForFieldName('right');
|
|
837
|
+
if (left === null || right === null)
|
|
838
|
+
continue;
|
|
839
|
+
if (left.type !== 'array_pattern' || right.type !== 'identifier')
|
|
840
|
+
continue;
|
|
841
|
+
const rhs = right.text;
|
|
842
|
+
let slot = 0;
|
|
843
|
+
for (const child of left.namedChildren) {
|
|
844
|
+
if (child === null || child.type !== 'identifier')
|
|
845
|
+
continue;
|
|
846
|
+
const localName = child.text;
|
|
847
|
+
out.push({
|
|
848
|
+
'@type-binding.name': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.name', child, localName),
|
|
849
|
+
'@type-binding.type': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.type', child, `__MAP_TUPLE_${slot}__:${rhs}`),
|
|
850
|
+
'@type-binding.map-tuple-entry': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.map-tuple-entry', child, String(slot)),
|
|
851
|
+
});
|
|
852
|
+
slot++;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* `if (x instanceof User) { x.save() }` — synthesize a `User` type binding
|
|
858
|
+
* for `x` anchored in the consequence block so scope-chain lookup inside
|
|
859
|
+
* the then-branch sees the narrowed type.
|
|
860
|
+
*
|
|
861
|
+
* **Known limitation:** the LHS must be a bare `identifier` and the RHS
|
|
862
|
+
* an `identifier`/`type_identifier`. Member-expression LHS such as
|
|
863
|
+
* `if (user.address instanceof Address)` is intentionally NOT synthesized
|
|
864
|
+
* — narrowing a property-access target requires a stable storage key
|
|
865
|
+
* the binding layer can hold, which member chains don't supply. Field-
|
|
866
|
+
* type resolution covers the common case for those receivers via
|
|
867
|
+
* declared types instead.
|
|
868
|
+
*/
|
|
869
|
+
function synthesizeInstanceofNarrowings(root, out) {
|
|
870
|
+
const stack = [root];
|
|
871
|
+
for (;;) {
|
|
872
|
+
const node = stack.pop();
|
|
873
|
+
if (node === undefined)
|
|
874
|
+
break;
|
|
875
|
+
for (const child of node.namedChildren) {
|
|
876
|
+
if (child !== null)
|
|
877
|
+
stack.push(child);
|
|
878
|
+
}
|
|
879
|
+
if (node.type !== 'if_statement')
|
|
880
|
+
continue;
|
|
881
|
+
const cond = node.childForFieldName('condition');
|
|
882
|
+
if (cond === null)
|
|
883
|
+
continue;
|
|
884
|
+
const inner = cond.type === 'parenthesized_expression' ? cond.namedChildren[0] : cond;
|
|
885
|
+
if (inner === null || inner.type !== 'binary_expression')
|
|
886
|
+
continue;
|
|
887
|
+
const op = inner.childForFieldName('operator');
|
|
888
|
+
const left = inner.childForFieldName('left');
|
|
889
|
+
const right = inner.childForFieldName('right');
|
|
890
|
+
if (op === null || left === null || right === null)
|
|
891
|
+
continue;
|
|
892
|
+
if (op.type !== 'instanceof')
|
|
893
|
+
continue;
|
|
894
|
+
if (left.type !== 'identifier')
|
|
895
|
+
continue;
|
|
896
|
+
if (right.type !== 'identifier' && right.type !== 'type_identifier')
|
|
897
|
+
continue;
|
|
898
|
+
const varName = left.text;
|
|
899
|
+
const typeName = right.text;
|
|
900
|
+
const cons = node.childForFieldName('consequence');
|
|
901
|
+
if (cons === null)
|
|
902
|
+
continue;
|
|
903
|
+
out.push({
|
|
904
|
+
'@type-binding.name': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.name', cons, varName),
|
|
905
|
+
'@type-binding.type': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.type', right, typeName),
|
|
906
|
+
'@type-binding.instanceof-narrow': (0, ast_helpers_js_1.syntheticCapture)('@type-binding.instanceof-narrow', cons, '1'),
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
/** Infer a TypeScript argument expression's static type from literal
|
|
911
|
+
* shapes. Returns `''` when the arg has no statically-derivable type
|
|
912
|
+
* (identifiers, member accesses, etc.) — consumers treat unknown as
|
|
913
|
+
* any-match during overload narrowing. */
|
|
914
|
+
function inferArgType(argNode) {
|
|
915
|
+
switch (argNode.type) {
|
|
916
|
+
case 'number':
|
|
917
|
+
return 'number';
|
|
918
|
+
case 'string':
|
|
919
|
+
case 'template_string':
|
|
920
|
+
return 'string';
|
|
921
|
+
case 'true':
|
|
922
|
+
case 'false':
|
|
923
|
+
return 'boolean';
|
|
924
|
+
case 'null':
|
|
925
|
+
return 'null';
|
|
926
|
+
case 'undefined':
|
|
927
|
+
return 'undefined';
|
|
928
|
+
case 'array':
|
|
929
|
+
return 'Array';
|
|
930
|
+
case 'object':
|
|
931
|
+
return 'object';
|
|
932
|
+
case 'regex':
|
|
933
|
+
return 'RegExp';
|
|
934
|
+
case 'new_expression': {
|
|
935
|
+
const ctor = argNode.childForFieldName('constructor');
|
|
936
|
+
return ctor?.text ?? '';
|
|
937
|
+
}
|
|
938
|
+
default:
|
|
939
|
+
return '';
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
/** Find the first TypeScript function-like node at the given range.
|
|
943
|
+
* The `@scope.function` anchor range covers the whole node, but the
|
|
944
|
+
* tag alone doesn't identify which node type among the many TS
|
|
945
|
+
* function-likes. */
|
|
946
|
+
function findFunctionNode(rootNode, range, anchorNode) {
|
|
947
|
+
const fromAnchor = findSelfOrAncestorOfTypes(anchorNode, exports.FUNCTION_NODE_TYPES);
|
|
948
|
+
if (fromAnchor !== null)
|
|
949
|
+
return fromAnchor;
|
|
950
|
+
for (const nodeType of exports.FUNCTION_NODE_TYPES) {
|
|
951
|
+
const n = (0, ast_helpers_js_1.findNodeAtRange)(rootNode, range, nodeType);
|
|
952
|
+
if (n !== null)
|
|
953
|
+
return n;
|
|
954
|
+
}
|
|
955
|
+
return null;
|
|
956
|
+
}
|