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,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift same-module implicit IMPORTS-edge emission for the
|
|
3
|
+
* `emitImplicitImportEdges` hook.
|
|
4
|
+
*
|
|
5
|
+
* Swift gives every file in a module (an SPM target) visibility of every
|
|
6
|
+
* other file's top-level declarations WITHOUT any `import` statement
|
|
7
|
+
* (whole-module visibility). The legacy DAG models this with File→File
|
|
8
|
+
* IMPORTS edges via `wireSwiftImplicitImports`; under registry-primary
|
|
9
|
+
* that wirer's `addImportEdge` is gated off, and the scope-resolution
|
|
10
|
+
* import pipeline (`emitImportEdges`) only materializes edges from
|
|
11
|
+
* finalized `ImportEdge`s — of which there are none here, because there
|
|
12
|
+
* is no syntactic `import`. This hook emits the missing edges directly.
|
|
13
|
+
*
|
|
14
|
+
* Module identity: Swift has no in-source `package X` marker. Module
|
|
15
|
+
* membership is the SPM target *subtree* (`Sources/<Target>/…`), threaded
|
|
16
|
+
* in via the SPM target map (`resolutionConfig` → `coerceSwiftTargets`)
|
|
17
|
+
* and grouped by `groupSwiftFilesBySpmTarget` — replicating legacy
|
|
18
|
+
* `groupSwiftFilesByTarget`. With no scanned source dir the map is null
|
|
19
|
+
* and all files form one `__default__` module (single-Xcode-project
|
|
20
|
+
* assumption). Every pair of distinct `.swift` files in the same module
|
|
21
|
+
* gets a directed IMPORTS edge in both directions (whole-module
|
|
22
|
+
* visibility is symmetric).
|
|
23
|
+
*
|
|
24
|
+
* Node identity + edge construction mirror the generic `emitImportEdges`
|
|
25
|
+
* convention (`graph-bridge/imports-to-edges.ts`): `generateId('File', path)`
|
|
26
|
+
* for endpoints and `generateId('IMPORTS', key)` for the relationship id,
|
|
27
|
+
* deduped by `(sourceFile -> targetFile)`. Re-invocation idempotency comes
|
|
28
|
+
* from `graph.addRelationship` id-dedup (the same `IMPORTS` id is produced
|
|
29
|
+
* for a given ordered pair), so no local `seen` set is needed.
|
|
30
|
+
*/
|
|
31
|
+
import { generateId } from '../../../../lib/utils.js';
|
|
32
|
+
import { coerceSwiftTargets, groupSwiftFilesBySpmTarget } from './target-grouping.js';
|
|
33
|
+
export function emitSwiftImplicitImportEdges(graph, parsedFiles, _nodeLookup, resolutionConfig) {
|
|
34
|
+
// Group files by SPM target subtree (the module). No-source-dir → all
|
|
35
|
+
// files in one `__default__` bucket.
|
|
36
|
+
const targets = coerceSwiftTargets(resolutionConfig);
|
|
37
|
+
const filesByTarget = groupSwiftFilesBySpmTarget(parsedFiles, (parsed) => parsed.filePath, targets);
|
|
38
|
+
for (const [, group] of filesByTarget) {
|
|
39
|
+
if (group.length < 2)
|
|
40
|
+
continue; // no siblings to import
|
|
41
|
+
for (const source of group) {
|
|
42
|
+
for (const target of group) {
|
|
43
|
+
if (source.filePath === target.filePath)
|
|
44
|
+
continue; // no self-import
|
|
45
|
+
const dedupKey = `${source.filePath}->${target.filePath}`;
|
|
46
|
+
graph.addRelationship({
|
|
47
|
+
id: generateId('IMPORTS', dedupKey),
|
|
48
|
+
sourceId: generateId('File', source.filePath),
|
|
49
|
+
targetId: generateId('File', target.filePath),
|
|
50
|
+
type: 'IMPORTS',
|
|
51
|
+
confidence: 1.0,
|
|
52
|
+
reason: 'swift-scope: implicit module visibility',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decompose a Swift `import_declaration` into a `CaptureMatch` carrying
|
|
3
|
+
* the synthesized markers `@import.kind` / `@import.source` /
|
|
4
|
+
* `@import.name` / `@import.testable` that `interpretSwiftImport`
|
|
5
|
+
* consumes.
|
|
6
|
+
*
|
|
7
|
+
* Swift imports are whole-module (no named members), so this is 1:1 —
|
|
8
|
+
* one `import` produces exactly one import. The split layer exposes the
|
|
9
|
+
* module name and the `@testable` flag without pushing raw-text parsing
|
|
10
|
+
* into `interpret.ts`.
|
|
11
|
+
*
|
|
12
|
+
* import Foundation → kind=namespace, source=Foundation
|
|
13
|
+
* import Foo.Bar → kind=namespace, source=Foo (SPM target),
|
|
14
|
+
* name=Foo.Bar (full path, for reference)
|
|
15
|
+
* @testable import MyApp → kind=namespace, source=MyApp, testable=1
|
|
16
|
+
*
|
|
17
|
+
* Verified against tree-sitter-swift 0.7.1:
|
|
18
|
+
* (import_declaration
|
|
19
|
+
* (modifiers (attribute (user_type (type_identifier))))? ; @testable / @_exported
|
|
20
|
+
* (identifier (simple_identifier)+)) ; one per dotted segment
|
|
21
|
+
*/
|
|
22
|
+
import type { CaptureMatch } from '../../../../_shared/index.js';
|
|
23
|
+
import { type SyntaxNode } from '../../utils/ast-helpers.js';
|
|
24
|
+
export declare function splitSwiftImport(stmtNode: SyntaxNode): CaptureMatch | null;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decompose a Swift `import_declaration` into a `CaptureMatch` carrying
|
|
3
|
+
* the synthesized markers `@import.kind` / `@import.source` /
|
|
4
|
+
* `@import.name` / `@import.testable` that `interpretSwiftImport`
|
|
5
|
+
* consumes.
|
|
6
|
+
*
|
|
7
|
+
* Swift imports are whole-module (no named members), so this is 1:1 —
|
|
8
|
+
* one `import` produces exactly one import. The split layer exposes the
|
|
9
|
+
* module name and the `@testable` flag without pushing raw-text parsing
|
|
10
|
+
* into `interpret.ts`.
|
|
11
|
+
*
|
|
12
|
+
* import Foundation → kind=namespace, source=Foundation
|
|
13
|
+
* import Foo.Bar → kind=namespace, source=Foo (SPM target),
|
|
14
|
+
* name=Foo.Bar (full path, for reference)
|
|
15
|
+
* @testable import MyApp → kind=namespace, source=MyApp, testable=1
|
|
16
|
+
*
|
|
17
|
+
* Verified against tree-sitter-swift 0.7.1:
|
|
18
|
+
* (import_declaration
|
|
19
|
+
* (modifiers (attribute (user_type (type_identifier))))? ; @testable / @_exported
|
|
20
|
+
* (identifier (simple_identifier)+)) ; one per dotted segment
|
|
21
|
+
*/
|
|
22
|
+
import { nodeToCapture, syntheticCapture } from '../../utils/ast-helpers.js';
|
|
23
|
+
export function splitSwiftImport(stmtNode) {
|
|
24
|
+
if (stmtNode.type !== 'import_declaration')
|
|
25
|
+
return null;
|
|
26
|
+
const spec = parseSwiftImport(stmtNode);
|
|
27
|
+
if (spec === null)
|
|
28
|
+
return null;
|
|
29
|
+
return buildImportMatch(stmtNode, spec);
|
|
30
|
+
}
|
|
31
|
+
function parseSwiftImport(node) {
|
|
32
|
+
let testable = false;
|
|
33
|
+
let identifierNode = null;
|
|
34
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
35
|
+
const child = node.namedChild(i);
|
|
36
|
+
if (child === null)
|
|
37
|
+
continue;
|
|
38
|
+
if (child.type === 'modifiers') {
|
|
39
|
+
// Any attribute whose text mentions `testable` flips the flag.
|
|
40
|
+
if (/\btestable\b/.test(child.text))
|
|
41
|
+
testable = true;
|
|
42
|
+
}
|
|
43
|
+
else if (child.type === 'identifier') {
|
|
44
|
+
identifierNode = child;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (identifierNode === null)
|
|
48
|
+
return null;
|
|
49
|
+
// The module path is one or more simple_identifier children, one per
|
|
50
|
+
// dotted segment. The SPM target is the FIRST segment.
|
|
51
|
+
const segments = [];
|
|
52
|
+
for (let i = 0; i < identifierNode.namedChildCount; i++) {
|
|
53
|
+
const seg = identifierNode.namedChild(i);
|
|
54
|
+
if (seg !== null && seg.type === 'simple_identifier')
|
|
55
|
+
segments.push(seg.text);
|
|
56
|
+
}
|
|
57
|
+
if (segments.length === 0) {
|
|
58
|
+
// Fall back to the raw identifier text (e.g. a grammar shape we didn't
|
|
59
|
+
// anticipate). Split on `.` to recover the target segment.
|
|
60
|
+
const raw = identifierNode.text.trim();
|
|
61
|
+
if (raw === '')
|
|
62
|
+
return null;
|
|
63
|
+
const parts = raw.split('.');
|
|
64
|
+
return { source: parts[0], fullPath: raw, testable, atNode: node };
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
source: segments[0],
|
|
68
|
+
fullPath: segments.join('.'),
|
|
69
|
+
testable,
|
|
70
|
+
atNode: node,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function buildImportMatch(stmtNode, spec) {
|
|
74
|
+
const m = {
|
|
75
|
+
'@import.statement': nodeToCapture('@import.statement', stmtNode),
|
|
76
|
+
'@import.kind': syntheticCapture('@import.kind', spec.atNode, 'namespace'),
|
|
77
|
+
'@import.source': syntheticCapture('@import.source', spec.atNode, spec.source),
|
|
78
|
+
'@import.name': syntheticCapture('@import.name', spec.atNode, spec.fullPath),
|
|
79
|
+
};
|
|
80
|
+
if (spec.testable) {
|
|
81
|
+
m['@import.testable'] = syntheticCapture('@import.testable', spec.atNode, '1');
|
|
82
|
+
}
|
|
83
|
+
return m;
|
|
84
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `resolveImportTarget` adapter for the Swift `ScopeResolver`.
|
|
3
|
+
*
|
|
4
|
+
* Swift's `import ModuleName` brings in a whole SPM target / framework
|
|
5
|
+
* module. The scope-resolution contract passes only `allFilePaths` (no
|
|
6
|
+
* `SwiftPackageConfig`), so we resolve a module name to the `.swift`
|
|
7
|
+
* files under a directory segment named after the module — the SPM
|
|
8
|
+
* convention `Sources/<Module>/*.swift` (and the common
|
|
9
|
+
* `<Module>/*.swift` layout). This needs no manifest parsing.
|
|
10
|
+
*
|
|
11
|
+
* Same-module (intra-target) visibility — the bulk of Swift cross-file
|
|
12
|
+
* resolution, which needs NO `import` statement — is handled separately
|
|
13
|
+
* by `populateSwiftTargetSiblings` (see `target-siblings.ts`). This
|
|
14
|
+
* adapter only resolves EXPLICIT `import` statements (cross-module).
|
|
15
|
+
*
|
|
16
|
+
* Returns all matching files (one ImportEdge per file, like Go's
|
|
17
|
+
* package resolver) so every exported symbol in the module materializes
|
|
18
|
+
* a binding. Returns `null` for external frameworks (Foundation, UIKit,
|
|
19
|
+
* …) that have no in-repo directory.
|
|
20
|
+
*
|
|
21
|
+
* Performance: the directory→files grouping is memoized on the stable
|
|
22
|
+
* `allFilePaths` Set identity (the same Set is threaded to every import
|
|
23
|
+
* in a run), so it is built once per run — NOT once per import. Mirrors
|
|
24
|
+
* Python's `getPythonFileIndex` WeakMap pattern (PR #1918).
|
|
25
|
+
*/
|
|
26
|
+
import type { ParsedImport, WorkspaceIndex } from '../../../../_shared/index.js';
|
|
27
|
+
export interface SwiftResolveContext {
|
|
28
|
+
readonly fromFile: string;
|
|
29
|
+
/** `ReadonlySet` so the orchestrator's stable run-level set flows
|
|
30
|
+
* straight through to the memoized index key. */
|
|
31
|
+
readonly allFilePaths: ReadonlySet<string>;
|
|
32
|
+
}
|
|
33
|
+
export declare function resolveSwiftImportTarget(parsedImport: ParsedImport, workspaceIndex: WorkspaceIndex): string | readonly string[] | null;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `resolveImportTarget` adapter for the Swift `ScopeResolver`.
|
|
3
|
+
*
|
|
4
|
+
* Swift's `import ModuleName` brings in a whole SPM target / framework
|
|
5
|
+
* module. The scope-resolution contract passes only `allFilePaths` (no
|
|
6
|
+
* `SwiftPackageConfig`), so we resolve a module name to the `.swift`
|
|
7
|
+
* files under a directory segment named after the module — the SPM
|
|
8
|
+
* convention `Sources/<Module>/*.swift` (and the common
|
|
9
|
+
* `<Module>/*.swift` layout). This needs no manifest parsing.
|
|
10
|
+
*
|
|
11
|
+
* Same-module (intra-target) visibility — the bulk of Swift cross-file
|
|
12
|
+
* resolution, which needs NO `import` statement — is handled separately
|
|
13
|
+
* by `populateSwiftTargetSiblings` (see `target-siblings.ts`). This
|
|
14
|
+
* adapter only resolves EXPLICIT `import` statements (cross-module).
|
|
15
|
+
*
|
|
16
|
+
* Returns all matching files (one ImportEdge per file, like Go's
|
|
17
|
+
* package resolver) so every exported symbol in the module materializes
|
|
18
|
+
* a binding. Returns `null` for external frameworks (Foundation, UIKit,
|
|
19
|
+
* …) that have no in-repo directory.
|
|
20
|
+
*
|
|
21
|
+
* Performance: the directory→files grouping is memoized on the stable
|
|
22
|
+
* `allFilePaths` Set identity (the same Set is threaded to every import
|
|
23
|
+
* in a run), so it is built once per run — NOT once per import. Mirrors
|
|
24
|
+
* Python's `getPythonFileIndex` WeakMap pattern (PR #1918).
|
|
25
|
+
*/
|
|
26
|
+
const SWIFT_MODULE_INDEX_CACHE = new WeakMap();
|
|
27
|
+
function getSwiftModuleIndex(allFilePaths) {
|
|
28
|
+
const cached = SWIFT_MODULE_INDEX_CACHE.get(allFilePaths);
|
|
29
|
+
if (cached !== undefined)
|
|
30
|
+
return cached;
|
|
31
|
+
const byModule = new Map();
|
|
32
|
+
for (const raw of allFilePaths) {
|
|
33
|
+
const norm = raw.replace(/\\/g, '/');
|
|
34
|
+
if (!norm.endsWith('.swift'))
|
|
35
|
+
continue;
|
|
36
|
+
// Each interior directory segment is a candidate module name. A file
|
|
37
|
+
// `Sources/Models/User.swift` is attributed to module `Sources` and
|
|
38
|
+
// module `Models`; an `import Models` then resolves to it.
|
|
39
|
+
const segments = norm.split('/');
|
|
40
|
+
// Drop the filename (last segment); the rest are directory segments.
|
|
41
|
+
for (let i = 0; i < segments.length - 1; i++) {
|
|
42
|
+
const seg = segments[i];
|
|
43
|
+
if (seg === '')
|
|
44
|
+
continue;
|
|
45
|
+
let bucket = byModule.get(seg);
|
|
46
|
+
if (bucket === undefined) {
|
|
47
|
+
bucket = [];
|
|
48
|
+
byModule.set(seg, bucket);
|
|
49
|
+
}
|
|
50
|
+
bucket.push(raw);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const index = { byModule };
|
|
54
|
+
SWIFT_MODULE_INDEX_CACHE.set(allFilePaths, index);
|
|
55
|
+
return index;
|
|
56
|
+
}
|
|
57
|
+
export function resolveSwiftImportTarget(parsedImport, workspaceIndex) {
|
|
58
|
+
const ctx = workspaceIndex;
|
|
59
|
+
// Duck-type the set (PR #1918 P2: don't `instanceof Set`).
|
|
60
|
+
const allFilePaths = ctx?.allFilePaths;
|
|
61
|
+
if (ctx === undefined ||
|
|
62
|
+
typeof ctx.fromFile !== 'string' ||
|
|
63
|
+
typeof allFilePaths?.has !== 'function' ||
|
|
64
|
+
typeof allFilePaths?.[Symbol.iterator] !== 'function') {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
// Swift import target is the SPM module name (first dotted segment).
|
|
68
|
+
const targetRaw = parsedImport.targetRaw;
|
|
69
|
+
if (targetRaw === null || targetRaw === '')
|
|
70
|
+
return null;
|
|
71
|
+
const moduleName = targetRaw.split('.')[0];
|
|
72
|
+
if (moduleName === '')
|
|
73
|
+
return null;
|
|
74
|
+
const index = getSwiftModuleIndex(ctx.allFilePaths);
|
|
75
|
+
const files = index.byModule.get(moduleName);
|
|
76
|
+
if (files === undefined || files.length === 0)
|
|
77
|
+
return null; // external framework
|
|
78
|
+
// Exclude the importer itself (a file under `Foo/` importing `Foo`).
|
|
79
|
+
const out = files.filter((f) => f !== ctx.fromFile);
|
|
80
|
+
return out.length > 0 ? out : null;
|
|
81
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift scope-resolution hooks (RFC #909 Ring 3, issue #937 — the final
|
|
3
|
+
* per-language migration).
|
|
4
|
+
*
|
|
5
|
+
* Public API barrel. Consumers import from this file rather than the
|
|
6
|
+
* individual modules.
|
|
7
|
+
*
|
|
8
|
+
* Module layout (each file is a single concern):
|
|
9
|
+
*
|
|
10
|
+
* - `query.ts` — tree-sitter query + lazy parser/query singletons
|
|
11
|
+
* - `captures.ts` — `emitSwiftScopeCaptures` orchestrator
|
|
12
|
+
* - `import-decomposer.ts` — each `import` → ParsedImport-shaped captures
|
|
13
|
+
* - `interpret.ts` — capture-match → `ParsedImport` / `ParsedTypeBinding`
|
|
14
|
+
* - `simple-hooks.ts` — small/no-op hooks made explicit
|
|
15
|
+
* - `receiver-binding.ts` — synthesize `self` / `super` type-bindings
|
|
16
|
+
* - `merge-bindings.ts` — Swift import-vs-local precedence
|
|
17
|
+
* - `arity.ts` — Swift arity compatibility (count-primary)
|
|
18
|
+
* - `arity-metadata.ts` — synthesize arity metadata from declarations
|
|
19
|
+
* - `import-target.ts` — `(ParsedImport, WorkspaceIndex) → file path` adapter
|
|
20
|
+
* - `target-grouping.ts` — group same-module files by SPM target subtree
|
|
21
|
+
* - `target-siblings.ts` — same-SPM-target implicit cross-file visibility
|
|
22
|
+
* - `implicit-imports.ts` — same-SPM-target File→File IMPORTS edges
|
|
23
|
+
* - `sibling-type-bindings.ts` — mirror sibling return-type typeBindings
|
|
24
|
+
* - `scope-resolver.ts` — `ScopeResolver` registered in `SCOPE_RESOLVERS`
|
|
25
|
+
* - `cache-stats.ts` — PROF_SCOPE_RESOLUTION cache hit/miss counters
|
|
26
|
+
*/
|
|
27
|
+
export { emitSwiftScopeCaptures } from './captures.js';
|
|
28
|
+
export { getSwiftCaptureCacheStats, resetSwiftCaptureCacheStats } from './cache-stats.js';
|
|
29
|
+
export { interpretSwiftImport, interpretSwiftTypeBinding } from './interpret.js';
|
|
30
|
+
export { swiftMergeBindings } from './merge-bindings.js';
|
|
31
|
+
export { swiftArityCompatibility } from './arity.js';
|
|
32
|
+
export { resolveSwiftImportTarget, type SwiftResolveContext } from './import-target.js';
|
|
33
|
+
export { groupSwiftFilesBySpmTarget, coerceSwiftTargets } from './target-grouping.js';
|
|
34
|
+
export { populateSwiftTargetSiblings } from './target-siblings.js';
|
|
35
|
+
export { emitSwiftImplicitImportEdges } from './implicit-imports.js';
|
|
36
|
+
export { mirrorSwiftSiblingTypeBindings } from './sibling-type-bindings.js';
|
|
37
|
+
export { swiftBindingScopeFor, swiftImportOwningScope, swiftReceiverBinding, } from './simple-hooks.js';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift scope-resolution hooks (RFC #909 Ring 3, issue #937 — the final
|
|
3
|
+
* per-language migration).
|
|
4
|
+
*
|
|
5
|
+
* Public API barrel. Consumers import from this file rather than the
|
|
6
|
+
* individual modules.
|
|
7
|
+
*
|
|
8
|
+
* Module layout (each file is a single concern):
|
|
9
|
+
*
|
|
10
|
+
* - `query.ts` — tree-sitter query + lazy parser/query singletons
|
|
11
|
+
* - `captures.ts` — `emitSwiftScopeCaptures` orchestrator
|
|
12
|
+
* - `import-decomposer.ts` — each `import` → ParsedImport-shaped captures
|
|
13
|
+
* - `interpret.ts` — capture-match → `ParsedImport` / `ParsedTypeBinding`
|
|
14
|
+
* - `simple-hooks.ts` — small/no-op hooks made explicit
|
|
15
|
+
* - `receiver-binding.ts` — synthesize `self` / `super` type-bindings
|
|
16
|
+
* - `merge-bindings.ts` — Swift import-vs-local precedence
|
|
17
|
+
* - `arity.ts` — Swift arity compatibility (count-primary)
|
|
18
|
+
* - `arity-metadata.ts` — synthesize arity metadata from declarations
|
|
19
|
+
* - `import-target.ts` — `(ParsedImport, WorkspaceIndex) → file path` adapter
|
|
20
|
+
* - `target-grouping.ts` — group same-module files by SPM target subtree
|
|
21
|
+
* - `target-siblings.ts` — same-SPM-target implicit cross-file visibility
|
|
22
|
+
* - `implicit-imports.ts` — same-SPM-target File→File IMPORTS edges
|
|
23
|
+
* - `sibling-type-bindings.ts` — mirror sibling return-type typeBindings
|
|
24
|
+
* - `scope-resolver.ts` — `ScopeResolver` registered in `SCOPE_RESOLVERS`
|
|
25
|
+
* - `cache-stats.ts` — PROF_SCOPE_RESOLUTION cache hit/miss counters
|
|
26
|
+
*/
|
|
27
|
+
export { emitSwiftScopeCaptures } from './captures.js';
|
|
28
|
+
export { getSwiftCaptureCacheStats, resetSwiftCaptureCacheStats } from './cache-stats.js';
|
|
29
|
+
export { interpretSwiftImport, interpretSwiftTypeBinding } from './interpret.js';
|
|
30
|
+
export { swiftMergeBindings } from './merge-bindings.js';
|
|
31
|
+
export { swiftArityCompatibility } from './arity.js';
|
|
32
|
+
export { resolveSwiftImportTarget } from './import-target.js';
|
|
33
|
+
export { groupSwiftFilesBySpmTarget, coerceSwiftTargets } from './target-grouping.js';
|
|
34
|
+
export { populateSwiftTargetSiblings } from './target-siblings.js';
|
|
35
|
+
export { emitSwiftImplicitImportEdges } from './implicit-imports.js';
|
|
36
|
+
export { mirrorSwiftSiblingTypeBindings } from './sibling-type-bindings.js';
|
|
37
|
+
export { swiftBindingScopeFor, swiftImportOwningScope, swiftReceiverBinding, } from './simple-hooks.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture-match → semantic-shape interpreters for Swift.
|
|
3
|
+
*
|
|
4
|
+
* - `interpretSwiftImport` → `ParsedImport`
|
|
5
|
+
* - `interpretSwiftTypeBinding` → `ParsedTypeBinding`
|
|
6
|
+
*
|
|
7
|
+
* Import matches arrive pre-decomposed by `emitSwiftScopeCaptures` (one
|
|
8
|
+
* import per match, with synthesized `@import.kind/source/name` markers
|
|
9
|
+
* and an optional `@import.testable` flag). Type-binding matches arrive
|
|
10
|
+
* from the raw query captures — each `@type-binding.*` anchor carries
|
|
11
|
+
* `@type-binding.name` + `@type-binding.type`.
|
|
12
|
+
*/
|
|
13
|
+
import type { CaptureMatch, ParsedImport, ParsedTypeBinding } from '../../../../_shared/index.js';
|
|
14
|
+
export declare function interpretSwiftImport(captures: CaptureMatch): ParsedImport | null;
|
|
15
|
+
export declare function interpretSwiftTypeBinding(captures: CaptureMatch): ParsedTypeBinding | null;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture-match → semantic-shape interpreters for Swift.
|
|
3
|
+
*
|
|
4
|
+
* - `interpretSwiftImport` → `ParsedImport`
|
|
5
|
+
* - `interpretSwiftTypeBinding` → `ParsedTypeBinding`
|
|
6
|
+
*
|
|
7
|
+
* Import matches arrive pre-decomposed by `emitSwiftScopeCaptures` (one
|
|
8
|
+
* import per match, with synthesized `@import.kind/source/name` markers
|
|
9
|
+
* and an optional `@import.testable` flag). Type-binding matches arrive
|
|
10
|
+
* from the raw query captures — each `@type-binding.*` anchor carries
|
|
11
|
+
* `@type-binding.name` + `@type-binding.type`.
|
|
12
|
+
*/
|
|
13
|
+
// ─── interpretImport ──────────────────────────────────────────────────────
|
|
14
|
+
export function interpretSwiftImport(captures) {
|
|
15
|
+
const sourceCap = captures['@import.source'];
|
|
16
|
+
if (sourceCap === undefined)
|
|
17
|
+
return null;
|
|
18
|
+
// Swift imports are whole-module (wildcard semantics): `import Foundation`
|
|
19
|
+
// brings the entire module into scope, no named members. The SPM target
|
|
20
|
+
// (first dotted segment) is the resolution target; the full path is kept
|
|
21
|
+
// as importedName for reference. `@testable` resolves identically to a
|
|
22
|
+
// plain import (same module is visible in test scope).
|
|
23
|
+
const source = sourceCap.text;
|
|
24
|
+
const fullPath = captures['@import.name']?.text ?? source;
|
|
25
|
+
return {
|
|
26
|
+
kind: 'namespace',
|
|
27
|
+
localName: source,
|
|
28
|
+
importedName: fullPath,
|
|
29
|
+
targetRaw: source,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// ─── interpretTypeBinding ─────────────────────────────────────────────────
|
|
33
|
+
export function interpretSwiftTypeBinding(captures) {
|
|
34
|
+
const nameCap = captures['@type-binding.name'];
|
|
35
|
+
const typeCap = captures['@type-binding.type'];
|
|
36
|
+
if (nameCap === undefined || typeCap === undefined)
|
|
37
|
+
return null;
|
|
38
|
+
// Normalize so receiver-typed resolution treats these identically:
|
|
39
|
+
// `User?` / `User!` → User (optional / IUO)
|
|
40
|
+
// `[User]` → User (array sugar)
|
|
41
|
+
// `Array<User>` / `Optional<User>` → User (single-arg generic)
|
|
42
|
+
// `Foundation.URL` → URL (qualifier)
|
|
43
|
+
const rawType = stripQualifier(stripGeneric(stripArraySugar(stripOptional(typeCap.text.trim()))));
|
|
44
|
+
let source = 'parameter-annotation';
|
|
45
|
+
if (captures['@type-binding.self'] !== undefined)
|
|
46
|
+
source = 'self';
|
|
47
|
+
else if (captures['@type-binding.constructor'] !== undefined)
|
|
48
|
+
source = 'constructor-inferred';
|
|
49
|
+
else if (captures['@type-binding.annotation'] !== undefined)
|
|
50
|
+
source = 'annotation';
|
|
51
|
+
else if (captures['@type-binding.alias'] !== undefined)
|
|
52
|
+
source = 'assignment-inferred';
|
|
53
|
+
else if (captures['@type-binding.return'] !== undefined)
|
|
54
|
+
source = 'return-annotation';
|
|
55
|
+
return { boundName: nameCap.text, rawTypeName: rawType, source };
|
|
56
|
+
}
|
|
57
|
+
/** `User?` / `User!` → `User`. */
|
|
58
|
+
function stripOptional(text) {
|
|
59
|
+
if (text.endsWith('?') || text.endsWith('!'))
|
|
60
|
+
return text.slice(0, -1).trim();
|
|
61
|
+
return text;
|
|
62
|
+
}
|
|
63
|
+
/** `[User]` → `User` (array sugar). `[K: V]` (dictionary) is left alone —
|
|
64
|
+
* element semantics aren't unambiguous. */
|
|
65
|
+
function stripArraySugar(text) {
|
|
66
|
+
if (text.startsWith('[') && text.endsWith(']') && !text.includes(':')) {
|
|
67
|
+
return text.slice(1, -1).trim();
|
|
68
|
+
}
|
|
69
|
+
return text;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Unwrap a single-arg generic collection wrapper — `Array<User>`,
|
|
73
|
+
* `Optional<User>`, `Set<User>` — to its element type. Mirrors C#'s
|
|
74
|
+
* `stripGeneric`. Multi-arg generics (`Dictionary<K, V>`,
|
|
75
|
+
* `Result<T, E>`) are left alone.
|
|
76
|
+
*/
|
|
77
|
+
function stripGeneric(text) {
|
|
78
|
+
const single = text.match(/^(?:[A-Za-z_][A-Za-z0-9_.]*\.)?(?:Array|Optional|Set|ContiguousArray|ArraySlice)<([^,<>]+)>$/);
|
|
79
|
+
if (single !== null)
|
|
80
|
+
return single[1].trim();
|
|
81
|
+
return text;
|
|
82
|
+
}
|
|
83
|
+
/** `Foundation.URL` → `URL`. */
|
|
84
|
+
function stripQualifier(text) {
|
|
85
|
+
const lastDot = text.lastIndexOf('.');
|
|
86
|
+
if (lastDot === -1)
|
|
87
|
+
return text;
|
|
88
|
+
return text.slice(lastDot + 1);
|
|
89
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift shadowing precedence for the `mergeBindings` hook.
|
|
3
|
+
*
|
|
4
|
+
* Tier ranking (lower wins in shadowing):
|
|
5
|
+
*
|
|
6
|
+
* - 0: `local` — a type member, method, local var, or parameter
|
|
7
|
+
* declared in this scope.
|
|
8
|
+
* - 1: `import` / `namespace` / `reexport` — names brought in by an
|
|
9
|
+
* `import ModuleName` (whole-module, including `@testable`).
|
|
10
|
+
* - 2: `wildcard` — reserved; Swift's whole-module import already
|
|
11
|
+
* behaves like a namespace tier, so this is rarely populated.
|
|
12
|
+
*
|
|
13
|
+
* Swift resolves an ambiguity between two imported modules by requiring
|
|
14
|
+
* an explicit `Module.Symbol` qualifier; for receiver-typed dispatch we
|
|
15
|
+
* treat all imports as one tier. Locals always shadow imports.
|
|
16
|
+
*
|
|
17
|
+
* Within a surviving tier we de-dup by `DefId`, last-write-wins.
|
|
18
|
+
*/
|
|
19
|
+
import type { BindingRef } from '../../../../_shared/index.js';
|
|
20
|
+
export declare function swiftMergeBindings(bindings: readonly BindingRef[]): readonly BindingRef[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift shadowing precedence for the `mergeBindings` hook.
|
|
3
|
+
*
|
|
4
|
+
* Tier ranking (lower wins in shadowing):
|
|
5
|
+
*
|
|
6
|
+
* - 0: `local` — a type member, method, local var, or parameter
|
|
7
|
+
* declared in this scope.
|
|
8
|
+
* - 1: `import` / `namespace` / `reexport` — names brought in by an
|
|
9
|
+
* `import ModuleName` (whole-module, including `@testable`).
|
|
10
|
+
* - 2: `wildcard` — reserved; Swift's whole-module import already
|
|
11
|
+
* behaves like a namespace tier, so this is rarely populated.
|
|
12
|
+
*
|
|
13
|
+
* Swift resolves an ambiguity between two imported modules by requiring
|
|
14
|
+
* an explicit `Module.Symbol` qualifier; for receiver-typed dispatch we
|
|
15
|
+
* treat all imports as one tier. Locals always shadow imports.
|
|
16
|
+
*
|
|
17
|
+
* Within a surviving tier we de-dup by `DefId`, last-write-wins.
|
|
18
|
+
*/
|
|
19
|
+
const TIER_LOCAL = 0;
|
|
20
|
+
const TIER_IMPORT = 1;
|
|
21
|
+
const TIER_WILDCARD = 2;
|
|
22
|
+
const TIER_UNKNOWN = 3;
|
|
23
|
+
function tierOf(b) {
|
|
24
|
+
switch (b.origin) {
|
|
25
|
+
case 'local':
|
|
26
|
+
return TIER_LOCAL;
|
|
27
|
+
case 'reexport':
|
|
28
|
+
case 'import':
|
|
29
|
+
case 'namespace':
|
|
30
|
+
return TIER_IMPORT;
|
|
31
|
+
case 'wildcard':
|
|
32
|
+
return TIER_WILDCARD;
|
|
33
|
+
default:
|
|
34
|
+
return TIER_UNKNOWN;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function swiftMergeBindings(bindings) {
|
|
38
|
+
if (bindings.length === 0)
|
|
39
|
+
return bindings;
|
|
40
|
+
let bestTier = Number.POSITIVE_INFINITY;
|
|
41
|
+
for (const b of bindings)
|
|
42
|
+
bestTier = Math.min(bestTier, tierOf(b));
|
|
43
|
+
const survivors = bindings.filter((b) => tierOf(b) === bestTier);
|
|
44
|
+
const seen = new Map();
|
|
45
|
+
for (const b of survivors)
|
|
46
|
+
seen.set(b.def.nodeId, b);
|
|
47
|
+
return [...seen.values()];
|
|
48
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
export declare function getSwiftParser(): Parser;
|
|
46
|
+
export declare function getSwiftScopeQuery(): Parser.Query;
|