gitnexus 1.6.6-rc.99 → 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 +162 -3
- 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,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter query for Swift scope captures (RFC §5.1).
|
|
3
|
+
*
|
|
4
|
+
* Captures the structural skeleton the generic scope-resolution
|
|
5
|
+
* pipeline consumes: scopes (module/class/function), declarations
|
|
6
|
+
* (class-likes, methods, init, properties), imports, type bindings
|
|
7
|
+
* (parameter annotations, property/field annotations, constructor
|
|
8
|
+
* inference, receiver self), and references (call sites, member calls).
|
|
9
|
+
*
|
|
10
|
+
* Swift specifics that shape this query (all verified against
|
|
11
|
+
* tree-sitter-swift 0.7.1 live s-expressions):
|
|
12
|
+
*
|
|
13
|
+
* - `class`, `struct`, AND `extension` all parse to a single node
|
|
14
|
+
* type `class_declaration`. They are distinguished by the `name:`
|
|
15
|
+
* field node type: class/struct name is a bare `(type_identifier)`,
|
|
16
|
+
* while an extension's name field wraps the extended type in a
|
|
17
|
+
* `(user_type (type_identifier))`. The capture below grabs all
|
|
18
|
+
* three under `@scope.class` + `@declaration.class`; the captures
|
|
19
|
+
* orchestrator (`captures.ts`) re-tags extensions via the
|
|
20
|
+
* user_type discriminator so extension members hoist onto the
|
|
21
|
+
* extended type.
|
|
22
|
+
* - `protocol_declaration` is its own node; its bodyless method
|
|
23
|
+
* requirements are `protocol_function_declaration` (NOT
|
|
24
|
+
* `function_declaration`).
|
|
25
|
+
* - `init_declaration` has no `name:` field — identity is the `init`
|
|
26
|
+
* keyword. The captures layer synthesizes its `@declaration.name`.
|
|
27
|
+
* - Inside a `parameter`, BOTH the label and the type use the field
|
|
28
|
+
* name `name:` — disambiguate by child node type (simple_identifier
|
|
29
|
+
* = label, user_type = type). Parameter type bindings are therefore
|
|
30
|
+
* synthesized in `captures.ts`, not matched here.
|
|
31
|
+
* - A labeled call argument wraps its label in a dedicated
|
|
32
|
+
* `value_argument_label` node.
|
|
33
|
+
* - `self` is its own node `self_expression`; a `self.member()` call
|
|
34
|
+
* is `call_expression > navigation_expression(target: self_expression,
|
|
35
|
+
* suffix: navigation_suffix > simple_identifier)`.
|
|
36
|
+
* - `import_declaration` carries the module path as an `(identifier
|
|
37
|
+
* (simple_identifier)+)` — one `simple_identifier` per dotted
|
|
38
|
+
* segment. `@testable` and other attributes surface as a leading
|
|
39
|
+
* `(modifiers (attribute (user_type (type_identifier))))`.
|
|
40
|
+
*
|
|
41
|
+
* Exposes lazy `Parser` and `Query` singletons so callers don't pay
|
|
42
|
+
* tree-sitter init cost per file.
|
|
43
|
+
*/
|
|
44
|
+
import Parser from 'tree-sitter';
|
|
45
|
+
import Swift from 'tree-sitter-swift';
|
|
46
|
+
const SWIFT_SCOPE_QUERY = `
|
|
47
|
+
;; ── Scopes ──────────────────────────────────────────────────────────
|
|
48
|
+
(source_file) @scope.module
|
|
49
|
+
|
|
50
|
+
;; class / struct / extension all parse to class_declaration; the
|
|
51
|
+
;; captures orchestrator splits extensions out via the user_type
|
|
52
|
+
;; name discriminator.
|
|
53
|
+
(class_declaration) @scope.class
|
|
54
|
+
(protocol_declaration) @scope.class
|
|
55
|
+
|
|
56
|
+
(function_declaration) @scope.function
|
|
57
|
+
(protocol_function_declaration) @scope.function
|
|
58
|
+
(init_declaration) @scope.function
|
|
59
|
+
(deinit_declaration) @scope.function
|
|
60
|
+
|
|
61
|
+
;; ── Declarations — types ────────────────────────────────────────────
|
|
62
|
+
;; class / struct: name is a bare type_identifier.
|
|
63
|
+
(class_declaration
|
|
64
|
+
name: (type_identifier) @declaration.name) @declaration.class
|
|
65
|
+
|
|
66
|
+
;; extension: name is (user_type (type_identifier)). Captured separately
|
|
67
|
+
;; so captures.ts can re-tag it as an extension of the wrapped type.
|
|
68
|
+
(class_declaration
|
|
69
|
+
name: (user_type) @declaration.name) @declaration.extension
|
|
70
|
+
|
|
71
|
+
(protocol_declaration
|
|
72
|
+
name: (type_identifier) @declaration.name) @declaration.interface
|
|
73
|
+
|
|
74
|
+
;; ── Declarations — methods / init / properties ──────────────────────
|
|
75
|
+
(function_declaration
|
|
76
|
+
name: (simple_identifier) @declaration.name) @declaration.method
|
|
77
|
+
|
|
78
|
+
(protocol_function_declaration
|
|
79
|
+
name: (simple_identifier) @declaration.name) @declaration.method
|
|
80
|
+
|
|
81
|
+
;; init has no name field — captures.ts synthesizes @declaration.name = "init".
|
|
82
|
+
(init_declaration) @declaration.constructor
|
|
83
|
+
|
|
84
|
+
(property_declaration
|
|
85
|
+
name: (pattern
|
|
86
|
+
bound_identifier: (simple_identifier) @declaration.name)) @declaration.property
|
|
87
|
+
|
|
88
|
+
;; ── Imports ─────────────────────────────────────────────────────────
|
|
89
|
+
;; Single anchor per import; the captures layer decomposes the module
|
|
90
|
+
;; path (and detects @testable) into @import.kind/source/name markers.
|
|
91
|
+
(import_declaration) @import.statement
|
|
92
|
+
|
|
93
|
+
;; ── Type bindings — property annotations: \`var owner: Owner\` ─────────
|
|
94
|
+
(property_declaration
|
|
95
|
+
name: (pattern
|
|
96
|
+
bound_identifier: (simple_identifier) @type-binding.name)
|
|
97
|
+
(type_annotation
|
|
98
|
+
(user_type (type_identifier) @type-binding.type))) @type-binding.annotation
|
|
99
|
+
|
|
100
|
+
;; ── Type bindings — stored / local-var constructor inference:
|
|
101
|
+
;; \`let p = Product(...)\` (constructor) and \`let u = getUser()\`
|
|
102
|
+
;; (free-call result; chain-follow resolves getUser → its return type).
|
|
103
|
+
;; property_declaration is the node for both class-level stored
|
|
104
|
+
;; properties AND let/var inside a function body. ───────────────────
|
|
105
|
+
(property_declaration
|
|
106
|
+
name: (pattern
|
|
107
|
+
bound_identifier: (simple_identifier) @type-binding.name)
|
|
108
|
+
value: (call_expression
|
|
109
|
+
(simple_identifier) @type-binding.type)) @type-binding.constructor
|
|
110
|
+
|
|
111
|
+
;; \`let u = await fetchUser()\` — unwrap the await wrapper to the call.
|
|
112
|
+
(property_declaration
|
|
113
|
+
name: (pattern
|
|
114
|
+
bound_identifier: (simple_identifier) @type-binding.name)
|
|
115
|
+
value: (await_expression
|
|
116
|
+
(call_expression
|
|
117
|
+
(simple_identifier) @type-binding.type))) @type-binding.constructor
|
|
118
|
+
|
|
119
|
+
;; \`let r = try parseRepo()\` — unwrap the try wrapper to the call.
|
|
120
|
+
(property_declaration
|
|
121
|
+
name: (pattern
|
|
122
|
+
bound_identifier: (simple_identifier) @type-binding.name)
|
|
123
|
+
value: (try_expression
|
|
124
|
+
(call_expression
|
|
125
|
+
(simple_identifier) @type-binding.type))) @type-binding.constructor
|
|
126
|
+
|
|
127
|
+
;; ── Optional binding anchors: if-let / guard-let. In tree-sitter-swift
|
|
128
|
+
;; 0.7.1 these are if_statement / guard_statement with a flat shape — a
|
|
129
|
+
;; \`bound_identifier:\` field for the name plus separate \`condition:\`
|
|
130
|
+
;; children (one of which is the bound value expression). A static .scm
|
|
131
|
+
;; pattern can't pair the name with the value across those sibling
|
|
132
|
+
;; condition fields, so we only ANCHOR the statement here and synthesize
|
|
133
|
+
;; the @type-binding.constructor in captures.ts (synthesizeOptionalBinding)
|
|
134
|
+
;; by walking the node. (A nonexistent if_let_binding node type would throw
|
|
135
|
+
;; TSQueryErrorNodeType and break the WHOLE query — do not reintroduce it.)
|
|
136
|
+
(if_statement
|
|
137
|
+
bound_identifier: (simple_identifier)) @optional.binding
|
|
138
|
+
(guard_statement
|
|
139
|
+
bound_identifier: (simple_identifier)) @optional.binding
|
|
140
|
+
|
|
141
|
+
;; NOTE: parameter-type bindings (\`func f(u: User)\`) and function
|
|
142
|
+
;; return-type bindings (\`func getUser() -> User\`) are NOT matched by
|
|
143
|
+
;; tree-sitter patterns here. Swift's grammar reuses the SAME \`name:\`
|
|
144
|
+
;; field for the function name, each parameter's label, AND the return
|
|
145
|
+
;; type, so a two-\`name:\`-field query cross-assigns and produces garbage
|
|
146
|
+
;; bindings (\`save: save\`). They are synthesized in code instead —
|
|
147
|
+
;; \`captures.ts\` reads the function node via
|
|
148
|
+
;; \`swiftMethodConfig.extractParameters\` / \`extractReturnType\`, which
|
|
149
|
+
;; handle the grammar correctly. (Mirrors how receiver + arity are
|
|
150
|
+
;; synthesized rather than queried.)
|
|
151
|
+
|
|
152
|
+
;; ── References — field reads: \`u.address\` (member access that is NOT a
|
|
153
|
+
;; call callee or assignment LHS). Emit-side filtering in captures.ts
|
|
154
|
+
;; drops call targets and write LHS so only genuine reads emit ACCESSES.
|
|
155
|
+
(navigation_expression
|
|
156
|
+
target: (_) @reference.receiver
|
|
157
|
+
suffix: (navigation_suffix
|
|
158
|
+
suffix: (simple_identifier) @reference.name)) @reference.read.member
|
|
159
|
+
|
|
160
|
+
;; ── References — free calls: \`foo(...)\` ─────────────────────────────
|
|
161
|
+
(call_expression
|
|
162
|
+
(simple_identifier) @reference.name) @reference.call.free
|
|
163
|
+
|
|
164
|
+
;; ── References — member / method calls: \`obj.method(...)\` ───────────
|
|
165
|
+
;; navigation_expression carries the receiver (target:) and the member
|
|
166
|
+
;; (suffix > navigation_suffix > simple_identifier). \`self\` is a
|
|
167
|
+
;; self_expression; other receivers are simple_identifier / nested
|
|
168
|
+
;; navigation_expression — capture the whole target as @reference.receiver.
|
|
169
|
+
(call_expression
|
|
170
|
+
(navigation_expression
|
|
171
|
+
target: (_) @reference.receiver
|
|
172
|
+
suffix: (navigation_suffix
|
|
173
|
+
suffix: (simple_identifier) @reference.name))) @reference.call.member
|
|
174
|
+
|
|
175
|
+
;; ── References — constructor calls handled via @reference.call.free
|
|
176
|
+
;; (a Swift \`Foo(...)\` is a call_expression with a simple_identifier
|
|
177
|
+
;; callee; pickConstructorOrClass in free-call fallback targets the
|
|
178
|
+
;; type's Constructor). No separate object_creation node in Swift.
|
|
179
|
+
`;
|
|
180
|
+
let _parser = null;
|
|
181
|
+
let _query = null;
|
|
182
|
+
export function getSwiftParser() {
|
|
183
|
+
if (_parser === null) {
|
|
184
|
+
_parser = new Parser();
|
|
185
|
+
_parser.setLanguage(Swift);
|
|
186
|
+
}
|
|
187
|
+
return _parser;
|
|
188
|
+
}
|
|
189
|
+
export function getSwiftScopeQuery() {
|
|
190
|
+
if (_query === null) {
|
|
191
|
+
_query = new Parser.Query(Swift, SWIFT_SCOPE_QUERY);
|
|
192
|
+
}
|
|
193
|
+
return _query;
|
|
194
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synthesize `@type-binding.self` captures for Swift instance methods —
|
|
3
|
+
* one for `self` (always on non-static methods inside a type body) and
|
|
4
|
+
* optionally one for `super` (only on class methods when the enclosing
|
|
5
|
+
* class declares a superclass).
|
|
6
|
+
*
|
|
7
|
+
* Mirrors `languages/csharp/receiver-binding.ts`. tree-sitter can't
|
|
8
|
+
* express "the implicit receiver of a non-static member of a
|
|
9
|
+
* class/struct/extension/protocol" via a static `.scm` pattern because
|
|
10
|
+
* the receiver isn't a parameter — it's implicit. Synthesis in code is
|
|
11
|
+
* the same approach C#/Python use for `this`/`self`.
|
|
12
|
+
*
|
|
13
|
+
* Swift AST facts (tree-sitter-swift 0.7.1, verified):
|
|
14
|
+
* - class / struct / extension all parse to `class_declaration`. For
|
|
15
|
+
* class/struct the `name:` field is `(type_identifier)`; for an
|
|
16
|
+
* extension it is `(user_type (type_identifier))` wrapping the
|
|
17
|
+
* EXTENDED type — so `self` in an extension binds to the extended
|
|
18
|
+
* type, which is exactly what we want for method dispatch.
|
|
19
|
+
* - `protocol_declaration` has a `(type_identifier)` name.
|
|
20
|
+
* - the method body is the `body:` field (`function_body`); a bodyless
|
|
21
|
+
* `protocol_function_declaration` has no function scope to anchor to.
|
|
22
|
+
* - a superclass / conformance is an `(inheritance_specifier
|
|
23
|
+
* inherits_from: (user_type (type_identifier)))` child of the
|
|
24
|
+
* class_declaration.
|
|
25
|
+
*/
|
|
26
|
+
import type { CaptureMatch } from '../../../../_shared/index.js';
|
|
27
|
+
import { type SyntaxNode } from '../../utils/ast-helpers.js';
|
|
28
|
+
/**
|
|
29
|
+
* Build zero, one, or two `@type-binding.self` matches for `fnNode`:
|
|
30
|
+
* - `null`/`[]` if the function is free (no enclosing type), static, or
|
|
31
|
+
* the enclosing type has no resolvable name, or the function is
|
|
32
|
+
* bodyless (no scope to anchor to).
|
|
33
|
+
* - one match (`self`) for instance methods of a class/struct/extension/
|
|
34
|
+
* protocol.
|
|
35
|
+
* - two matches (`self` + `super`) only when the function lives in a
|
|
36
|
+
* `class` (keyword) declaration with a declared superclass.
|
|
37
|
+
*
|
|
38
|
+
* Caller must guarantee `FUNCTION_NODE_TYPES.has(fnNode.type)`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function synthesizeSwiftReceiverBinding(fnNode: SyntaxNode): CaptureMatch[];
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synthesize `@type-binding.self` captures for Swift instance methods —
|
|
3
|
+
* one for `self` (always on non-static methods inside a type body) and
|
|
4
|
+
* optionally one for `super` (only on class methods when the enclosing
|
|
5
|
+
* class declares a superclass).
|
|
6
|
+
*
|
|
7
|
+
* Mirrors `languages/csharp/receiver-binding.ts`. tree-sitter can't
|
|
8
|
+
* express "the implicit receiver of a non-static member of a
|
|
9
|
+
* class/struct/extension/protocol" via a static `.scm` pattern because
|
|
10
|
+
* the receiver isn't a parameter — it's implicit. Synthesis in code is
|
|
11
|
+
* the same approach C#/Python use for `this`/`self`.
|
|
12
|
+
*
|
|
13
|
+
* Swift AST facts (tree-sitter-swift 0.7.1, verified):
|
|
14
|
+
* - class / struct / extension all parse to `class_declaration`. For
|
|
15
|
+
* class/struct the `name:` field is `(type_identifier)`; for an
|
|
16
|
+
* extension it is `(user_type (type_identifier))` wrapping the
|
|
17
|
+
* EXTENDED type — so `self` in an extension binds to the extended
|
|
18
|
+
* type, which is exactly what we want for method dispatch.
|
|
19
|
+
* - `protocol_declaration` has a `(type_identifier)` name.
|
|
20
|
+
* - the method body is the `body:` field (`function_body`); a bodyless
|
|
21
|
+
* `protocol_function_declaration` has no function scope to anchor to.
|
|
22
|
+
* - a superclass / conformance is an `(inheritance_specifier
|
|
23
|
+
* inherits_from: (user_type (type_identifier)))` child of the
|
|
24
|
+
* class_declaration.
|
|
25
|
+
*/
|
|
26
|
+
import { nodeToCapture, syntheticCapture } from '../../utils/ast-helpers.js';
|
|
27
|
+
import { swiftQualifiedBaseTail } from './base-type.js';
|
|
28
|
+
import { swiftMethodConfig } from '../../method-extractors/configs/swift.js';
|
|
29
|
+
const TYPE_DECL_NODE_TYPES = new Set(['class_declaration', 'protocol_declaration']);
|
|
30
|
+
const FUNCTION_NODE_TYPES = new Set([
|
|
31
|
+
'function_declaration',
|
|
32
|
+
'init_declaration',
|
|
33
|
+
'deinit_declaration',
|
|
34
|
+
]);
|
|
35
|
+
/** Walk up to the enclosing type declaration (class/struct/extension/
|
|
36
|
+
* protocol). Nested local functions still see `self` from the enclosing
|
|
37
|
+
* type, so don't stop at function-like nodes. */
|
|
38
|
+
function findEnclosingTypeDeclaration(node) {
|
|
39
|
+
let cur = node.parent;
|
|
40
|
+
while (cur !== null) {
|
|
41
|
+
if (TYPE_DECL_NODE_TYPES.has(cur.type))
|
|
42
|
+
return cur;
|
|
43
|
+
cur = cur.parent;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
/** Bare type name of the enclosing type. class/struct → type_identifier
|
|
48
|
+
* text; extension → the wrapped user_type's identifier text; protocol →
|
|
49
|
+
* type_identifier text. */
|
|
50
|
+
function enclosingTypeName(typeNode) {
|
|
51
|
+
const nameNode = typeNode.childForFieldName('name');
|
|
52
|
+
if (nameNode === null)
|
|
53
|
+
return null;
|
|
54
|
+
if (nameNode.type === 'user_type') {
|
|
55
|
+
// extension Foo { } → name is (user_type (type_identifier)).
|
|
56
|
+
// extension Foo.Bar { } → (user_type (type_identifier Foo)
|
|
57
|
+
// (type_identifier Bar)); the extended type — and therefore `self` —
|
|
58
|
+
// is the TRAILING identifier `Bar` (lastNamedChild), not `Foo`. For a
|
|
59
|
+
// single identifier first === last, so this is unchanged.
|
|
60
|
+
const inner = nameNode.lastNamedChild;
|
|
61
|
+
return inner?.text ?? nameNode.text;
|
|
62
|
+
}
|
|
63
|
+
return nameNode.text;
|
|
64
|
+
}
|
|
65
|
+
/** Is this declaration a `class` (vs `struct`/`extension`)? Only classes
|
|
66
|
+
* have a meaningful `super`. Detected by the leading keyword token —
|
|
67
|
+
* class/struct/extension share the `class_declaration` node type. */
|
|
68
|
+
function isClassKeyword(typeNode) {
|
|
69
|
+
for (let i = 0; i < typeNode.childCount; i++) {
|
|
70
|
+
const child = typeNode.child(i);
|
|
71
|
+
if (child !== null && !child.isNamed) {
|
|
72
|
+
const t = child.text.trim();
|
|
73
|
+
if (t === 'class')
|
|
74
|
+
return true;
|
|
75
|
+
if (t === 'struct' || t === 'extension' || t === 'enum' || t === 'actor')
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
/** First inherited type (superclass or first protocol) as raw text, or
|
|
82
|
+
* null. For a class the first `inheritance_specifier` is conventionally
|
|
83
|
+
* the superclass — `super.x()` only compiles when that is true. For a
|
|
84
|
+
* `user_type` base the name is its trailing `type_identifier` segment (see
|
|
85
|
+
* `swiftQualifiedBaseTail`), falling back to the raw node text when there is
|
|
86
|
+
* no `type_identifier` child. */
|
|
87
|
+
function firstInheritedType(typeNode) {
|
|
88
|
+
for (let i = 0; i < typeNode.namedChildCount; i++) {
|
|
89
|
+
const child = typeNode.namedChild(i);
|
|
90
|
+
if (child === null || child.type !== 'inheritance_specifier')
|
|
91
|
+
continue;
|
|
92
|
+
const inheritsFrom = child.childForFieldName('inherits_from') ?? child.firstNamedChild;
|
|
93
|
+
if (inheritsFrom === null)
|
|
94
|
+
return null;
|
|
95
|
+
if (inheritsFrom.type === 'user_type') {
|
|
96
|
+
return swiftQualifiedBaseTail(inheritsFrom)?.text ?? inheritsFrom.text;
|
|
97
|
+
}
|
|
98
|
+
return inheritsFrom.text;
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
/** A Swift type method (`static func` OR `class func`) has no `self`
|
|
103
|
+
* instance receiver. Delegate to `swiftMethodConfig.isStatic`, which is
|
|
104
|
+
* the single source of truth: `static func` emits the modifier under a
|
|
105
|
+
* `modifiers > property_modifier` wrapper, but `class func` emits a BARE
|
|
106
|
+
* anonymous `class` token directly under `function_declaration` (verified,
|
|
107
|
+
* tree-sitter-swift 0.7.1). `swiftMethodConfig.isStatic` covers both via
|
|
108
|
+
* `hasKeyword(node, 'static'|'class')` (scans direct children) and
|
|
109
|
+
* `hasModifier(...)` — so reusing it avoids re-deriving the same scan and
|
|
110
|
+
* fixes the prior `modifiers`-only check that missed `class func`. */
|
|
111
|
+
function isStaticMethod(fnNode) {
|
|
112
|
+
return swiftMethodConfig.isStatic(fnNode);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Build zero, one, or two `@type-binding.self` matches for `fnNode`:
|
|
116
|
+
* - `null`/`[]` if the function is free (no enclosing type), static, or
|
|
117
|
+
* the enclosing type has no resolvable name, or the function is
|
|
118
|
+
* bodyless (no scope to anchor to).
|
|
119
|
+
* - one match (`self`) for instance methods of a class/struct/extension/
|
|
120
|
+
* protocol.
|
|
121
|
+
* - two matches (`self` + `super`) only when the function lives in a
|
|
122
|
+
* `class` (keyword) declaration with a declared superclass.
|
|
123
|
+
*
|
|
124
|
+
* Caller must guarantee `FUNCTION_NODE_TYPES.has(fnNode.type)`.
|
|
125
|
+
*/
|
|
126
|
+
export function synthesizeSwiftReceiverBinding(fnNode) {
|
|
127
|
+
if (!FUNCTION_NODE_TYPES.has(fnNode.type))
|
|
128
|
+
return [];
|
|
129
|
+
if (isStaticMethod(fnNode))
|
|
130
|
+
return [];
|
|
131
|
+
const enclosingType = findEnclosingTypeDeclaration(fnNode);
|
|
132
|
+
if (enclosingType === null)
|
|
133
|
+
return [];
|
|
134
|
+
const enclosingName = enclosingTypeName(enclosingType);
|
|
135
|
+
if (enclosingName === null)
|
|
136
|
+
return [];
|
|
137
|
+
// Anchor inside the function scope. `body:` is the function_body; its
|
|
138
|
+
// range is guaranteed inside the function scope (unlike the method's
|
|
139
|
+
// start position, which maps to the enclosing type scope via
|
|
140
|
+
// positionIndex). Bodyless declarations have no function scope.
|
|
141
|
+
const anchorNode = fnNode.childForFieldName('body');
|
|
142
|
+
if (anchorNode === null)
|
|
143
|
+
return [];
|
|
144
|
+
const out = [buildReceiverMatch(anchorNode, 'self', enclosingName)];
|
|
145
|
+
// `super` only for class methods with a declared superclass.
|
|
146
|
+
if (isClassKeyword(enclosingType)) {
|
|
147
|
+
const superType = firstInheritedType(enclosingType);
|
|
148
|
+
if (superType !== null) {
|
|
149
|
+
out.push(buildReceiverMatch(anchorNode, 'super', superType));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
function buildReceiverMatch(anchorNode, name, typeText) {
|
|
155
|
+
const m = {
|
|
156
|
+
'@type-binding.self': nodeToCapture('@type-binding.self', anchorNode),
|
|
157
|
+
'@type-binding.name': syntheticCapture('@type-binding.name', anchorNode, name),
|
|
158
|
+
'@type-binding.type': syntheticCapture('@type-binding.type', anchorNode, typeText),
|
|
159
|
+
};
|
|
160
|
+
return m;
|
|
161
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift `ScopeResolver` registered in `SCOPE_RESOLVERS` and consumed by
|
|
3
|
+
* the generic `runScopeResolution` orchestrator (RFC #909 Ring 3,
|
|
4
|
+
* issue #937 — the final per-language migration).
|
|
5
|
+
*
|
|
6
|
+
* Closest reference: C# (`csharpScopeResolver`) — both are OOP with
|
|
7
|
+
* classes, structs, interfaces/protocols, and explicit instance
|
|
8
|
+
* receivers. MRO follows Kotlin's shape (single superclass + multiple
|
|
9
|
+
* protocol conformance).
|
|
10
|
+
*
|
|
11
|
+
* ## Swift specifics
|
|
12
|
+
*
|
|
13
|
+
* - **Extensions** add members to an existing type. `emitSwiftScopeCaptures`
|
|
14
|
+
* re-keys an `extension Foo { … }` to a `class_declaration`-style def
|
|
15
|
+
* named `Foo`, so its members land on `Foo`'s scope and the shared
|
|
16
|
+
* `populateClassOwnedMembers` stamps them with `Foo`'s ownerId — the
|
|
17
|
+
* same mechanism C# uses for `partial class`. No separate hoist pass.
|
|
18
|
+
* - **Labeled arguments** narrow by ARITY only (count-primary, labels
|
|
19
|
+
* soft) — see `arity.ts`. Label-precise dispatch is deferred to the
|
|
20
|
+
* type-binding layer.
|
|
21
|
+
* - **Same-module visibility**: every file in an SPM target sees its
|
|
22
|
+
* siblings' top-level defs without an `import`. Modeled via
|
|
23
|
+
* `populateSwiftTargetSiblings`, grouped by the SPM target *subtree*
|
|
24
|
+
* (`Sources/<Target>/…`) via `groupSwiftFilesBySpmTarget` fed from the
|
|
25
|
+
* `loadResolutionConfig` SPM map, mirroring Go's package siblings. With
|
|
26
|
+
* no scanned source dir (no `Sources/`/`Package/Sources/`/`src/`) the
|
|
27
|
+
* map is null and all files form one `__default__` module.
|
|
28
|
+
* - **`super`** is the superclass receiver (`super.method()`); plain
|
|
29
|
+
* `self` is the instance receiver. Both synthesized in
|
|
30
|
+
* `receiver-binding.ts`.
|
|
31
|
+
*
|
|
32
|
+
* ## Known limitations (conscious migration trade-offs; parity gate flags
|
|
33
|
+
* anything that matters in the corpus)
|
|
34
|
+
*
|
|
35
|
+
* 1. **Protocol associated types / generic constraints** (`extension
|
|
36
|
+
* Array where Element: Equatable`) are not narrowed — the `Self`
|
|
37
|
+
* type of a protocol method resolves to the protocol, not the
|
|
38
|
+
* conforming type.
|
|
39
|
+
* 2. **Cross-module `import` resolution** is still directory-segment
|
|
40
|
+
* based (`import Foo` → files under a `Foo/` dir); explicit imports do
|
|
41
|
+
* not yet consult the SPM target map (follow-up, tracked under #1935).
|
|
42
|
+
* Same-target visibility (the common case) IS SPM-target-subtree
|
|
43
|
+
* accurate — handled by sibling augmentation grouped via
|
|
44
|
+
* `groupSwiftFilesBySpmTarget`, not by explicit imports.
|
|
45
|
+
* 3. **Operator / subscript overloads** dispatch by name only.
|
|
46
|
+
* 4. **`@_exported import` re-exports** are treated as plain imports.
|
|
47
|
+
*/
|
|
48
|
+
import type { ScopeResolver } from '../../scope-resolution/contract/scope-resolver.js';
|
|
49
|
+
declare const swiftScopeResolver: ScopeResolver;
|
|
50
|
+
export { swiftScopeResolver };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift `ScopeResolver` registered in `SCOPE_RESOLVERS` and consumed by
|
|
3
|
+
* the generic `runScopeResolution` orchestrator (RFC #909 Ring 3,
|
|
4
|
+
* issue #937 — the final per-language migration).
|
|
5
|
+
*
|
|
6
|
+
* Closest reference: C# (`csharpScopeResolver`) — both are OOP with
|
|
7
|
+
* classes, structs, interfaces/protocols, and explicit instance
|
|
8
|
+
* receivers. MRO follows Kotlin's shape (single superclass + multiple
|
|
9
|
+
* protocol conformance).
|
|
10
|
+
*
|
|
11
|
+
* ## Swift specifics
|
|
12
|
+
*
|
|
13
|
+
* - **Extensions** add members to an existing type. `emitSwiftScopeCaptures`
|
|
14
|
+
* re-keys an `extension Foo { … }` to a `class_declaration`-style def
|
|
15
|
+
* named `Foo`, so its members land on `Foo`'s scope and the shared
|
|
16
|
+
* `populateClassOwnedMembers` stamps them with `Foo`'s ownerId — the
|
|
17
|
+
* same mechanism C# uses for `partial class`. No separate hoist pass.
|
|
18
|
+
* - **Labeled arguments** narrow by ARITY only (count-primary, labels
|
|
19
|
+
* soft) — see `arity.ts`. Label-precise dispatch is deferred to the
|
|
20
|
+
* type-binding layer.
|
|
21
|
+
* - **Same-module visibility**: every file in an SPM target sees its
|
|
22
|
+
* siblings' top-level defs without an `import`. Modeled via
|
|
23
|
+
* `populateSwiftTargetSiblings`, grouped by the SPM target *subtree*
|
|
24
|
+
* (`Sources/<Target>/…`) via `groupSwiftFilesBySpmTarget` fed from the
|
|
25
|
+
* `loadResolutionConfig` SPM map, mirroring Go's package siblings. With
|
|
26
|
+
* no scanned source dir (no `Sources/`/`Package/Sources/`/`src/`) the
|
|
27
|
+
* map is null and all files form one `__default__` module.
|
|
28
|
+
* - **`super`** is the superclass receiver (`super.method()`); plain
|
|
29
|
+
* `self` is the instance receiver. Both synthesized in
|
|
30
|
+
* `receiver-binding.ts`.
|
|
31
|
+
*
|
|
32
|
+
* ## Known limitations (conscious migration trade-offs; parity gate flags
|
|
33
|
+
* anything that matters in the corpus)
|
|
34
|
+
*
|
|
35
|
+
* 1. **Protocol associated types / generic constraints** (`extension
|
|
36
|
+
* Array where Element: Equatable`) are not narrowed — the `Self`
|
|
37
|
+
* type of a protocol method resolves to the protocol, not the
|
|
38
|
+
* conforming type.
|
|
39
|
+
* 2. **Cross-module `import` resolution** is still directory-segment
|
|
40
|
+
* based (`import Foo` → files under a `Foo/` dir); explicit imports do
|
|
41
|
+
* not yet consult the SPM target map (follow-up, tracked under #1935).
|
|
42
|
+
* Same-target visibility (the common case) IS SPM-target-subtree
|
|
43
|
+
* accurate — handled by sibling augmentation grouped via
|
|
44
|
+
* `groupSwiftFilesBySpmTarget`, not by explicit imports.
|
|
45
|
+
* 3. **Operator / subscript overloads** dispatch by name only.
|
|
46
|
+
* 4. **`@_exported import` re-exports** are treated as plain imports.
|
|
47
|
+
*/
|
|
48
|
+
import { SupportedLanguages } from '../../../../_shared/index.js';
|
|
49
|
+
import { loadSwiftPackageConfig } from '../../language-config.js';
|
|
50
|
+
import { buildMro, defaultLinearize } from '../../scope-resolution/passes/mro.js';
|
|
51
|
+
import { populateClassOwnedMembers, isClassLike } from '../../scope-resolution/scope/walkers.js';
|
|
52
|
+
import { resolveDefGraphId } from '../../scope-resolution/graph-bridge/ids.js';
|
|
53
|
+
import { swiftProvider } from '../swift.js';
|
|
54
|
+
import { swiftArityCompatibility, swiftMergeBindings, interpretSwiftImport, resolveSwiftImportTarget, populateSwiftTargetSiblings, emitSwiftImplicitImportEdges, mirrorSwiftSiblingTypeBindings, } from './index.js';
|
|
55
|
+
const ZERO_RANGE = { startLine: 0, startCol: 0, endLine: 0, endCol: 0 };
|
|
56
|
+
const swiftScopeResolver = {
|
|
57
|
+
language: SupportedLanguages.Swift,
|
|
58
|
+
languageProvider: swiftProvider,
|
|
59
|
+
importEdgeReason: 'swift-scope: import',
|
|
60
|
+
// Load the SPM target map (Sources/<Target>/ subtree mapping) once per
|
|
61
|
+
// workspace pass. Threaded through the orchestrator as `resolutionConfig`
|
|
62
|
+
// and consumed by the three same-module grouping hooks
|
|
63
|
+
// (`emitImplicitImportEdges`, `populateNamespaceSiblings`,
|
|
64
|
+
// `mirrorNamespaceTypeBindings`) via `coerceSwiftTargets` so they group by
|
|
65
|
+
// the SPM target subtree, not the immediate directory. Mirrors
|
|
66
|
+
// `goScopeResolver`'s `loadGoModulePath`.
|
|
67
|
+
loadResolutionConfig: (repoPath) => loadSwiftPackageConfig(repoPath),
|
|
68
|
+
resolveImportTarget: (targetRaw, fromFile, allFilePaths) => {
|
|
69
|
+
const ws = { fromFile, allFilePaths };
|
|
70
|
+
return resolveSwiftImportTarget(interpretSwiftImport({
|
|
71
|
+
'@import.source': { name: '@import.source', text: targetRaw, range: ZERO_RANGE },
|
|
72
|
+
}) ?? { kind: 'namespace', localName: targetRaw, importedName: targetRaw, targetRaw }, ws);
|
|
73
|
+
},
|
|
74
|
+
// Swift shadowing: local declarations hide imports.
|
|
75
|
+
mergeBindings: (existing, incoming) => [...swiftMergeBindings([...existing, ...incoming])],
|
|
76
|
+
// Adapter: swiftArityCompatibility uses (def, callsite); contract is (callsite, def).
|
|
77
|
+
arityCompatibility: (callsite, def) => swiftArityCompatibility(def, callsite),
|
|
78
|
+
buildMro: (graph, parsedFiles, nodeLookup) => buildSwiftMro(graph, parsedFiles, nodeLookup),
|
|
79
|
+
// Methods/properties/init are owned by their enclosing class/struct/
|
|
80
|
+
// extension(→extended type)/protocol. Extension members hoist for free
|
|
81
|
+
// because captures.ts re-keys the extension to a Class def named after
|
|
82
|
+
// the extended type.
|
|
83
|
+
populateOwners: (parsed) => populateClassOwnedMembers(parsed),
|
|
84
|
+
// `super.method()` dispatches through the superclass chain.
|
|
85
|
+
isSuperReceiver: (text) => text.trim() === 'super',
|
|
86
|
+
// Whole-module same-target visibility without `import`.
|
|
87
|
+
populateNamespaceSiblings: populateSwiftTargetSiblings,
|
|
88
|
+
// Same-target File→File IMPORTS edges (no syntactic `import`). The
|
|
89
|
+
// generic finalized-ImportEdge pipeline has nothing to emit here, so
|
|
90
|
+
// these whole-module-visibility edges are emitted directly.
|
|
91
|
+
emitImplicitImportEdges: emitSwiftImplicitImportEdges,
|
|
92
|
+
// Mirror sibling files' return-type typeBindings into each file's
|
|
93
|
+
// module scope so cross-file chains (`let u = siblingFn(); u.m()`)
|
|
94
|
+
// resolve. Whole-module visibility has no import edge for
|
|
95
|
+
// `propagateImportedReturnTypes` to follow, so this directory-sibling
|
|
96
|
+
// mirror feeds it (mirrors Go's namespace-typeBinding mirror).
|
|
97
|
+
mirrorNamespaceTypeBindings: mirrorSwiftSiblingTypeBindings,
|
|
98
|
+
// Swift is statically typed — type info is reliable; the field-fallback
|
|
99
|
+
// heuristic over-connects, so keep it off. Return-type propagation on.
|
|
100
|
+
fieldFallbackOnMethodLookup: false,
|
|
101
|
+
propagatesReturnTypesAcrossImports: true,
|
|
102
|
+
// Swift has no `new` keyword: `UserService()` is a bare call that
|
|
103
|
+
// resolves to the type's Constructor/Class. With whole-module sibling
|
|
104
|
+
// visibility, the callee is reachable workspace-wide, so allow the
|
|
105
|
+
// global free-call fallback (as Python/Go/Ruby/COBOL do for the same
|
|
106
|
+
// no-`new` constructor + cross-file free-call shape).
|
|
107
|
+
allowGlobalFreeCallFallback: true,
|
|
108
|
+
// Swift's call graph models `Type(...)` as a reference to the type
|
|
109
|
+
// itself, not its `init` — both the legacy DAG and this test suite link
|
|
110
|
+
// `Foo()` to the Class node even when an explicit `init` exists.
|
|
111
|
+
constructorCallTargetsClass: true,
|
|
112
|
+
};
|
|
113
|
+
export { swiftScopeResolver };
|
|
114
|
+
/**
|
|
115
|
+
* Swift MRO — `defaultLinearize` (EXTENDS-only superclass chain) extended
|
|
116
|
+
* with protocol ancestors discovered via `IMPLEMENTS` edges. Protocols
|
|
117
|
+
* with default method implementations (via protocol extensions) are
|
|
118
|
+
* inherited by conforming types without an explicit `override`; the
|
|
119
|
+
* generic EXTENDS-only MRO would miss them because the conformer has no
|
|
120
|
+
* EXTENDS link to the protocol.
|
|
121
|
+
*
|
|
122
|
+
* Mirrors `buildKotlinMro`: append protocols after the superclass chain
|
|
123
|
+
* (Swift requires an explicit implementation on ambiguity, so first-seen
|
|
124
|
+
* ordering approximates method lookup). Transitive protocol inheritance
|
|
125
|
+
* (`protocol A: B`) is closed via BFS.
|
|
126
|
+
*/
|
|
127
|
+
function buildSwiftMro(graph, parsedFiles, nodeLookup) {
|
|
128
|
+
const mro = buildMro(graph, parsedFiles, nodeLookup, defaultLinearize);
|
|
129
|
+
const defIdByGraphId = new Map();
|
|
130
|
+
for (const parsed of parsedFiles) {
|
|
131
|
+
for (const def of parsed.localDefs) {
|
|
132
|
+
if (!isClassLike(def.type))
|
|
133
|
+
continue;
|
|
134
|
+
const graphId = resolveDefGraphId(parsed.filePath, def, nodeLookup);
|
|
135
|
+
if (graphId !== undefined)
|
|
136
|
+
defIdByGraphId.set(graphId, def.nodeId);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const directImpls = new Map();
|
|
140
|
+
for (const rel of graph.iterRelationshipsByType('IMPLEMENTS')) {
|
|
141
|
+
const source = defIdByGraphId.get(rel.sourceId);
|
|
142
|
+
const target = defIdByGraphId.get(rel.targetId);
|
|
143
|
+
if (source === undefined || target === undefined)
|
|
144
|
+
continue;
|
|
145
|
+
let list = directImpls.get(source);
|
|
146
|
+
if (list === undefined) {
|
|
147
|
+
list = [];
|
|
148
|
+
directImpls.set(source, list);
|
|
149
|
+
}
|
|
150
|
+
if (!list.includes(target))
|
|
151
|
+
list.push(target);
|
|
152
|
+
}
|
|
153
|
+
for (const [classDefId, extendsMro] of mro) {
|
|
154
|
+
const ancestorChain = [classDefId, ...extendsMro];
|
|
155
|
+
const seeds = [];
|
|
156
|
+
for (const ancestorId of ancestorChain) {
|
|
157
|
+
for (const ifaceId of directImpls.get(ancestorId) ?? [])
|
|
158
|
+
seeds.push(ifaceId);
|
|
159
|
+
}
|
|
160
|
+
if (seeds.length === 0)
|
|
161
|
+
continue;
|
|
162
|
+
const protocols = closeProtocols(seeds, directImpls);
|
|
163
|
+
mro.set(classDefId, [...extendsMro, ...protocols.filter((i) => !extendsMro.includes(i))]);
|
|
164
|
+
}
|
|
165
|
+
// Types that only conform to protocols (no superclass) still need an MRO.
|
|
166
|
+
for (const [classDefId, ifaces] of directImpls) {
|
|
167
|
+
if (mro.has(classDefId))
|
|
168
|
+
continue;
|
|
169
|
+
mro.set(classDefId, closeProtocols([...ifaces], directImpls));
|
|
170
|
+
}
|
|
171
|
+
return mro;
|
|
172
|
+
}
|
|
173
|
+
function closeProtocols(seeds, directImpls) {
|
|
174
|
+
const out = [];
|
|
175
|
+
const seen = new Set();
|
|
176
|
+
const queue = [...seeds];
|
|
177
|
+
while (queue.length > 0) {
|
|
178
|
+
const cur = queue.shift();
|
|
179
|
+
if (seen.has(cur))
|
|
180
|
+
continue;
|
|
181
|
+
seen.add(cur);
|
|
182
|
+
out.push(cur);
|
|
183
|
+
for (const next of directImpls.get(cur) ?? []) {
|
|
184
|
+
if (!seen.has(next))
|
|
185
|
+
queue.push(next);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return out;
|
|
189
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 type { ParsedFile } from '../../../../_shared/index.js';
|
|
32
|
+
import type { ScopeResolutionIndexes } from '../../model/scope-resolution-indexes.js';
|
|
33
|
+
import type { WorkspaceResolutionIndex } from '../../scope-resolution/workspace-index.js';
|
|
34
|
+
export declare function mirrorSwiftSiblingTypeBindings(parsedFiles: readonly ParsedFile[], indexes: ScopeResolutionIndexes, workspaceIndex: WorkspaceResolutionIndex, resolutionConfig?: unknown): void;
|