gitnexus 1.6.6-rc.98 → 1.6.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/README.md +122 -68
- package/dist/_shared/graph/types.d.ts +17 -1
- package/dist/_shared/graph/types.d.ts.map +1 -1
- package/dist/_shared/index.d.ts +3 -5
- package/dist/_shared/index.d.ts.map +1 -1
- package/dist/_shared/index.js +2 -4
- package/dist/_shared/index.js.map +1 -1
- package/dist/_shared/scope-resolution/module-scope-index.d.ts +1 -2
- package/dist/_shared/scope-resolution/module-scope-index.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/module-scope-index.js +1 -2
- package/dist/_shared/scope-resolution/module-scope-index.js.map +1 -1
- package/dist/_shared/scope-resolution/parsed-file.d.ts +24 -0
- package/dist/_shared/scope-resolution/parsed-file.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/reference-site.d.ts +13 -1
- package/dist/_shared/scope-resolution/reference-site.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/context.d.ts +1 -0
- package/dist/_shared/scope-resolution/registries/context.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/context.js +6 -0
- package/dist/_shared/scope-resolution/registries/context.js.map +1 -1
- package/dist/_shared/scope-resolution/registries/evidence.d.ts +2 -3
- package/dist/_shared/scope-resolution/registries/evidence.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/evidence.js +2 -3
- package/dist/_shared/scope-resolution/registries/evidence.js.map +1 -1
- package/dist/_shared/scope-resolution/registries/macro-registry.d.ts +29 -0
- package/dist/_shared/scope-resolution/registries/macro-registry.d.ts.map +1 -0
- package/dist/_shared/scope-resolution/registries/macro-registry.js +32 -0
- package/dist/_shared/scope-resolution/registries/macro-registry.js.map +1 -0
- package/dist/_shared/scope-resolution/symbol-definition.d.ts +9 -0
- package/dist/_shared/scope-resolution/symbol-definition.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/types.d.ts +1 -1
- package/dist/_shared/scope-resolution/types.d.ts.map +1 -1
- package/dist/cli/ai-context.d.ts +35 -1
- package/dist/cli/ai-context.js +111 -12
- package/dist/cli/analyze-config.d.ts +92 -0
- package/dist/cli/analyze-config.js +364 -0
- package/dist/cli/analyze.d.ts +17 -1
- package/dist/cli/analyze.js +224 -71
- package/dist/cli/cli-message.d.ts +1 -1
- package/dist/cli/doctor.d.ts +18 -0
- package/dist/cli/doctor.js +32 -0
- package/dist/cli/i18n/en.d.ts +2 -2
- package/dist/cli/i18n/en.js +2 -2
- package/dist/cli/i18n/resources.d.ts +2 -2
- package/dist/cli/i18n/zh-CN.js +2 -2
- package/dist/cli/index.js +4 -2
- package/dist/cli/resolve-invocation.d.ts +21 -0
- package/dist/cli/resolve-invocation.js +68 -0
- package/dist/cli/setup.d.ts +33 -0
- package/dist/cli/setup.js +96 -35
- package/dist/cli/skill-gen.js +2 -2
- package/dist/cli/wiki.js +20 -4
- package/dist/core/embeddings/embedder.d.ts +1 -1
- package/dist/core/embeddings/embedder.js +14 -1
- package/dist/core/embeddings/runtime-support.d.ts +41 -0
- package/dist/core/embeddings/runtime-support.js +65 -0
- package/dist/core/group/extractors/grpc-patterns/proto.js +2 -1
- package/dist/core/group/extractors/http-patterns/java.js +15 -1
- package/dist/core/ingestion/call-processor.d.ts +57 -227
- package/dist/core/ingestion/call-processor.js +172 -2595
- package/dist/core/ingestion/call-routing.d.ts +6 -5
- package/dist/core/ingestion/call-routing.js +6 -6
- package/dist/core/ingestion/call-types.d.ts +0 -75
- package/dist/core/ingestion/class-extractors/configs/c-cpp.js +26 -1
- package/dist/core/ingestion/class-extractors/configs/ruby.js +3 -0
- package/dist/core/ingestion/class-extractors/generic.js +9 -11
- package/dist/core/ingestion/class-types.d.ts +23 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.d.ts +11 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.js +227 -73
- package/dist/core/ingestion/cobol-processor.d.ts +1 -0
- package/dist/core/ingestion/cobol-processor.js +51 -2
- package/dist/core/ingestion/emit-references.js +8 -2
- package/dist/core/ingestion/export-detection.d.ts +2 -1
- package/dist/core/ingestion/export-detection.js +2 -6
- package/dist/core/ingestion/field-extractors/configs/dart.d.ts +0 -6
- package/dist/core/ingestion/field-extractors/configs/dart.js +62 -44
- package/dist/core/ingestion/field-extractors/configs/go.d.ts +0 -9
- package/dist/core/ingestion/field-extractors/configs/go.js +40 -1
- package/dist/core/ingestion/field-extractors/configs/jvm.js +43 -4
- package/dist/core/ingestion/field-extractors/configs/php.js +1 -2
- package/dist/core/ingestion/field-extractors/configs/swift.d.ts +12 -1
- package/dist/core/ingestion/field-extractors/configs/swift.js +31 -6
- package/dist/core/ingestion/field-extractors/generic.d.ts +6 -0
- package/dist/core/ingestion/field-extractors/generic.js +5 -4
- package/dist/core/ingestion/field-extractors/typescript.js +0 -29
- package/dist/core/ingestion/filesystem-walker.d.ts +0 -9
- package/dist/core/ingestion/filesystem-walker.js +0 -11
- package/dist/core/ingestion/finalize-orchestrator.js +14 -2
- package/dist/core/ingestion/import-resolvers/configs/swift.d.ts +21 -0
- package/dist/core/ingestion/import-resolvers/configs/swift.js +72 -11
- package/dist/core/ingestion/import-resolvers/python.d.ts +1 -1
- package/dist/core/ingestion/import-resolvers/standard.d.ts +2 -2
- package/dist/core/ingestion/import-resolvers/standard.js +6 -5
- package/dist/core/ingestion/import-resolvers/utils.d.ts +2 -5
- package/dist/core/ingestion/import-resolvers/utils.js +1 -9
- package/dist/core/ingestion/language-provider.d.ts +39 -119
- package/dist/core/ingestion/language-provider.js +0 -2
- package/dist/core/ingestion/languages/c/capture-side-channel.d.ts +62 -0
- package/dist/core/ingestion/languages/c/capture-side-channel.js +65 -0
- package/dist/core/ingestion/languages/c/captures.js +41 -23
- package/dist/core/ingestion/languages/c/import-decomposer.d.ts +9 -0
- package/dist/core/ingestion/languages/c/import-decomposer.js +15 -0
- package/dist/core/ingestion/languages/c/import-target.js +52 -9
- package/dist/core/ingestion/languages/c/index.d.ts +2 -1
- package/dist/core/ingestion/languages/c/index.js +2 -1
- package/dist/core/ingestion/languages/c/query.js +15 -0
- package/dist/core/ingestion/languages/c/scope-resolver.js +47 -4
- package/dist/core/ingestion/languages/c/static-linkage.d.ts +8 -0
- package/dist/core/ingestion/languages/c/static-linkage.js +46 -1
- package/dist/core/ingestion/languages/c-cpp.js +16 -7
- package/dist/core/ingestion/languages/cobol/captures.js +25 -2
- package/dist/core/ingestion/languages/cpp/adl.d.ts +88 -4
- package/dist/core/ingestion/languages/cpp/adl.js +380 -160
- package/dist/core/ingestion/languages/cpp/arity-metadata.js +2 -8
- package/dist/core/ingestion/languages/cpp/capture-side-channel.d.ts +65 -0
- package/dist/core/ingestion/languages/cpp/capture-side-channel.js +78 -0
- package/dist/core/ingestion/languages/cpp/captures.js +162 -54
- package/dist/core/ingestion/languages/cpp/file-local-linkage.d.ts +18 -52
- package/dist/core/ingestion/languages/cpp/file-local-linkage.js +49 -1
- package/dist/core/ingestion/languages/cpp/import-decomposer.d.ts +7 -0
- package/dist/core/ingestion/languages/cpp/import-decomposer.js +12 -0
- package/dist/core/ingestion/languages/cpp/index.d.ts +1 -0
- package/dist/core/ingestion/languages/cpp/index.js +1 -0
- package/dist/core/ingestion/languages/cpp/inline-namespaces.d.ts +8 -0
- package/dist/core/ingestion/languages/cpp/inline-namespaces.js +21 -0
- package/dist/core/ingestion/languages/cpp/query.js +21 -0
- package/dist/core/ingestion/languages/cpp/range-bindings.js +20 -5
- package/dist/core/ingestion/languages/cpp/scope-resolver.js +52 -5
- package/dist/core/ingestion/languages/cpp/two-phase-lookup.d.ts +20 -0
- package/dist/core/ingestion/languages/cpp/two-phase-lookup.js +83 -3
- package/dist/core/ingestion/languages/csharp/captures.js +205 -41
- package/dist/core/ingestion/languages/csharp/index.d.ts +3 -4
- package/dist/core/ingestion/languages/csharp/index.js +3 -4
- package/dist/core/ingestion/languages/csharp/interpret.js +17 -3
- package/dist/core/ingestion/languages/csharp/namespace-siblings.d.ts +17 -7
- package/dist/core/ingestion/languages/csharp/namespace-siblings.js +129 -124
- package/dist/core/ingestion/languages/csharp/qualified-type-names.d.ts +14 -0
- package/dist/core/ingestion/languages/csharp/qualified-type-names.js +59 -0
- package/dist/core/ingestion/languages/csharp/query.js +13 -0
- package/dist/core/ingestion/languages/csharp/receiver-binding.js +10 -6
- package/dist/core/ingestion/languages/csharp/scope-resolver.js +8 -1
- package/dist/core/ingestion/languages/csharp.js +0 -5
- package/dist/core/ingestion/languages/dart/arity-metadata.d.ts +25 -0
- package/dist/core/ingestion/languages/dart/arity-metadata.js +35 -0
- package/dist/core/ingestion/languages/dart/arity.d.ts +19 -0
- package/dist/core/ingestion/languages/dart/arity.js +31 -0
- package/dist/core/ingestion/languages/dart/built-ins.d.ts +11 -0
- package/dist/core/ingestion/languages/dart/built-ins.js +34 -0
- package/dist/core/ingestion/languages/dart/cache-stats.d.ts +13 -0
- package/dist/core/ingestion/languages/dart/cache-stats.js +24 -0
- package/dist/core/ingestion/languages/dart/captures.d.ts +29 -0
- package/dist/core/ingestion/languages/dart/captures.js +445 -0
- package/dist/core/ingestion/languages/dart/expand-wildcards.d.ts +13 -0
- package/dist/core/ingestion/languages/dart/expand-wildcards.js +31 -0
- package/dist/core/ingestion/languages/dart/import-target.d.ts +15 -0
- package/dist/core/ingestion/languages/dart/import-target.js +65 -0
- package/dist/core/ingestion/languages/dart/index.d.ts +28 -0
- package/dist/core/ingestion/languages/dart/index.js +28 -0
- package/dist/core/ingestion/languages/dart/interpret.d.ts +24 -0
- package/dist/core/ingestion/languages/dart/interpret.js +95 -0
- package/dist/core/ingestion/languages/dart/merge-bindings.d.ts +10 -0
- package/dist/core/ingestion/languages/dart/merge-bindings.js +39 -0
- package/dist/core/ingestion/languages/dart/query.d.ts +26 -0
- package/dist/core/ingestion/languages/dart/query.js +142 -0
- package/dist/core/ingestion/languages/dart/receiver-binding.d.ts +24 -0
- package/dist/core/ingestion/languages/dart/receiver-binding.js +87 -0
- package/dist/core/ingestion/languages/dart/scope-resolver.d.ts +29 -0
- package/dist/core/ingestion/languages/dart/scope-resolver.js +194 -0
- package/dist/core/ingestion/languages/dart/signature-bindings.d.ts +23 -0
- package/dist/core/ingestion/languages/dart/signature-bindings.js +51 -0
- package/dist/core/ingestion/languages/dart/simple-hooks.d.ts +20 -0
- package/dist/core/ingestion/languages/dart/simple-hooks.js +47 -0
- package/dist/core/ingestion/languages/dart.d.ts +0 -1
- package/dist/core/ingestion/languages/dart.js +15 -29
- package/dist/core/ingestion/languages/go/arity-metadata.d.ts +1 -0
- package/dist/core/ingestion/languages/go/arity-metadata.js +31 -1
- package/dist/core/ingestion/languages/go/captures.js +247 -26
- package/dist/core/ingestion/languages/go/interface-impls.js +476 -50
- package/dist/core/ingestion/languages/go/interpret.js +21 -11
- package/dist/core/ingestion/languages/go/method-owners.js +20 -8
- package/dist/core/ingestion/languages/go/query.js +15 -7
- package/dist/core/ingestion/languages/go/range-binding.js +24 -9
- package/dist/core/ingestion/languages/go/receiver-binding.js +1 -1
- package/dist/core/ingestion/languages/go/scope-resolver.js +2 -2
- package/dist/core/ingestion/languages/go/simple-hooks.js +10 -5
- package/dist/core/ingestion/languages/go/type-binding.d.ts +1 -0
- package/dist/core/ingestion/languages/go/type-binding.js +40 -2
- package/dist/core/ingestion/languages/go.d.ts +0 -1
- package/dist/core/ingestion/languages/go.js +0 -5
- package/dist/core/ingestion/languages/index.d.ts +0 -5
- package/dist/core/ingestion/languages/index.js +0 -3
- package/dist/core/ingestion/languages/java/captures.js +252 -23
- package/dist/core/ingestion/languages/java/interpret.js +12 -6
- package/dist/core/ingestion/languages/java/package-siblings.js +18 -5
- package/dist/core/ingestion/languages/java/query.js +16 -1
- package/dist/core/ingestion/languages/java/scope-resolver.d.ts +2 -8
- package/dist/core/ingestion/languages/java/scope-resolver.js +2 -8
- package/dist/core/ingestion/languages/java.js +0 -5
- package/dist/core/ingestion/languages/javascript/captures.js +185 -11
- package/dist/core/ingestion/languages/javascript/query.js +107 -1
- package/dist/core/ingestion/languages/kotlin/capture-side-channel.d.ts +57 -0
- package/dist/core/ingestion/languages/kotlin/capture-side-channel.js +60 -0
- package/dist/core/ingestion/languages/kotlin/captures.js +213 -22
- package/dist/core/ingestion/languages/kotlin/companion-scopes.d.ts +7 -0
- package/dist/core/ingestion/languages/kotlin/companion-scopes.js +10 -0
- package/dist/core/ingestion/languages/kotlin/index.d.ts +1 -0
- package/dist/core/ingestion/languages/kotlin/index.js +1 -0
- package/dist/core/ingestion/languages/kotlin/query.js +30 -0
- package/dist/core/ingestion/languages/kotlin/scope-resolver.d.ts +5 -7
- package/dist/core/ingestion/languages/kotlin/scope-resolver.js +22 -7
- package/dist/core/ingestion/languages/kotlin.js +8 -5
- package/dist/core/ingestion/languages/php/captures.js +135 -19
- package/dist/core/ingestion/languages/php/import-decomposer.js +21 -63
- package/dist/core/ingestion/languages/php/index.d.ts +3 -4
- package/dist/core/ingestion/languages/php/index.js +3 -4
- package/dist/core/ingestion/languages/php/query.js +5 -0
- package/dist/core/ingestion/languages/php/receiver-binding.js +8 -4
- package/dist/core/ingestion/languages/php.js +0 -4
- package/dist/core/ingestion/languages/python/captures.js +128 -13
- package/dist/core/ingestion/languages/python/depends-references.js +1 -1
- package/dist/core/ingestion/languages/python/import-target.d.ts +4 -5
- package/dist/core/ingestion/languages/python/import-target.js +108 -16
- package/dist/core/ingestion/languages/python/index-stats.d.ts +18 -0
- package/dist/core/ingestion/languages/python/index-stats.js +25 -0
- package/dist/core/ingestion/languages/python/index.d.ts +3 -4
- package/dist/core/ingestion/languages/python/index.js +3 -4
- package/dist/core/ingestion/languages/python/query.js +17 -0
- package/dist/core/ingestion/languages/python/scope-resolver.js +7 -6
- package/dist/core/ingestion/languages/python.d.ts +0 -2
- package/dist/core/ingestion/languages/python.js +0 -7
- package/dist/core/ingestion/languages/ruby/captures.js +174 -31
- package/dist/core/ingestion/languages/ruby/import-target.js +2 -1
- package/dist/core/ingestion/languages/ruby/interpret.js +2 -1
- package/dist/core/ingestion/languages/ruby/query.js +10 -0
- package/dist/core/ingestion/languages/ruby/scope-resolver.js +61 -11
- package/dist/core/ingestion/languages/ruby.js +4 -53
- package/dist/core/ingestion/languages/rust/captures.js +95 -13
- package/dist/core/ingestion/languages/rust/query.js +64 -1
- package/dist/core/ingestion/languages/rust/range-binding.js +40 -12
- package/dist/core/ingestion/languages/rust/receiver-binding.js +9 -0
- package/dist/core/ingestion/languages/rust/scope-resolver.js +75 -1
- package/dist/core/ingestion/languages/rust.d.ts +0 -2
- package/dist/core/ingestion/languages/rust.js +0 -6
- package/dist/core/ingestion/languages/swift/arity-metadata.d.ts +24 -0
- package/dist/core/ingestion/languages/swift/arity-metadata.js +41 -0
- package/dist/core/ingestion/languages/swift/arity.d.ts +29 -0
- package/dist/core/ingestion/languages/swift/arity.js +42 -0
- package/dist/core/ingestion/languages/swift/base-type.d.ts +20 -0
- package/dist/core/ingestion/languages/swift/base-type.js +27 -0
- package/dist/core/ingestion/languages/swift/cache-stats.d.ts +15 -0
- package/dist/core/ingestion/languages/swift/cache-stats.js +26 -0
- package/dist/core/ingestion/languages/swift/captures.d.ts +35 -0
- package/dist/core/ingestion/languages/swift/captures.js +495 -0
- package/dist/core/ingestion/languages/swift/implicit-imports.d.ts +34 -0
- package/dist/core/ingestion/languages/swift/implicit-imports.js +57 -0
- package/dist/core/ingestion/languages/swift/import-decomposer.d.ts +24 -0
- package/dist/core/ingestion/languages/swift/import-decomposer.js +84 -0
- package/dist/core/ingestion/languages/swift/import-target.d.ts +33 -0
- package/dist/core/ingestion/languages/swift/import-target.js +81 -0
- package/dist/core/ingestion/languages/swift/index.d.ts +37 -0
- package/dist/core/ingestion/languages/swift/index.js +37 -0
- package/dist/core/ingestion/languages/swift/interpret.d.ts +15 -0
- package/dist/core/ingestion/languages/swift/interpret.js +89 -0
- package/dist/core/ingestion/languages/swift/merge-bindings.d.ts +20 -0
- package/dist/core/ingestion/languages/swift/merge-bindings.js +48 -0
- package/dist/core/ingestion/languages/swift/query.d.ts +46 -0
- package/dist/core/ingestion/languages/swift/query.js +194 -0
- package/dist/core/ingestion/languages/swift/receiver-binding.d.ts +40 -0
- package/dist/core/ingestion/languages/swift/receiver-binding.js +161 -0
- package/dist/core/ingestion/languages/swift/scope-resolver.d.ts +50 -0
- package/dist/core/ingestion/languages/swift/scope-resolver.js +189 -0
- package/dist/core/ingestion/languages/swift/sibling-type-bindings.d.ts +34 -0
- package/dist/core/ingestion/languages/swift/sibling-type-bindings.js +65 -0
- package/dist/core/ingestion/languages/swift/signature-bindings.d.ts +25 -0
- package/dist/core/ingestion/languages/swift/signature-bindings.js +66 -0
- package/dist/core/ingestion/languages/swift/simple-hooks.d.ts +37 -0
- package/dist/core/ingestion/languages/swift/simple-hooks.js +60 -0
- package/dist/core/ingestion/languages/swift/target-grouping.d.ts +51 -0
- package/dist/core/ingestion/languages/swift/target-grouping.js +93 -0
- package/dist/core/ingestion/languages/swift/target-siblings.d.ts +30 -0
- package/dist/core/ingestion/languages/swift/target-siblings.js +71 -0
- package/dist/core/ingestion/languages/swift.d.ts +0 -5
- package/dist/core/ingestion/languages/swift.js +11 -87
- package/dist/core/ingestion/languages/typescript/array-callback.d.ts +3 -29
- package/dist/core/ingestion/languages/typescript/array-callback.js +4 -43
- package/dist/core/ingestion/languages/typescript/captures.js +147 -17
- package/dist/core/ingestion/languages/typescript/index.d.ts +3 -4
- package/dist/core/ingestion/languages/typescript/index.js +3 -4
- package/dist/core/ingestion/languages/typescript/query.d.ts +2 -3
- package/dist/core/ingestion/languages/typescript/query.js +125 -4
- package/dist/core/ingestion/languages/typescript/receiver-binding.js +0 -1
- package/dist/core/ingestion/languages/typescript.d.ts +2 -3
- package/dist/core/ingestion/languages/typescript.js +46 -23
- package/dist/core/ingestion/languages/vue/captures.d.ts +46 -0
- package/dist/core/ingestion/languages/vue/captures.js +67 -0
- package/dist/core/ingestion/languages/vue/import-target.d.ts +27 -0
- package/dist/core/ingestion/languages/vue/import-target.js +58 -0
- package/dist/core/ingestion/languages/vue/index.d.ts +49 -0
- package/dist/core/ingestion/languages/vue/index.js +49 -0
- package/dist/core/ingestion/languages/vue/scope-resolver.d.ts +55 -0
- package/dist/core/ingestion/languages/vue/scope-resolver.js +292 -0
- package/dist/core/ingestion/languages/vue.js +12 -4
- package/dist/core/ingestion/local-symbol-pruner.d.ts +11 -0
- package/dist/core/ingestion/local-symbol-pruner.js +63 -0
- package/dist/core/ingestion/method-extractors/configs/dart.js +14 -1
- package/dist/core/ingestion/method-extractors/configs/jvm.js +37 -20
- package/dist/core/ingestion/method-extractors/configs/php.js +0 -1
- package/dist/core/ingestion/method-extractors/configs/swift.js +11 -4
- package/dist/core/ingestion/method-types.d.ts +2 -2
- package/dist/core/ingestion/model/index.d.ts +0 -3
- package/dist/core/ingestion/model/index.js +0 -8
- package/dist/core/ingestion/model/resolve.d.ts +7 -43
- package/dist/core/ingestion/model/resolve.js +7 -226
- package/dist/core/ingestion/model/scope-resolution-indexes.d.ts +46 -1
- package/dist/core/ingestion/model/semantic-model.d.ts +4 -6
- package/dist/core/ingestion/model/semantic-model.js +1 -1
- package/dist/core/ingestion/model/symbol-table.d.ts +3 -4
- package/dist/core/ingestion/model/symbol-table.js +3 -4
- package/dist/core/ingestion/parsing-processor.d.ts +30 -24
- package/dist/core/ingestion/parsing-processor.js +76 -640
- package/dist/core/ingestion/pipeline-phases/communities.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/communities.js +5 -2
- package/dist/core/ingestion/pipeline-phases/cross-file.d.ts +9 -8
- package/dist/core/ingestion/pipeline-phases/cross-file.js +16 -12
- package/dist/core/ingestion/pipeline-phases/index.d.ts +1 -0
- package/dist/core/ingestion/pipeline-phases/index.js +1 -0
- package/dist/core/ingestion/pipeline-phases/mro.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/mro.js +2 -2
- package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +44 -22
- package/dist/core/ingestion/pipeline-phases/parse-impl.js +426 -565
- package/dist/core/ingestion/pipeline-phases/parse.d.ts +13 -33
- package/dist/core/ingestion/pipeline-phases/parse.js +2 -2
- package/dist/core/ingestion/pipeline-phases/processes.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/processes.js +5 -3
- package/dist/core/ingestion/pipeline-phases/prune-local-symbols.d.ts +14 -0
- package/dist/core/ingestion/pipeline-phases/prune-local-symbols.js +26 -0
- package/dist/core/ingestion/pipeline.d.ts +27 -19
- package/dist/core/ingestion/pipeline.js +4 -2
- package/dist/core/ingestion/resolve-references.js +15 -3
- package/dist/core/ingestion/route-extractors/laravel.d.ts +10 -0
- package/dist/core/ingestion/route-extractors/laravel.js +88 -9
- package/dist/core/ingestion/scope-extractor-bridge.d.ts +2 -1
- package/dist/core/ingestion/scope-extractor-bridge.js +2 -2
- package/dist/core/ingestion/scope-extractor.js +13 -0
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +181 -15
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.js +21 -10
- package/dist/core/ingestion/scope-resolution/graph-bridge/edges.js +10 -2
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.d.ts +7 -1
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.js +58 -6
- package/dist/core/ingestion/scope-resolution/graph-bridge/node-lookup.js +24 -5
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.d.ts +68 -1
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.js +189 -29
- package/dist/core/ingestion/scope-resolution/passes/imported-return-types.js +21 -1
- package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +1 -1
- package/dist/core/ingestion/scope-resolution/pipeline/phase.d.ts +8 -11
- package/dist/core/ingestion/scope-resolution/pipeline/phase.js +171 -50
- package/dist/core/ingestion/scope-resolution/pipeline/registry.d.ts +3 -4
- package/dist/core/ingestion/scope-resolution/pipeline/registry.js +9 -4
- package/dist/core/ingestion/scope-resolution/pipeline/run.d.ts +28 -5
- package/dist/core/ingestion/scope-resolution/pipeline/run.js +191 -24
- package/dist/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.js +31 -0
- package/dist/core/ingestion/scope-resolution/scope/walkers.d.ts +72 -0
- package/dist/core/ingestion/scope-resolution/scope/walkers.js +440 -39
- package/dist/core/ingestion/scope-resolution/workspace-index.d.ts +18 -2
- package/dist/core/ingestion/scope-resolution/workspace-index.js +94 -7
- package/dist/core/ingestion/tree-sitter-queries.d.ts +14 -14
- package/dist/core/ingestion/tree-sitter-queries.js +380 -158
- package/dist/core/ingestion/ts-js-hoc-utils.d.ts +12 -0
- package/dist/core/ingestion/ts-js-hoc-utils.js +105 -0
- package/dist/core/ingestion/type-env.d.ts +2 -1
- package/dist/core/ingestion/type-env.js +6 -8
- package/dist/core/ingestion/type-extractors/c-cpp.js +8 -10
- package/dist/core/ingestion/type-extractors/csharp.js +18 -34
- package/dist/core/ingestion/type-extractors/go.js +2 -10
- package/dist/core/ingestion/type-extractors/jvm.js +6 -5
- package/dist/core/ingestion/type-extractors/php.js +1 -1
- package/dist/core/ingestion/type-extractors/python.js +1 -1
- package/dist/core/ingestion/type-extractors/ruby.js +2 -2
- package/dist/core/ingestion/type-extractors/rust.js +0 -16
- package/dist/core/ingestion/type-extractors/shared.d.ts +2 -2
- package/dist/core/ingestion/type-extractors/shared.js +25 -11
- package/dist/core/ingestion/type-extractors/swift.js +5 -5
- package/dist/core/ingestion/type-extractors/types.d.ts +1 -1
- package/dist/core/ingestion/type-extractors/typescript.js +1 -1
- package/dist/core/ingestion/utils/ast-helpers.d.ts +119 -1
- package/dist/core/ingestion/utils/ast-helpers.js +260 -13
- package/dist/core/ingestion/utils/callable-labels.d.ts +13 -0
- package/dist/core/ingestion/utils/callable-labels.js +14 -0
- package/dist/core/ingestion/utils/deferred-resolution-profile.d.ts +10 -0
- package/dist/core/ingestion/utils/deferred-resolution-profile.js +30 -0
- package/dist/core/ingestion/utils/heap-probe.d.ts +20 -0
- package/dist/core/ingestion/utils/heap-probe.js +39 -0
- package/dist/core/ingestion/utils/heritage-marker.d.ts +33 -0
- package/dist/core/ingestion/utils/heritage-marker.js +41 -0
- package/dist/core/ingestion/utils/qualified-name.d.ts +37 -0
- package/dist/core/ingestion/utils/qualified-name.js +67 -0
- package/dist/core/ingestion/variable-extractors/configs/c-cpp.js +49 -0
- package/dist/core/ingestion/variable-extractors/configs/dart.js +76 -62
- package/dist/core/ingestion/variable-extractors/configs/go.js +74 -7
- package/dist/core/ingestion/variable-extractors/configs/jvm.js +35 -8
- package/dist/core/ingestion/variable-extractors/generic.js +40 -12
- package/dist/core/ingestion/variable-types.d.ts +9 -0
- package/dist/core/ingestion/vue-sfc-extractor.d.ts +97 -7
- package/dist/core/ingestion/vue-sfc-extractor.js +433 -11
- package/dist/core/ingestion/workers/parse-worker.d.ts +0 -11
- package/dist/core/ingestion/workers/parse-worker.js +358 -187
- package/dist/core/ingestion/workers/worker-pool.d.ts +78 -9
- package/dist/core/ingestion/workers/worker-pool.js +346 -49
- package/dist/core/lbug/csv-generator.js +20 -2
- package/dist/core/lbug/lbug-adapter.js +29 -10
- package/dist/core/lbug/native-check.js +17 -5
- package/dist/core/lbug/pool-adapter.d.ts +0 -19
- package/dist/core/lbug/pool-adapter.js +40 -77
- package/dist/core/lbug/query-result-utils.d.ts +19 -0
- package/dist/core/lbug/query-result-utils.js +28 -0
- package/dist/core/run-analyze.d.ts +9 -2
- package/dist/core/run-analyze.js +24 -3
- package/dist/core/tree-sitter/parser-loader.d.ts +13 -0
- package/dist/core/tree-sitter/parser-loader.js +4 -0
- package/dist/core/tree-sitter/safe-parse.d.ts +70 -3
- package/dist/core/tree-sitter/safe-parse.js +214 -11
- package/dist/core/wiki/generator.js +13 -5
- package/dist/core/wiki/graph-queries.d.ts +3 -0
- package/dist/core/wiki/graph-queries.js +9 -1
- package/dist/core/wiki/llm-client.d.ts +1 -1
- package/dist/core/wiki/llm-client.js +7 -2
- package/dist/core/wiki/local-cli-client.d.ts +2 -1
- package/dist/core/wiki/local-cli-client.js +62 -4
- package/dist/mcp/compatible-stdio-transport.d.ts +3 -0
- package/dist/mcp/compatible-stdio-transport.js +22 -0
- package/dist/mcp/core/embedder.d.ts +1 -1
- package/dist/mcp/core/embedder.js +13 -1
- package/dist/mcp/local/local-backend.d.ts +37 -5
- package/dist/mcp/local/local-backend.js +227 -129
- package/dist/mcp/resources.js +3 -3
- package/dist/mcp/server.js +9 -1
- package/dist/storage/git.d.ts +11 -0
- package/dist/storage/git.js +30 -0
- package/dist/storage/parse-cache.d.ts +23 -1
- package/dist/storage/parse-cache.js +138 -32
- package/dist/storage/parsedfile-store.d.ts +142 -0
- package/dist/storage/parsedfile-store.js +367 -0
- package/dist/storage/repo-manager.d.ts +2 -1
- package/dist/storage/scope-index-store.d.ts +114 -0
- package/dist/storage/scope-index-store.js +236 -0
- package/dist/types/pipeline.d.ts +6 -3
- package/hooks/antigravity/gitnexus-antigravity-hook.cjs +2 -1
- package/hooks/claude/gitnexus-hook.cjs +2 -1
- package/hooks/claude/resolve-analyze-cmd.cjs +323 -0
- package/package.json +4 -5
- package/scripts/bench-scope-resolution.ts +1 -3
- package/scripts/cross-platform-tests.ts +4 -1
- package/skills/gitnexus-cli.md +8 -6
- package/skills/gitnexus-debugging.md +15 -15
- package/skills/gitnexus-exploring.md +11 -11
- package/skills/gitnexus-guide.md +1 -1
- package/skills/gitnexus-impact-analysis.md +10 -10
- package/skills/gitnexus-pr-review.md +19 -19
- package/skills/gitnexus-refactoring.md +25 -25
- package/web/assets/{agent-BRX-afm3.js → agent-EkX7webX.js} +156 -131
- package/web/assets/{architectureDiagram-UL44E2DR-B1oYB8-c.js → architectureDiagram-UL44E2DR-BoczH8cv.js} +1 -1
- package/web/assets/{chunk-LCXTWHL2-SPC6pgWI.js → chunk-LCXTWHL2-By5HB3b-.js} +1 -1
- package/web/assets/{chunk-RG4AUYOV-DZXr4Yv3.js → chunk-RG4AUYOV-BQE_DkpL.js} +1 -1
- package/web/assets/{classDiagram-KGZ6W3CR-BqpOj8L9.js → classDiagram-KGZ6W3CR-Dj_02GUH.js} +1 -1
- package/web/assets/{classDiagram-v2-72OJOZXJ-FmElywK2.js → classDiagram-v2-72OJOZXJ-D-NArMpf.js} +1 -1
- package/web/assets/{diagram-3NCE3AQN-BWtJXMDq.js → diagram-3NCE3AQN-VXtXDO95.js} +1 -1
- package/web/assets/{diagram-GF46GFSD-Hh-fChxU.js → diagram-GF46GFSD-B1qab2Ah.js} +1 -1
- package/web/assets/{diagram-QXG6HAR7-DYeQHxGU.js → diagram-QXG6HAR7-BSCHGzzT.js} +1 -1
- package/web/assets/{diagram-WEQXMOUZ-DYGU4T0y.js → diagram-WEQXMOUZ-DHtknmNT.js} +1 -1
- package/web/assets/{erDiagram-L5TCEMPS-bN3wlP2A.js → erDiagram-L5TCEMPS-Db-IYTmm.js} +1 -1
- package/web/assets/{flowDiagram-H6V6AXG4-YACVtF3-.js → flowDiagram-H6V6AXG4-BHDoyVoW.js} +1 -1
- package/web/assets/{index-BhnAdWTt.js → index-BR0IhgbR.js} +10 -10
- package/web/assets/{infoDiagram-3YFTVSEB-BWBzD28-.js → infoDiagram-3YFTVSEB-6h8wbWEe.js} +1 -1
- package/web/assets/{ishikawaDiagram-BNXS4ZKH-B8qYT-j9.js → ishikawaDiagram-BNXS4ZKH-Dx2OkPk1.js} +1 -1
- package/web/assets/{kanban-definition-75IXJCU3-BeoPr5Tl.js → kanban-definition-75IXJCU3-CIIEZfqV.js} +1 -1
- package/web/assets/{mindmap-definition-2TDM6QVE-CdLLN_so.js → mindmap-definition-2TDM6QVE-DUAqydRq.js} +1 -1
- package/web/assets/{pieDiagram-CU6KROY3-DEd2a_k_.js → pieDiagram-CU6KROY3-BntYuYZa.js} +1 -1
- package/web/assets/{requirementDiagram-JXO7QTGE-QNeTo5C_.js → requirementDiagram-JXO7QTGE-QCD6I29n.js} +1 -1
- package/web/assets/{sequenceDiagram-VS2MUI6T-BHC7q7yJ.js → sequenceDiagram-VS2MUI6T-DScFwLz2.js} +1 -1
- package/web/assets/{stateDiagram-7D4R322I-KONnc2Px.js → stateDiagram-7D4R322I-AkRAm6Hl.js} +1 -1
- package/web/assets/{stateDiagram-v2-36443NZ5-C2QfuMlu.js → stateDiagram-v2-36443NZ5-BCK1vigR.js} +1 -1
- package/web/assets/{timeline-definition-O6YCAMPW-D4t4NJx1.js → timeline-definition-O6YCAMPW-BvpIVXjX.js} +1 -1
- package/web/assets/{vennDiagram-MWXL3ELB-6bctC9Yg.js → vennDiagram-MWXL3ELB-BYGWk6dK.js} +1 -1
- package/web/assets/{wardleyDiagram-CUQ6CDDI-BPZYNTvC.js → wardleyDiagram-CUQ6CDDI-Dk1z7H2T.js} +1 -1
- package/web/assets/{xychartDiagram-N2JHSOCM-lBI9O6DW.js → xychartDiagram-N2JHSOCM-2N6NCSWN.js} +1 -1
- package/web/index.html +1 -1
- package/dist/_shared/scope-resolution/shadow/aggregate.d.ts +0 -63
- package/dist/_shared/scope-resolution/shadow/aggregate.d.ts.map +0 -1
- package/dist/_shared/scope-resolution/shadow/aggregate.js +0 -122
- package/dist/_shared/scope-resolution/shadow/aggregate.js.map +0 -1
- package/dist/_shared/scope-resolution/shadow/diff.d.ts +0 -59
- package/dist/_shared/scope-resolution/shadow/diff.d.ts.map +0 -1
- package/dist/_shared/scope-resolution/shadow/diff.js +0 -79
- package/dist/_shared/scope-resolution/shadow/diff.js.map +0 -1
- package/dist/core/ingestion/ast-cache.d.ts +0 -26
- package/dist/core/ingestion/ast-cache.js +0 -48
- package/dist/core/ingestion/heritage-extractors/configs/go.d.ts +0 -13
- package/dist/core/ingestion/heritage-extractors/configs/go.js +0 -20
- package/dist/core/ingestion/heritage-extractors/configs/ruby.d.ts +0 -18
- package/dist/core/ingestion/heritage-extractors/configs/ruby.js +0 -65
- package/dist/core/ingestion/heritage-extractors/generic.d.ts +0 -23
- package/dist/core/ingestion/heritage-extractors/generic.js +0 -47
- package/dist/core/ingestion/heritage-processor.d.ts +0 -54
- package/dist/core/ingestion/heritage-processor.js +0 -367
- package/dist/core/ingestion/heritage-types.d.ts +0 -73
- package/dist/core/ingestion/heritage-types.js +0 -2
- package/dist/core/ingestion/import-processor.d.ts +0 -23
- package/dist/core/ingestion/import-processor.js +0 -377
- package/dist/core/ingestion/model/heritage-map.d.ts +0 -105
- package/dist/core/ingestion/model/heritage-map.js +0 -294
- package/dist/core/ingestion/model/resolution-context.d.ts +0 -93
- package/dist/core/ingestion/model/resolution-context.js +0 -337
- package/dist/core/ingestion/named-bindings/csharp.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/csharp.js +0 -37
- package/dist/core/ingestion/named-bindings/java.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/java.js +0 -29
- package/dist/core/ingestion/named-bindings/kotlin.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/kotlin.js +0 -36
- package/dist/core/ingestion/named-bindings/php.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/php.js +0 -61
- package/dist/core/ingestion/named-bindings/python.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/python.js +0 -49
- package/dist/core/ingestion/named-bindings/rust.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/rust.js +0 -66
- package/dist/core/ingestion/named-bindings/types.d.ts +0 -16
- package/dist/core/ingestion/named-bindings/types.js +0 -6
- package/dist/core/ingestion/named-bindings/typescript.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/typescript.js +0 -58
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.d.ts +0 -17
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.js +0 -209
- package/dist/core/ingestion/pipeline-phases/orm-extraction.d.ts +0 -22
- package/dist/core/ingestion/pipeline-phases/orm-extraction.js +0 -92
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.d.ts +0 -70
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.js +0 -312
- package/dist/core/ingestion/registry-primary-flag.d.ts +0 -89
- package/dist/core/ingestion/registry-primary-flag.js +0 -122
- package/dist/core/ingestion/shadow-harness.d.ts +0 -113
- package/dist/core/ingestion/shadow-harness.js +0 -148
- package/dist/core/ingestion/utils/ruby-self-call.d.ts +0 -52
- package/dist/core/ingestion/utils/ruby-self-call.js +0 -59
- package/scripts/ci-list-migrated-languages.ts +0 -24
- package/scripts/run-parity.ts +0 -128
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift same-module return-type typeBinding mirroring for the
|
|
3
|
+
* `mirrorNamespaceTypeBindings` hook.
|
|
4
|
+
*
|
|
5
|
+
* Swift gives every file in a module (an SPM target) visibility of every
|
|
6
|
+
* sibling's top-level declarations without a syntactic `import`. For a
|
|
7
|
+
* chained call like
|
|
8
|
+
*
|
|
9
|
+
* App.swift: let user = getUser(); user.save() // user → getUser → ?
|
|
10
|
+
* Models.swift: func getUser() -> User { … } // getUser → User
|
|
11
|
+
*
|
|
12
|
+
* to resolve `user.save()` cross-file, App.swift's scope chain must be
|
|
13
|
+
* able to follow `getUser → User`. The function return-type binding
|
|
14
|
+
* (`getUser → User`) lives on Models.swift's module scope, so we mirror
|
|
15
|
+
* sibling module-scope typeBindings into the importer's module scope —
|
|
16
|
+
* the same trick Go uses (`mirrorGoNamespaceTypeBindings`), but Swift has
|
|
17
|
+
* no namespace-import edges, so module membership is the SPM target
|
|
18
|
+
* subtree (`Sources/<Target>/…`): threaded in via the SPM target map
|
|
19
|
+
* (`resolutionConfig` → `coerceSwiftTargets`) and grouped by
|
|
20
|
+
* `groupSwiftFilesBySpmTarget` (replicating legacy `groupSwiftFilesByTarget`;
|
|
21
|
+
* no-source-dir → all files form one `__default__` module).
|
|
22
|
+
*
|
|
23
|
+
* Runs after `populateNamespaceSiblings` and before
|
|
24
|
+
* `propagateImportedReturnTypes`, so the SCC-ordered propagation pass
|
|
25
|
+
* sees the mirrored bindings and chains `user → getUser → User` to the
|
|
26
|
+
* terminal class. Each mirrored binding is chain-followed inside its
|
|
27
|
+
* source module first so we mirror the terminal type, not an intermediate
|
|
28
|
+
* intra-module reference. `Scope.typeBindings` is mutated via the
|
|
29
|
+
* sanctioned non-frozen Map cast (Contract Invariant I6).
|
|
30
|
+
*/
|
|
31
|
+
import { followChainPostFinalize } from '../../scope-resolution/passes/imported-return-types.js';
|
|
32
|
+
import { coerceSwiftTargets, groupSwiftFilesBySpmTarget } from './target-grouping.js';
|
|
33
|
+
export function mirrorSwiftSiblingTypeBindings(parsedFiles, indexes, workspaceIndex, resolutionConfig) {
|
|
34
|
+
const moduleScopeByFile = workspaceIndex.moduleScopeByFile;
|
|
35
|
+
// Group files by SPM target subtree (the module). No-source-dir → all
|
|
36
|
+
// files in one `__default__` bucket.
|
|
37
|
+
const targets = coerceSwiftTargets(resolutionConfig);
|
|
38
|
+
const filesByTarget = groupSwiftFilesBySpmTarget(parsedFiles, (parsed) => parsed.filePath, targets);
|
|
39
|
+
for (const [, group] of filesByTarget) {
|
|
40
|
+
if (group.length < 2)
|
|
41
|
+
continue; // no siblings to mirror from
|
|
42
|
+
const files = group.map((parsed) => parsed.filePath);
|
|
43
|
+
for (const importerFile of files) {
|
|
44
|
+
const importerModule = moduleScopeByFile.get(importerFile);
|
|
45
|
+
if (importerModule === undefined)
|
|
46
|
+
continue;
|
|
47
|
+
for (const sourceFile of files) {
|
|
48
|
+
if (sourceFile === importerFile)
|
|
49
|
+
continue;
|
|
50
|
+
const sourceModule = moduleScopeByFile.get(sourceFile);
|
|
51
|
+
if (sourceModule === undefined)
|
|
52
|
+
continue;
|
|
53
|
+
for (const [name, ref] of sourceModule.typeBindings) {
|
|
54
|
+
if (name.length === 0)
|
|
55
|
+
continue;
|
|
56
|
+
// A local annotation on the importer must win over a sibling's.
|
|
57
|
+
if (importerModule.typeBindings.has(name))
|
|
58
|
+
continue;
|
|
59
|
+
const terminal = followChainPostFinalize(ref, sourceModule.id, indexes);
|
|
60
|
+
importerModule.typeBindings.set(name, terminal);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synthesize parameter-type and function return-type `@type-binding.*`
|
|
3
|
+
* captures for a Swift function-like node.
|
|
4
|
+
*
|
|
5
|
+
* Why synthesized rather than queried: Swift's tree-sitter grammar reuses
|
|
6
|
+
* the field name `name:` for the function name, each parameter's label,
|
|
7
|
+
* each parameter's type, AND the function's return type. A tree-sitter
|
|
8
|
+
* query with two `name:` fields cross-assigns those captures and produces
|
|
9
|
+
* garbage bindings (e.g. `save: save`). Reading the node via the existing
|
|
10
|
+
* `swiftMethodConfig.extractParameters` / `extractReturnType` extractors
|
|
11
|
+
* — which already handle the grammar correctly for the legacy parse path
|
|
12
|
+
* — yields the right name→type pairs. This mirrors how receiver and arity
|
|
13
|
+
* metadata are synthesized in `captures.ts` instead of queried.
|
|
14
|
+
*
|
|
15
|
+
* - **Parameter bindings** anchor inside the function body so the
|
|
16
|
+
* binding lands in the Function scope: `func f(u: User) { u.save() }`
|
|
17
|
+
* → `u: User` visible in f's body.
|
|
18
|
+
* - **Return-type binding** anchors at the function node and carries
|
|
19
|
+
* `@type-binding.return`, which `swiftBindingScopeFor` hoists to the
|
|
20
|
+
* Module scope so `propagateImportedReturnTypes` mirrors it across
|
|
21
|
+
* files and callers see `let u = getUser(); u.save()`.
|
|
22
|
+
*/
|
|
23
|
+
import type { CaptureMatch } from '../../../../_shared/index.js';
|
|
24
|
+
import { type SyntaxNode } from '../../utils/ast-helpers.js';
|
|
25
|
+
export declare function synthesizeSwiftSignatureBindings(fnNode: SyntaxNode): CaptureMatch[];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synthesize parameter-type and function return-type `@type-binding.*`
|
|
3
|
+
* captures for a Swift function-like node.
|
|
4
|
+
*
|
|
5
|
+
* Why synthesized rather than queried: Swift's tree-sitter grammar reuses
|
|
6
|
+
* the field name `name:` for the function name, each parameter's label,
|
|
7
|
+
* each parameter's type, AND the function's return type. A tree-sitter
|
|
8
|
+
* query with two `name:` fields cross-assigns those captures and produces
|
|
9
|
+
* garbage bindings (e.g. `save: save`). Reading the node via the existing
|
|
10
|
+
* `swiftMethodConfig.extractParameters` / `extractReturnType` extractors
|
|
11
|
+
* — which already handle the grammar correctly for the legacy parse path
|
|
12
|
+
* — yields the right name→type pairs. This mirrors how receiver and arity
|
|
13
|
+
* metadata are synthesized in `captures.ts` instead of queried.
|
|
14
|
+
*
|
|
15
|
+
* - **Parameter bindings** anchor inside the function body so the
|
|
16
|
+
* binding lands in the Function scope: `func f(u: User) { u.save() }`
|
|
17
|
+
* → `u: User` visible in f's body.
|
|
18
|
+
* - **Return-type binding** anchors at the function node and carries
|
|
19
|
+
* `@type-binding.return`, which `swiftBindingScopeFor` hoists to the
|
|
20
|
+
* Module scope so `propagateImportedReturnTypes` mirrors it across
|
|
21
|
+
* files and callers see `let u = getUser(); u.save()`.
|
|
22
|
+
*/
|
|
23
|
+
import { nodeToCapture, syntheticCapture } from '../../utils/ast-helpers.js';
|
|
24
|
+
import { swiftMethodConfig } from '../../method-extractors/configs/swift.js';
|
|
25
|
+
const NAMED_FUNCTION_NODE_TYPES = new Set([
|
|
26
|
+
'function_declaration',
|
|
27
|
+
'protocol_function_declaration',
|
|
28
|
+
]);
|
|
29
|
+
export function synthesizeSwiftSignatureBindings(fnNode) {
|
|
30
|
+
const out = [];
|
|
31
|
+
// ── Parameter bindings (anchor in the body for Function-scope landing) ──
|
|
32
|
+
const params = swiftMethodConfig.extractParameters?.(fnNode) ?? [];
|
|
33
|
+
if (params.length > 0) {
|
|
34
|
+
const bodyNode = fnNode.childForFieldName('body');
|
|
35
|
+
// Anchor params inside the body when present; for bodyless protocol
|
|
36
|
+
// requirements there is no Function scope to bind locals into, so skip.
|
|
37
|
+
if (bodyNode !== null) {
|
|
38
|
+
for (const p of params) {
|
|
39
|
+
if (p.type === null || p.name === '')
|
|
40
|
+
continue;
|
|
41
|
+
out.push(buildBindingMatch(bodyNode, '@type-binding.parameter', p.name, p.type));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// ── Return-type binding (function name → return type, hoisted to Module) ──
|
|
46
|
+
// Only named functions have a name to bind; init/deinit have no return.
|
|
47
|
+
if (NAMED_FUNCTION_NODE_TYPES.has(fnNode.type)) {
|
|
48
|
+
const funcName = swiftMethodConfig.extractName?.(fnNode);
|
|
49
|
+
const returnType = swiftMethodConfig.extractReturnType?.(fnNode);
|
|
50
|
+
if (funcName !== undefined &&
|
|
51
|
+
funcName !== '' &&
|
|
52
|
+
returnType !== undefined &&
|
|
53
|
+
returnType !== '') {
|
|
54
|
+
out.push(buildBindingMatch(fnNode, '@type-binding.return', funcName, returnType));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
function buildBindingMatch(anchorNode, sourceTag, name, typeText) {
|
|
60
|
+
const m = {
|
|
61
|
+
[sourceTag]: nodeToCapture(sourceTag, anchorNode),
|
|
62
|
+
'@type-binding.name': syntheticCapture('@type-binding.name', anchorNode, name),
|
|
63
|
+
'@type-binding.type': syntheticCapture('@type-binding.type', anchorNode, typeText),
|
|
64
|
+
};
|
|
65
|
+
return m;
|
|
66
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trivial / no-op-ish hooks for the Swift provider. Kept together
|
|
3
|
+
* because each is a few lines and they share a theme: they make the
|
|
4
|
+
* provider's choice explicit rather than relying on "absence == default"
|
|
5
|
+
* so reviewers don't have to re-derive the analysis.
|
|
6
|
+
*/
|
|
7
|
+
import type { CaptureMatch, ParsedImport, Scope, ScopeId, ScopeTree, TypeRef } from '../../../../_shared/index.js';
|
|
8
|
+
/** Swift uses the central extractor's "innermost enclosing scope" default
|
|
9
|
+
* for most declarations: class-body declarations attach to the Class
|
|
10
|
+
* scope, function-body locals to the Function scope.
|
|
11
|
+
*
|
|
12
|
+
* Exception: **function return-type bindings** (`@type-binding.return`)
|
|
13
|
+
* must hoist to the Module scope. The default auto-hoist promotes only
|
|
14
|
+
* one level (Function → its parent). For top-level functions the parent
|
|
15
|
+
* is already the Module so the default works, but for methods declared
|
|
16
|
+
* inside a class/struct/extension the parent is the Class — the return
|
|
17
|
+
* binding would get stuck there, invisible to:
|
|
18
|
+
* - chain-follow's parent-chain walk (`let u = getUser(); u.save()`);
|
|
19
|
+
* - cross-file `propagateImportedReturnTypes`, which reads only
|
|
20
|
+
* `sourceModule.typeBindings`.
|
|
21
|
+
* Walking to Module restores both. Mirrors `csharpBindingScopeFor`. */
|
|
22
|
+
export declare function swiftBindingScopeFor(decl: CaptureMatch, innermost: Scope, tree: ScopeTree): ScopeId | null;
|
|
23
|
+
/** Swift imports only appear at file (module) scope and bring a whole
|
|
24
|
+
* module into view there. Attach the import to the Module scope; for any
|
|
25
|
+
* other innermost scope delegate to the default (returns null). */
|
|
26
|
+
export declare function swiftImportOwningScope(_imp: ParsedImport, innermost: Scope, _tree: ScopeTree): ScopeId | null;
|
|
27
|
+
/** Look up `self` (or `super`) in the function scope's type bindings.
|
|
28
|
+
*
|
|
29
|
+
* `self` / `super` are synthesized as type bindings on instance methods
|
|
30
|
+
* during capture emission (`receiver-binding.ts`) — `self` for every
|
|
31
|
+
* method inside a class/struct/extension/protocol body, and `super`
|
|
32
|
+
* additionally for methods of a class with a declared superclass. This
|
|
33
|
+
* hook returns a non-null `TypeRef` for instance-method bodies.
|
|
34
|
+
*
|
|
35
|
+
* Returns `null` for static methods (no `self` synthesized), free
|
|
36
|
+
* functions (no enclosing type), and non-Function scopes. */
|
|
37
|
+
export declare function swiftReceiverBinding(functionScope: Scope): TypeRef | null;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trivial / no-op-ish hooks for the Swift provider. Kept together
|
|
3
|
+
* because each is a few lines and they share a theme: they make the
|
|
4
|
+
* provider's choice explicit rather than relying on "absence == default"
|
|
5
|
+
* so reviewers don't have to re-derive the analysis.
|
|
6
|
+
*/
|
|
7
|
+
// ─── bindingScopeFor ──────────────────────────────────────────────────────
|
|
8
|
+
/** Swift uses the central extractor's "innermost enclosing scope" default
|
|
9
|
+
* for most declarations: class-body declarations attach to the Class
|
|
10
|
+
* scope, function-body locals to the Function scope.
|
|
11
|
+
*
|
|
12
|
+
* Exception: **function return-type bindings** (`@type-binding.return`)
|
|
13
|
+
* must hoist to the Module scope. The default auto-hoist promotes only
|
|
14
|
+
* one level (Function → its parent). For top-level functions the parent
|
|
15
|
+
* is already the Module so the default works, but for methods declared
|
|
16
|
+
* inside a class/struct/extension the parent is the Class — the return
|
|
17
|
+
* binding would get stuck there, invisible to:
|
|
18
|
+
* - chain-follow's parent-chain walk (`let u = getUser(); u.save()`);
|
|
19
|
+
* - cross-file `propagateImportedReturnTypes`, which reads only
|
|
20
|
+
* `sourceModule.typeBindings`.
|
|
21
|
+
* Walking to Module restores both. Mirrors `csharpBindingScopeFor`. */
|
|
22
|
+
export function swiftBindingScopeFor(decl, innermost, tree) {
|
|
23
|
+
if (decl['@type-binding.return'] !== undefined) {
|
|
24
|
+
let cur = innermost;
|
|
25
|
+
while (cur !== undefined && cur.kind !== 'Module') {
|
|
26
|
+
const parentId = cur.parent ?? null;
|
|
27
|
+
if (parentId === null)
|
|
28
|
+
break;
|
|
29
|
+
cur = tree.getScope(parentId);
|
|
30
|
+
}
|
|
31
|
+
if (cur !== undefined && cur.kind === 'Module')
|
|
32
|
+
return cur.id;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
// ─── importOwningScope ────────────────────────────────────────────────────
|
|
37
|
+
/** Swift imports only appear at file (module) scope and bring a whole
|
|
38
|
+
* module into view there. Attach the import to the Module scope; for any
|
|
39
|
+
* other innermost scope delegate to the default (returns null). */
|
|
40
|
+
export function swiftImportOwningScope(_imp, innermost, _tree) {
|
|
41
|
+
if (innermost.kind === 'Module')
|
|
42
|
+
return innermost.id;
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
// ─── receiverBinding ──────────────────────────────────────────────────────
|
|
46
|
+
/** Look up `self` (or `super`) in the function scope's type bindings.
|
|
47
|
+
*
|
|
48
|
+
* `self` / `super` are synthesized as type bindings on instance methods
|
|
49
|
+
* during capture emission (`receiver-binding.ts`) — `self` for every
|
|
50
|
+
* method inside a class/struct/extension/protocol body, and `super`
|
|
51
|
+
* additionally for methods of a class with a declared superclass. This
|
|
52
|
+
* hook returns a non-null `TypeRef` for instance-method bodies.
|
|
53
|
+
*
|
|
54
|
+
* Returns `null` for static methods (no `self` synthesized), free
|
|
55
|
+
* functions (no enclosing type), and non-Function scopes. */
|
|
56
|
+
export function swiftReceiverBinding(functionScope) {
|
|
57
|
+
if (functionScope.kind !== 'Function')
|
|
58
|
+
return null;
|
|
59
|
+
return functionScope.typeBindings.get('self') ?? functionScope.typeBindings.get('super') ?? null;
|
|
60
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift SPM-target file grouping for the registry-primary same-module
|
|
3
|
+
* hooks (`implicit-imports.ts`, `target-siblings.ts`,
|
|
4
|
+
* `sibling-type-bindings.ts`).
|
|
5
|
+
*
|
|
6
|
+
* A Swift module is an SPM *target* — a directory *subtree*
|
|
7
|
+
* (`Sources/<Target>/…`), not a single immediate directory. Grouping by
|
|
8
|
+
* the immediate containing directory (the prior `containingDir` proxy)
|
|
9
|
+
* drops cross-directory same-module edges and can mis-resolve a
|
|
10
|
+
* constructor call to a wrong same-simple-named type in another target.
|
|
11
|
+
*
|
|
12
|
+
* This module duplicates the legacy `groupSwiftFilesByTarget`
|
|
13
|
+
* (`languages/swift.ts`) semantics **verbatim** so the registry-primary
|
|
14
|
+
* path matches legacy SPM-subtree grouping without touching the legacy
|
|
15
|
+
* pipeline (hard constraint: legacy stays byte-identical). The SPM target
|
|
16
|
+
* map is threaded in via the `resolutionConfig` channel
|
|
17
|
+
* (`loadSwiftPackageConfig` → `resolutionConfig` → these hooks); see
|
|
18
|
+
* `scope-resolver.ts` and `scope-resolution/pipeline/run.ts`.
|
|
19
|
+
*
|
|
20
|
+
* NOTE: This intentionally differs from the import-config module's
|
|
21
|
+
* leading-`startsWith` (`import-resolvers/configs/swift.ts`): that module
|
|
22
|
+
* fans a file out to EVERY matching target (a nested file can belong to
|
|
23
|
+
* multiple configured target dirs there), whereas legacy module grouping
|
|
24
|
+
* assigns each file to the FIRST matching target only (legacy `break`s) —
|
|
25
|
+
* one bucket per file. Do not copy the import-config behavior here.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Group `items` by SPM target subtree, replicating legacy
|
|
29
|
+
* `groupSwiftFilesByTarget` semantics exactly:
|
|
30
|
+
*
|
|
31
|
+
* - `targets` null/empty (no scanned source dir found) → ALL items go to
|
|
32
|
+
* a single `__default__` bucket (single-Xcode-project assumption).
|
|
33
|
+
* - Otherwise: a file matches a target when its normalized path either
|
|
34
|
+
* starts with `<targetDir>/` (`indexOf === 0`) OR contains it at a `/`
|
|
35
|
+
* boundary (`norm[idx - 1] === '/'`). Each file is assigned to the
|
|
36
|
+
* FIRST matching target only (one bucket per file, no fan-out).
|
|
37
|
+
* - Files matching no target fall into the `__default__` bucket.
|
|
38
|
+
*
|
|
39
|
+
* `targets` is `name → directory` (the `SwiftPackageConfig.targets` map).
|
|
40
|
+
*/
|
|
41
|
+
export declare function groupSwiftFilesBySpmTarget<T>(items: readonly T[], getPath: (item: T) => string, targets: ReadonlyMap<string, string> | null): Map<string, T[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Duck-type the opaque `resolutionConfig` (loaded by
|
|
44
|
+
* `loadSwiftPackageConfig` and threaded through the orchestrator) into the
|
|
45
|
+
* SPM `targets` map, or `null` when no Swift package config is present.
|
|
46
|
+
*
|
|
47
|
+
* Uses structural duck-typing (no `instanceof`) because the value crosses
|
|
48
|
+
* the `unknown`-typed `resolutionConfig` channel and may be `null`,
|
|
49
|
+
* `undefined`, or a config object whose `targets` is a `Map<string,string>`.
|
|
50
|
+
*/
|
|
51
|
+
export declare function coerceSwiftTargets(resolutionConfig: unknown): ReadonlyMap<string, string> | null;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift SPM-target file grouping for the registry-primary same-module
|
|
3
|
+
* hooks (`implicit-imports.ts`, `target-siblings.ts`,
|
|
4
|
+
* `sibling-type-bindings.ts`).
|
|
5
|
+
*
|
|
6
|
+
* A Swift module is an SPM *target* — a directory *subtree*
|
|
7
|
+
* (`Sources/<Target>/…`), not a single immediate directory. Grouping by
|
|
8
|
+
* the immediate containing directory (the prior `containingDir` proxy)
|
|
9
|
+
* drops cross-directory same-module edges and can mis-resolve a
|
|
10
|
+
* constructor call to a wrong same-simple-named type in another target.
|
|
11
|
+
*
|
|
12
|
+
* This module duplicates the legacy `groupSwiftFilesByTarget`
|
|
13
|
+
* (`languages/swift.ts`) semantics **verbatim** so the registry-primary
|
|
14
|
+
* path matches legacy SPM-subtree grouping without touching the legacy
|
|
15
|
+
* pipeline (hard constraint: legacy stays byte-identical). The SPM target
|
|
16
|
+
* map is threaded in via the `resolutionConfig` channel
|
|
17
|
+
* (`loadSwiftPackageConfig` → `resolutionConfig` → these hooks); see
|
|
18
|
+
* `scope-resolver.ts` and `scope-resolution/pipeline/run.ts`.
|
|
19
|
+
*
|
|
20
|
+
* NOTE: This intentionally differs from the import-config module's
|
|
21
|
+
* leading-`startsWith` (`import-resolvers/configs/swift.ts`): that module
|
|
22
|
+
* fans a file out to EVERY matching target (a nested file can belong to
|
|
23
|
+
* multiple configured target dirs there), whereas legacy module grouping
|
|
24
|
+
* assigns each file to the FIRST matching target only (legacy `break`s) —
|
|
25
|
+
* one bucket per file. Do not copy the import-config behavior here.
|
|
26
|
+
*/
|
|
27
|
+
const DEFAULT_TARGET = '__default__';
|
|
28
|
+
/**
|
|
29
|
+
* Group `items` by SPM target subtree, replicating legacy
|
|
30
|
+
* `groupSwiftFilesByTarget` semantics exactly:
|
|
31
|
+
*
|
|
32
|
+
* - `targets` null/empty (no scanned source dir found) → ALL items go to
|
|
33
|
+
* a single `__default__` bucket (single-Xcode-project assumption).
|
|
34
|
+
* - Otherwise: a file matches a target when its normalized path either
|
|
35
|
+
* starts with `<targetDir>/` (`indexOf === 0`) OR contains it at a `/`
|
|
36
|
+
* boundary (`norm[idx - 1] === '/'`). Each file is assigned to the
|
|
37
|
+
* FIRST matching target only (one bucket per file, no fan-out).
|
|
38
|
+
* - Files matching no target fall into the `__default__` bucket.
|
|
39
|
+
*
|
|
40
|
+
* `targets` is `name → directory` (the `SwiftPackageConfig.targets` map).
|
|
41
|
+
*/
|
|
42
|
+
export function groupSwiftFilesBySpmTarget(items, getPath, targets) {
|
|
43
|
+
// No SPM config -> single target (common for Xcode projects).
|
|
44
|
+
if (targets === null || targets.size === 0) {
|
|
45
|
+
return new Map([[DEFAULT_TARGET, [...items]]]);
|
|
46
|
+
}
|
|
47
|
+
// Pre-convert target dirs to normalized prefix format once.
|
|
48
|
+
const targetPrefixes = [...targets.entries()].map(([name, dir]) => ({
|
|
49
|
+
name,
|
|
50
|
+
prefix: dir.replace(/\\/g, '/') + '/',
|
|
51
|
+
}));
|
|
52
|
+
const groups = new Map();
|
|
53
|
+
const defaultGroup = [];
|
|
54
|
+
for (const item of items) {
|
|
55
|
+
const rawPath = getPath(item);
|
|
56
|
+
const normalized = rawPath.includes('\\') ? rawPath.replace(/\\/g, '/') : rawPath;
|
|
57
|
+
let assigned = false;
|
|
58
|
+
for (const { name, prefix } of targetPrefixes) {
|
|
59
|
+
const idx = normalized.indexOf(prefix);
|
|
60
|
+
if (idx === 0 || (idx > 0 && normalized[idx - 1] === '/')) {
|
|
61
|
+
let group = groups.get(name);
|
|
62
|
+
if (group === undefined) {
|
|
63
|
+
group = [];
|
|
64
|
+
groups.set(name, group);
|
|
65
|
+
}
|
|
66
|
+
group.push(item);
|
|
67
|
+
assigned = true;
|
|
68
|
+
break; // FIRST match only — one bucket per file, no fan-out.
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!assigned)
|
|
72
|
+
defaultGroup.push(item);
|
|
73
|
+
}
|
|
74
|
+
if (defaultGroup.length > 0)
|
|
75
|
+
groups.set(DEFAULT_TARGET, defaultGroup);
|
|
76
|
+
return groups;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Duck-type the opaque `resolutionConfig` (loaded by
|
|
80
|
+
* `loadSwiftPackageConfig` and threaded through the orchestrator) into the
|
|
81
|
+
* SPM `targets` map, or `null` when no Swift package config is present.
|
|
82
|
+
*
|
|
83
|
+
* Uses structural duck-typing (no `instanceof`) because the value crosses
|
|
84
|
+
* the `unknown`-typed `resolutionConfig` channel and may be `null`,
|
|
85
|
+
* `undefined`, or a config object whose `targets` is a `Map<string,string>`.
|
|
86
|
+
*/
|
|
87
|
+
export function coerceSwiftTargets(resolutionConfig) {
|
|
88
|
+
const config = resolutionConfig;
|
|
89
|
+
if (config != null && config.targets instanceof Map) {
|
|
90
|
+
return config.targets;
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift same-module (SPM target) implicit visibility for the
|
|
3
|
+
* `populateNamespaceSiblings` hook.
|
|
4
|
+
*
|
|
5
|
+
* Swift gives every file in a module access to every other file's
|
|
6
|
+
* top-level declarations WITHOUT any `import` statement (whole-module
|
|
7
|
+
* visibility). This is the Swift analogue of Go's same-package sibling
|
|
8
|
+
* visibility — `populateGoPackageSiblings` is the template.
|
|
9
|
+
*
|
|
10
|
+
* Module identity: Swift has no in-source `package X` marker. The SPM
|
|
11
|
+
* target is a directory subtree (`Sources/<Target>/…`). Module membership
|
|
12
|
+
* is threaded in via the SPM target map (`ctx.resolutionConfig` →
|
|
13
|
+
* `coerceSwiftTargets`) and grouped by `groupSwiftFilesBySpmTarget`,
|
|
14
|
+
* replicating legacy `wireSwiftImplicitImports`'s `groupSwiftFilesByTarget`:
|
|
15
|
+
* files are grouped by SPM target subtree when a package config is present,
|
|
16
|
+
* else ALL Swift files form one module (`__default__`,
|
|
17
|
+
* single-Xcode-project assumption). Every `.swift` file in the same target
|
|
18
|
+
* sees its siblings' top-level defs.
|
|
19
|
+
*
|
|
20
|
+
* Bindings are added through the append-only `bindingAugmentations`
|
|
21
|
+
* channel (Contract Invariant I8) with `origin: 'namespace'`, exactly
|
|
22
|
+
* like the Go implementation — `indexes.bindings` is frozen post-
|
|
23
|
+
* finalize and must not be mutated.
|
|
24
|
+
*/
|
|
25
|
+
import type { ParsedFile } from '../../../../_shared/index.js';
|
|
26
|
+
import type { ScopeResolutionIndexes } from '../../model/scope-resolution-indexes.js';
|
|
27
|
+
export declare function populateSwiftTargetSiblings(parsedFiles: readonly ParsedFile[], indexes: ScopeResolutionIndexes, ctx: {
|
|
28
|
+
readonly fileContents: ReadonlyMap<string, string>;
|
|
29
|
+
readonly resolutionConfig?: unknown;
|
|
30
|
+
}): void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift same-module (SPM target) implicit visibility for the
|
|
3
|
+
* `populateNamespaceSiblings` hook.
|
|
4
|
+
*
|
|
5
|
+
* Swift gives every file in a module access to every other file's
|
|
6
|
+
* top-level declarations WITHOUT any `import` statement (whole-module
|
|
7
|
+
* visibility). This is the Swift analogue of Go's same-package sibling
|
|
8
|
+
* visibility — `populateGoPackageSiblings` is the template.
|
|
9
|
+
*
|
|
10
|
+
* Module identity: Swift has no in-source `package X` marker. The SPM
|
|
11
|
+
* target is a directory subtree (`Sources/<Target>/…`). Module membership
|
|
12
|
+
* is threaded in via the SPM target map (`ctx.resolutionConfig` →
|
|
13
|
+
* `coerceSwiftTargets`) and grouped by `groupSwiftFilesBySpmTarget`,
|
|
14
|
+
* replicating legacy `wireSwiftImplicitImports`'s `groupSwiftFilesByTarget`:
|
|
15
|
+
* files are grouped by SPM target subtree when a package config is present,
|
|
16
|
+
* else ALL Swift files form one module (`__default__`,
|
|
17
|
+
* single-Xcode-project assumption). Every `.swift` file in the same target
|
|
18
|
+
* sees its siblings' top-level defs.
|
|
19
|
+
*
|
|
20
|
+
* Bindings are added through the append-only `bindingAugmentations`
|
|
21
|
+
* channel (Contract Invariant I8) with `origin: 'namespace'`, exactly
|
|
22
|
+
* like the Go implementation — `indexes.bindings` is frozen post-
|
|
23
|
+
* finalize and must not be mutated.
|
|
24
|
+
*/
|
|
25
|
+
import { coerceSwiftTargets, groupSwiftFilesBySpmTarget } from './target-grouping.js';
|
|
26
|
+
export function populateSwiftTargetSiblings(parsedFiles, indexes, ctx) {
|
|
27
|
+
// Group files by SPM target subtree (the module). No-source-dir → all
|
|
28
|
+
// files in one `__default__` bucket.
|
|
29
|
+
const targets = coerceSwiftTargets(ctx.resolutionConfig);
|
|
30
|
+
const filesByTarget = groupSwiftFilesBySpmTarget(parsedFiles, (parsed) => parsed.filePath, targets);
|
|
31
|
+
const augmentations = indexes.bindingAugmentations;
|
|
32
|
+
for (const [, group] of filesByTarget) {
|
|
33
|
+
if (group.length < 2)
|
|
34
|
+
continue; // no siblings to share
|
|
35
|
+
const siblings = group.map((parsed) => ({
|
|
36
|
+
filePath: parsed.filePath,
|
|
37
|
+
defs: [...parsed.localDefs],
|
|
38
|
+
}));
|
|
39
|
+
for (const target of siblings) {
|
|
40
|
+
for (const receiver of siblings) {
|
|
41
|
+
if (receiver.filePath === target.filePath)
|
|
42
|
+
continue; // no self-reference
|
|
43
|
+
const receiverModule = indexes.moduleScopes.byFilePath.get(receiver.filePath);
|
|
44
|
+
if (receiverModule === undefined)
|
|
45
|
+
continue;
|
|
46
|
+
for (const def of target.defs) {
|
|
47
|
+
const name = def.qualifiedName?.split('.').pop() ?? def.qualifiedName ?? '';
|
|
48
|
+
if (name === '')
|
|
49
|
+
continue;
|
|
50
|
+
const bucket = getAugmentationBucket(augmentations, receiverModule, name);
|
|
51
|
+
if (bucket.some((b) => b.def.nodeId === def.nodeId))
|
|
52
|
+
continue;
|
|
53
|
+
bucket.push({ def, origin: 'namespace' });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function getAugmentationBucket(augmentations, scopeId, name) {
|
|
60
|
+
let scopeBindings = augmentations.get(scopeId);
|
|
61
|
+
if (scopeBindings === undefined) {
|
|
62
|
+
scopeBindings = new Map();
|
|
63
|
+
augmentations.set(scopeId, scopeBindings);
|
|
64
|
+
}
|
|
65
|
+
let bucketArr = scopeBindings.get(name);
|
|
66
|
+
if (bucketArr === undefined) {
|
|
67
|
+
bucketArr = [];
|
|
68
|
+
scopeBindings.set(name, bucketArr);
|
|
69
|
+
}
|
|
70
|
+
return bucketArr;
|
|
71
|
+
}
|
|
@@ -3,10 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Assembles all Swift-specific ingestion capabilities into a single
|
|
5
5
|
* LanguageProvider, following the Strategy pattern used by the pipeline.
|
|
6
|
-
*
|
|
7
|
-
* Key Swift traits:
|
|
8
|
-
* - importSemantics: 'wildcard-leaf' (Swift imports entire modules)
|
|
9
|
-
* - heritageDefaultEdge: 'IMPLEMENTS' (protocols are more common than class inheritance)
|
|
10
|
-
* - implicitImportWirer: all files in the same SPM target see each other
|
|
11
6
|
*/
|
|
12
7
|
export declare const swiftProvider: import("../language-provider.js").LanguageProvider;
|
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Assembles all Swift-specific ingestion capabilities into a single
|
|
5
5
|
* LanguageProvider, following the Strategy pattern used by the pipeline.
|
|
6
|
-
*
|
|
7
|
-
* Key Swift traits:
|
|
8
|
-
* - importSemantics: 'wildcard-leaf' (Swift imports entire modules)
|
|
9
|
-
* - heritageDefaultEdge: 'IMPLEMENTS' (protocols are more common than class inheritance)
|
|
10
|
-
* - implicitImportWirer: all files in the same SPM target see each other
|
|
11
6
|
*/
|
|
12
7
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
13
8
|
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
@@ -26,84 +21,7 @@ import { createVariableExtractor } from '../variable-extractors/generic.js';
|
|
|
26
21
|
import { swiftVariableConfig } from '../variable-extractors/configs/swift.js';
|
|
27
22
|
import { createCallExtractor } from '../call-extractors/generic.js';
|
|
28
23
|
import { swiftCallConfig } from '../call-extractors/configs/swift.js';
|
|
29
|
-
import {
|
|
30
|
-
/**
|
|
31
|
-
* Group Swift files by SPM target for implicit module visibility.
|
|
32
|
-
* If SwiftPackageConfig is available, use target -> directory mappings.
|
|
33
|
-
* Otherwise, group all Swift files under a single "default" target
|
|
34
|
-
* (assumes a single-module Xcode project).
|
|
35
|
-
*/
|
|
36
|
-
function groupSwiftFilesByTarget(swiftFiles, swiftPackageConfig) {
|
|
37
|
-
// No SPM config -> single target (common for Xcode projects)
|
|
38
|
-
if (!swiftPackageConfig || swiftPackageConfig.targets.size === 0) {
|
|
39
|
-
return new Map([['__default__', swiftFiles]]);
|
|
40
|
-
}
|
|
41
|
-
// Pre-convert target dirs to normalized prefix format once
|
|
42
|
-
const targets = [...swiftPackageConfig.targets.entries()].map(([name, dir]) => ({
|
|
43
|
-
name,
|
|
44
|
-
prefix: dir.replace(/\\/g, '/') + '/',
|
|
45
|
-
}));
|
|
46
|
-
const groups = new Map();
|
|
47
|
-
const defaultGroup = [];
|
|
48
|
-
for (const file of swiftFiles) {
|
|
49
|
-
const normalized = file.includes('\\') ? file.replace(/\\/g, '/') : file;
|
|
50
|
-
let assigned = false;
|
|
51
|
-
for (const { name, prefix } of targets) {
|
|
52
|
-
const idx = normalized.indexOf(prefix);
|
|
53
|
-
if (idx === 0 || (idx > 0 && normalized[idx - 1] === '/')) {
|
|
54
|
-
let group = groups.get(name);
|
|
55
|
-
if (!group) {
|
|
56
|
-
group = [];
|
|
57
|
-
groups.set(name, group);
|
|
58
|
-
}
|
|
59
|
-
group.push(file);
|
|
60
|
-
assigned = true;
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (!assigned)
|
|
65
|
-
defaultGroup.push(file);
|
|
66
|
-
}
|
|
67
|
-
if (defaultGroup.length > 0)
|
|
68
|
-
groups.set('__default__', defaultGroup);
|
|
69
|
-
return groups;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Wire implicit inter-file imports for Swift.
|
|
73
|
-
* All files in the same SPM target see each other (full module visibility).
|
|
74
|
-
* Two fast paths avoid unnecessary work:
|
|
75
|
-
* 1. No existing imports for src -> emit all (m-1) edges without Set.has checks
|
|
76
|
-
* 2. Existing imports present -> skip already-connected pairs
|
|
77
|
-
*/
|
|
78
|
-
function wireSwiftImplicitImports(swiftFiles, importMap, addImportEdge, projectConfig) {
|
|
79
|
-
const configs = projectConfig;
|
|
80
|
-
const targetGroups = groupSwiftFilesByTarget(swiftFiles, configs?.swiftPackageConfig ?? null);
|
|
81
|
-
for (const group of targetGroups.values()) {
|
|
82
|
-
const m = group.length;
|
|
83
|
-
if (m <= 1)
|
|
84
|
-
continue;
|
|
85
|
-
// All-pairs implicit edges: O(m²) is inherent for full module visibility.
|
|
86
|
-
for (let i = 0; i < m; i++) {
|
|
87
|
-
const src = group[i];
|
|
88
|
-
const existing = importMap.get(src);
|
|
89
|
-
if (!existing || existing.size === 0) {
|
|
90
|
-
// Fast path: no prior imports — emit all peers unconditionally
|
|
91
|
-
for (let j = 0; j < m; j++) {
|
|
92
|
-
if (i !== j)
|
|
93
|
-
addImportEdge(src, group[j]);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
// Dedup path: skip already-connected pairs
|
|
98
|
-
for (let j = 0; j < m; j++) {
|
|
99
|
-
if (i !== j && !existing.has(group[j])) {
|
|
100
|
-
addImportEdge(src, group[j]);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
24
|
+
import { emitSwiftScopeCaptures, interpretSwiftImport, interpretSwiftTypeBinding, swiftBindingScopeFor, swiftImportOwningScope, swiftReceiverBinding, swiftMergeBindings, swiftArityCompatibility, } from './swift/index.js';
|
|
107
25
|
/** Swift init/deinit declarations have special names and Constructor label. */
|
|
108
26
|
const swiftExtractFunctionName = (node) => {
|
|
109
27
|
if (node.type === 'init_declaration')
|
|
@@ -295,8 +213,6 @@ export const swiftProvider = defineLanguage({
|
|
|
295
213
|
typeConfig: swiftConfig,
|
|
296
214
|
exportChecker: swiftExportChecker,
|
|
297
215
|
importResolver: createImportResolver(swiftImportConfig),
|
|
298
|
-
importSemantics: 'wildcard-leaf',
|
|
299
|
-
heritageDefaultEdge: 'IMPLEMENTS',
|
|
300
216
|
callExtractor: createCallExtractor(swiftCallConfig),
|
|
301
217
|
fieldExtractor: createFieldExtractor(swiftFieldConfig),
|
|
302
218
|
methodExtractor: createMethodExtractor({
|
|
@@ -305,8 +221,16 @@ export const swiftProvider = defineLanguage({
|
|
|
305
221
|
}),
|
|
306
222
|
variableExtractor: createVariableExtractor(swiftVariableConfig),
|
|
307
223
|
classExtractor: createClassExtractor(swiftClassConfig),
|
|
308
|
-
heritageExtractor: createHeritageExtractor(SupportedLanguages.Swift),
|
|
309
|
-
implicitImportWirer: wireSwiftImplicitImports,
|
|
310
224
|
orderSameNameTypeCandidates: orderSwiftSameNameTypeCandidates,
|
|
311
225
|
builtInNames: BUILT_INS,
|
|
226
|
+
// ── Scope-based resolution hooks (RFC #909 Ring 3, issue #937). See
|
|
227
|
+
// languages/swift/ for the implementations. ──────────────────────
|
|
228
|
+
emitScopeCaptures: emitSwiftScopeCaptures,
|
|
229
|
+
interpretImport: interpretSwiftImport,
|
|
230
|
+
interpretTypeBinding: interpretSwiftTypeBinding,
|
|
231
|
+
bindingScopeFor: swiftBindingScopeFor,
|
|
232
|
+
importOwningScope: swiftImportOwningScope,
|
|
233
|
+
receiverBinding: swiftReceiverBinding,
|
|
234
|
+
mergeBindings: (_scope, bindings) => swiftMergeBindings(bindings),
|
|
235
|
+
arityCompatibility: swiftArityCompatibility,
|
|
312
236
|
});
|