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,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trailing simple-name `type_identifier` of a Swift `user_type` base. A
|
|
3
|
+
* qualified `Outer.Inner` parses flat as
|
|
4
|
+
* `(user_type (type_identifier "Outer") (type_identifier "Inner"))`, and the
|
|
5
|
+
* actual base type is the TRAILING segment `Inner` (mirrors Java
|
|
6
|
+
* `scoped_type_identifier` → `lastNamedChild` and TS `nested_type_identifier`
|
|
7
|
+
* → tail). Generic arguments live in a sibling `type_arguments` node — never a
|
|
8
|
+
* `type_identifier` — so they are skipped: `Box<Int>` → `Box`,
|
|
9
|
+
* `Outer.Inner<T>` → `Inner`. Returns null when the `user_type` has no
|
|
10
|
+
* `type_identifier` child.
|
|
11
|
+
*
|
|
12
|
+
* Shared by `swiftBaseTypeIdentifier` (captures.ts — returns the node for an
|
|
13
|
+
* `@reference.inherits` site) and `firstInheritedType` (receiver-binding.ts —
|
|
14
|
+
* reads `.text` for `super` receiver binding). It lives in this leaf module
|
|
15
|
+
* rather than being exported from captures.ts because captures.ts already
|
|
16
|
+
* imports receiver-binding.ts, so a captures.ts export would create a
|
|
17
|
+
* bidirectional import cycle (#1956 tri-review U7).
|
|
18
|
+
*/
|
|
19
|
+
export function swiftQualifiedBaseTail(userType) {
|
|
20
|
+
let last = null;
|
|
21
|
+
for (let i = 0; i < userType.namedChildCount; i++) {
|
|
22
|
+
const child = userType.namedChild(i);
|
|
23
|
+
if (child !== null && child.type === 'type_identifier')
|
|
24
|
+
last = child;
|
|
25
|
+
}
|
|
26
|
+
return last;
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-mode counters for the cross-phase scope-captures parse cache
|
|
3
|
+
* (Swift mirror of `languages/csharp/cache-stats.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Gated by `PROF_SCOPE_RESOLUTION=1`. Production builds fold every
|
|
6
|
+
* increment into dead code via the module-level `PROF` constant, so
|
|
7
|
+
* the hot path in `captures.ts` stays branch-free.
|
|
8
|
+
*/
|
|
9
|
+
export declare function recordCacheHit(): void;
|
|
10
|
+
export declare function recordCacheMiss(): void;
|
|
11
|
+
export declare function getSwiftCaptureCacheStats(): {
|
|
12
|
+
hits: number;
|
|
13
|
+
misses: number;
|
|
14
|
+
};
|
|
15
|
+
export declare function resetSwiftCaptureCacheStats(): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-mode counters for the cross-phase scope-captures parse cache
|
|
3
|
+
* (Swift mirror of `languages/csharp/cache-stats.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Gated by `PROF_SCOPE_RESOLUTION=1`. Production builds fold every
|
|
6
|
+
* increment into dead code via the module-level `PROF` constant, so
|
|
7
|
+
* the hot path in `captures.ts` stays branch-free.
|
|
8
|
+
*/
|
|
9
|
+
const PROF = process.env.PROF_SCOPE_RESOLUTION === '1';
|
|
10
|
+
let CACHE_HITS = 0;
|
|
11
|
+
let CACHE_MISSES = 0;
|
|
12
|
+
export function recordCacheHit() {
|
|
13
|
+
if (PROF)
|
|
14
|
+
CACHE_HITS++;
|
|
15
|
+
}
|
|
16
|
+
export function recordCacheMiss() {
|
|
17
|
+
if (PROF)
|
|
18
|
+
CACHE_MISSES++;
|
|
19
|
+
}
|
|
20
|
+
export function getSwiftCaptureCacheStats() {
|
|
21
|
+
return { hits: CACHE_HITS, misses: CACHE_MISSES };
|
|
22
|
+
}
|
|
23
|
+
export function resetSwiftCaptureCacheStats() {
|
|
24
|
+
CACHE_HITS = 0;
|
|
25
|
+
CACHE_MISSES = 0;
|
|
26
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `emitScopeCaptures` for Swift.
|
|
3
|
+
*
|
|
4
|
+
* Drives the Swift scope query against tree-sitter-swift and groups raw
|
|
5
|
+
* matches into `CaptureMatch[]` for the central extractor. Synthesizes
|
|
6
|
+
* several streams on top of the raw query captures:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Decomposed imports** — each `import_declaration` is re-emitted
|
|
9
|
+
* with `@import.kind/source/name` markers (and `@import.testable`
|
|
10
|
+
* when present) so `interpretSwiftImport` recovers the ParsedImport
|
|
11
|
+
* shape without re-parsing raw text (`import-decomposer.ts`).
|
|
12
|
+
* 2. **Optional bindings** — `if let u = getUser()` / `guard let …`
|
|
13
|
+
* synthesize a `@type-binding.constructor` (name → callee) by
|
|
14
|
+
* walking the anchored statement (`@optional.binding`).
|
|
15
|
+
* 3. **Receiver bindings** — `self` (+ `super`) `@type-binding.self`
|
|
16
|
+
* anchors on every instance method/init (`receiver-binding.ts`).
|
|
17
|
+
* 4. **Signature bindings** — parameter-type and return-type
|
|
18
|
+
* `@type-binding.*` synthesized from the function node, because
|
|
19
|
+
* Swift's grammar reuses the `name:` field for func-name / param /
|
|
20
|
+
* return so a query can't disambiguate (`signature-bindings.ts`).
|
|
21
|
+
* 5. **Arity metadata** — `@declaration.parameter-count` etc. on
|
|
22
|
+
* function-like declarations and `@reference.arity` on call sites,
|
|
23
|
+
* so the registry can narrow by arity (`arity-metadata.ts`).
|
|
24
|
+
*
|
|
25
|
+
* Extension handling: a `class_declaration` whose `name:` is a
|
|
26
|
+
* `(user_type …)` is an `extension Foo { … }`. The query tags it
|
|
27
|
+
* `@declaration.extension`; we re-key it to `@declaration.class` with a
|
|
28
|
+
* synthesized `@declaration.name` of the extended type so its members
|
|
29
|
+
* hoist onto `Foo`'s scope (`populateClassOwnedMembers` completes the
|
|
30
|
+
* ownership stamp) — the same mechanism C# uses for `partial class`.
|
|
31
|
+
*
|
|
32
|
+
* Pure given the input source text. No I/O, no globals consulted.
|
|
33
|
+
*/
|
|
34
|
+
import type { CaptureMatch } from '../../../../_shared/index.js';
|
|
35
|
+
export declare function emitSwiftScopeCaptures(sourceText: string, _filePath: string, cachedTree?: unknown): readonly CaptureMatch[];
|
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `emitScopeCaptures` for Swift.
|
|
3
|
+
*
|
|
4
|
+
* Drives the Swift scope query against tree-sitter-swift and groups raw
|
|
5
|
+
* matches into `CaptureMatch[]` for the central extractor. Synthesizes
|
|
6
|
+
* several streams on top of the raw query captures:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Decomposed imports** — each `import_declaration` is re-emitted
|
|
9
|
+
* with `@import.kind/source/name` markers (and `@import.testable`
|
|
10
|
+
* when present) so `interpretSwiftImport` recovers the ParsedImport
|
|
11
|
+
* shape without re-parsing raw text (`import-decomposer.ts`).
|
|
12
|
+
* 2. **Optional bindings** — `if let u = getUser()` / `guard let …`
|
|
13
|
+
* synthesize a `@type-binding.constructor` (name → callee) by
|
|
14
|
+
* walking the anchored statement (`@optional.binding`).
|
|
15
|
+
* 3. **Receiver bindings** — `self` (+ `super`) `@type-binding.self`
|
|
16
|
+
* anchors on every instance method/init (`receiver-binding.ts`).
|
|
17
|
+
* 4. **Signature bindings** — parameter-type and return-type
|
|
18
|
+
* `@type-binding.*` synthesized from the function node, because
|
|
19
|
+
* Swift's grammar reuses the `name:` field for func-name / param /
|
|
20
|
+
* return so a query can't disambiguate (`signature-bindings.ts`).
|
|
21
|
+
* 5. **Arity metadata** — `@declaration.parameter-count` etc. on
|
|
22
|
+
* function-like declarations and `@reference.arity` on call sites,
|
|
23
|
+
* so the registry can narrow by arity (`arity-metadata.ts`).
|
|
24
|
+
*
|
|
25
|
+
* Extension handling: a `class_declaration` whose `name:` is a
|
|
26
|
+
* `(user_type …)` is an `extension Foo { … }`. The query tags it
|
|
27
|
+
* `@declaration.extension`; we re-key it to `@declaration.class` with a
|
|
28
|
+
* synthesized `@declaration.name` of the extended type so its members
|
|
29
|
+
* hoist onto `Foo`'s scope (`populateClassOwnedMembers` completes the
|
|
30
|
+
* ownership stamp) — the same mechanism C# uses for `partial class`.
|
|
31
|
+
*
|
|
32
|
+
* Pure given the input source text. No I/O, no globals consulted.
|
|
33
|
+
*/
|
|
34
|
+
import { nodeIfType, nodeToCapture, syntheticCapture, walkNamedTree, } from '../../utils/ast-helpers.js';
|
|
35
|
+
import { splitSwiftImport } from './import-decomposer.js';
|
|
36
|
+
import { swiftQualifiedBaseTail } from './base-type.js';
|
|
37
|
+
import { computeSwiftArityMetadata } from './arity-metadata.js';
|
|
38
|
+
import { synthesizeSwiftReceiverBinding } from './receiver-binding.js';
|
|
39
|
+
import { synthesizeSwiftSignatureBindings } from './signature-bindings.js';
|
|
40
|
+
import { getSwiftParser, getSwiftScopeQuery } from './query.js';
|
|
41
|
+
import { recordCacheHit, recordCacheMiss } from './cache-stats.js';
|
|
42
|
+
import { getTreeSitterBufferSize } from '../../constants.js';
|
|
43
|
+
import { parseSourceSafe } from '../../../tree-sitter/safe-parse.js';
|
|
44
|
+
/** Declaration anchors that carry function-like arity metadata. */
|
|
45
|
+
const FUNCTION_DECL_TAGS = ['@declaration.method', '@declaration.constructor'];
|
|
46
|
+
/** tree-sitter-swift node types that carry arity. */
|
|
47
|
+
const FUNCTION_NODE_TYPES = [
|
|
48
|
+
'function_declaration',
|
|
49
|
+
'protocol_function_declaration',
|
|
50
|
+
'init_declaration',
|
|
51
|
+
];
|
|
52
|
+
/** Function-like nodes eligible for receiver-binding synthesis. */
|
|
53
|
+
const RECEIVER_NODE_TYPES = [
|
|
54
|
+
'function_declaration',
|
|
55
|
+
'init_declaration',
|
|
56
|
+
'deinit_declaration',
|
|
57
|
+
];
|
|
58
|
+
export function emitSwiftScopeCaptures(sourceText, _filePath, cachedTree) {
|
|
59
|
+
// Reuse the parse phase's cached Tree when available; otherwise parse.
|
|
60
|
+
let tree = cachedTree;
|
|
61
|
+
if (tree === undefined) {
|
|
62
|
+
tree = parseSourceSafe(getSwiftParser(), sourceText, undefined, {
|
|
63
|
+
bufferSize: getTreeSitterBufferSize(sourceText),
|
|
64
|
+
});
|
|
65
|
+
recordCacheMiss();
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
recordCacheHit();
|
|
69
|
+
}
|
|
70
|
+
const rawMatches = getSwiftScopeQuery().matches(tree.rootNode);
|
|
71
|
+
const out = [];
|
|
72
|
+
// Dedup genuine field reads by span — tree-sitter-swift can match the
|
|
73
|
+
// same navigation_expression twice (stacked nodes with identical spans).
|
|
74
|
+
const seenReadSpans = new Set();
|
|
75
|
+
for (const m of rawMatches) {
|
|
76
|
+
// Group captures by tag. Tree-sitter strips the leading `@`; put it
|
|
77
|
+
// back so the central extractor's prefix lookups work. Keep a
|
|
78
|
+
// parallel tag → node map so anchors resolve via nodeIfType (the
|
|
79
|
+
// captured node IS the node at that range — no findNodeAtRange
|
|
80
|
+
// root-walk, the O(matches × rootChildren) hot path fixed in #1918).
|
|
81
|
+
const grouped = {};
|
|
82
|
+
const nodeMap = {};
|
|
83
|
+
for (const c of m.captures) {
|
|
84
|
+
const tag = '@' + c.name;
|
|
85
|
+
grouped[tag] = nodeToCapture(tag, c.node);
|
|
86
|
+
nodeMap[tag] = c.node;
|
|
87
|
+
}
|
|
88
|
+
if (Object.keys(grouped).length === 0)
|
|
89
|
+
continue;
|
|
90
|
+
// ── Imports ──────────────────────────────────────────────────────
|
|
91
|
+
if (grouped['@import.statement'] !== undefined) {
|
|
92
|
+
const stmtNode = nodeIfType(nodeMap['@import.statement'], 'import_declaration');
|
|
93
|
+
if (stmtNode !== null) {
|
|
94
|
+
const decomposed = splitSwiftImport(stmtNode);
|
|
95
|
+
if (decomposed !== null) {
|
|
96
|
+
out.push(decomposed);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
out.push(grouped); // defensive fallback
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
// ── Optional bindings: if-let / guard-let. Synthesize a
|
|
104
|
+
// @type-binding.constructor (name → callee); chain-follow resolves
|
|
105
|
+
// the callee to its return type. ─────────────────────────────────
|
|
106
|
+
if (grouped['@optional.binding'] !== undefined) {
|
|
107
|
+
const stmtNode = nodeIfType(nodeMap['@optional.binding'], 'if_statement', 'guard_statement');
|
|
108
|
+
if (stmtNode !== null) {
|
|
109
|
+
for (const synth of synthesizeOptionalBindings(stmtNode))
|
|
110
|
+
out.push(synth);
|
|
111
|
+
}
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
// ── Field accesses: a `navigation_expression` (`obj.field`) is one of
|
|
115
|
+
// three things. Drop it when it's a call's callee (`u.save` in
|
|
116
|
+
// `u.save()` — the @reference.call.member query already covers that).
|
|
117
|
+
// Re-tag it as a write when it's the LHS of an assignment
|
|
118
|
+
// (`obj.field = x`) so a `write` ACCESSES edge emits (mirrors
|
|
119
|
+
// Kotlin/PHP `@reference.write.member`); otherwise keep it as a
|
|
120
|
+
// genuine read (`u.address`) and dedup identical spans. ───────────
|
|
121
|
+
if (grouped['@reference.read.member'] !== undefined) {
|
|
122
|
+
const navNode = nodeIfType(nodeMap['@reference.read.member'], 'navigation_expression');
|
|
123
|
+
if (navNode === null)
|
|
124
|
+
continue;
|
|
125
|
+
if (isSwiftMemberCallCallee(navNode))
|
|
126
|
+
continue;
|
|
127
|
+
if (isSwiftMemberWriteLhs(navNode)) {
|
|
128
|
+
// Re-tag the read anchor as a write. The extractor's anchor
|
|
129
|
+
// classifier reads the capture's `.name` (not the map key —
|
|
130
|
+
// `referenceKindFromAnchor` derives the site kind from
|
|
131
|
+
// `@reference.<kind>`), so we build a FRESH capture whose `.name`
|
|
132
|
+
// is the write tag rather than aliasing the read capture object
|
|
133
|
+
// (which would still classify as a read — a silent no-op). The
|
|
134
|
+
// sibling `@reference.name` / `@reference.receiver` captures carry
|
|
135
|
+
// over unchanged so the field + receiver still resolve. (Mirrors
|
|
136
|
+
// the constructor re-tag below and PHP's write re-tag.)
|
|
137
|
+
const reKeyed = { ...grouped };
|
|
138
|
+
delete reKeyed['@reference.read.member'];
|
|
139
|
+
reKeyed['@reference.write.member'] = nodeToCapture('@reference.write.member', navNode);
|
|
140
|
+
out.push(reKeyed);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const span = `${navNode.startIndex}-${navNode.endIndex}`;
|
|
144
|
+
if (seenReadSpans.has(span))
|
|
145
|
+
continue;
|
|
146
|
+
seenReadSpans.add(span);
|
|
147
|
+
out.push(grouped);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
// ── Extensions: re-key @declaration.extension → @declaration.class
|
|
151
|
+
// with the extended type's bare name so members hoist onto it. ────
|
|
152
|
+
if (grouped['@declaration.extension'] !== undefined) {
|
|
153
|
+
const extNode = nodeIfType(nodeMap['@declaration.extension'], 'class_declaration');
|
|
154
|
+
const reKeyed = { ...grouped };
|
|
155
|
+
delete reKeyed['@declaration.extension'];
|
|
156
|
+
reKeyed['@declaration.class'] = grouped['@declaration.extension'];
|
|
157
|
+
if (extNode !== null) {
|
|
158
|
+
const nameNode = extNode.childForFieldName('name');
|
|
159
|
+
// For a nested type `extension Foo.Bar`, the name is
|
|
160
|
+
// `(user_type (type_identifier Foo) (type_identifier Bar))`; the
|
|
161
|
+
// EXTENDED type is the trailing identifier `Bar` (lastNamedChild),
|
|
162
|
+
// not `Foo`. For a single `extension Foo`, first === last, so this
|
|
163
|
+
// is unchanged. Members must hoist onto `Bar`, not `Foo`.
|
|
164
|
+
const bare = nameNode?.type === 'user_type'
|
|
165
|
+
? (nameNode.lastNamedChild?.text ?? nameNode.text)
|
|
166
|
+
: (nameNode?.text ?? grouped['@declaration.name']?.text ?? '');
|
|
167
|
+
if (bare !== '') {
|
|
168
|
+
reKeyed['@declaration.name'] = syntheticCapture('@declaration.name', extNode, bare);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
out.push(reKeyed);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
// ── `let x = Type.init(...)` — explicit-initializer call. The
|
|
175
|
+
// constructor type-binding query only matches a bare `Type(...)`
|
|
176
|
+
// (simple_identifier callee); the `Type.init(...)` navigation form
|
|
177
|
+
// needs a synthesized `x: Type` binding so a later `x.method()`
|
|
178
|
+
// resolves. Emitted in ADDITION to the normal @declaration.property
|
|
179
|
+
// match, which still flows through to the final push below. ───────
|
|
180
|
+
if (grouped['@declaration.property'] !== undefined) {
|
|
181
|
+
const propNode = nodeIfType(nodeMap['@declaration.property'], 'property_declaration');
|
|
182
|
+
const synth = propNode === null ? null : synthesizeInitCtorBinding(propNode);
|
|
183
|
+
if (synth !== null)
|
|
184
|
+
out.push(synth);
|
|
185
|
+
}
|
|
186
|
+
// ── init: synthesize @declaration.name = "init" (no name field). ──
|
|
187
|
+
if (grouped['@declaration.constructor'] !== undefined &&
|
|
188
|
+
grouped['@declaration.name'] === undefined) {
|
|
189
|
+
const initNode = nodeIfType(nodeMap['@declaration.constructor'], 'init_declaration');
|
|
190
|
+
if (initNode !== null) {
|
|
191
|
+
grouped['@declaration.name'] = syntheticCapture('@declaration.name', initNode, 'init');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// ── @scope.function: arity + receiver + signature bindings. ──────
|
|
195
|
+
if (grouped['@scope.function'] !== undefined) {
|
|
196
|
+
const fnNodeForArity = nodeIfType(nodeMap['@scope.function'] ??
|
|
197
|
+
nodeMap['@declaration.method'] ??
|
|
198
|
+
nodeMap['@declaration.constructor'], ...FUNCTION_NODE_TYPES);
|
|
199
|
+
if (fnNodeForArity !== null)
|
|
200
|
+
attachArityMetadata(grouped, fnNodeForArity);
|
|
201
|
+
out.push(grouped);
|
|
202
|
+
const recvNode = nodeIfType(nodeMap['@scope.function'], ...RECEIVER_NODE_TYPES);
|
|
203
|
+
if (recvNode !== null) {
|
|
204
|
+
for (const synth of synthesizeSwiftReceiverBinding(recvNode))
|
|
205
|
+
out.push(synth);
|
|
206
|
+
}
|
|
207
|
+
const sigNode = nodeIfType(nodeMap['@scope.function'], ...FUNCTION_NODE_TYPES);
|
|
208
|
+
if (sigNode !== null) {
|
|
209
|
+
for (const synth of synthesizeSwiftSignatureBindings(sigNode))
|
|
210
|
+
out.push(synth);
|
|
211
|
+
}
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
// ── Arity metadata on function-like declarations (non-scope). ────
|
|
215
|
+
const declTag = FUNCTION_DECL_TAGS.find((t) => grouped[t] !== undefined);
|
|
216
|
+
if (declTag !== undefined) {
|
|
217
|
+
const fnNode = nodeIfType(nodeMap[declTag], ...FUNCTION_NODE_TYPES);
|
|
218
|
+
if (fnNode !== null)
|
|
219
|
+
attachArityMetadata(grouped, fnNode);
|
|
220
|
+
}
|
|
221
|
+
// ── Constructor calls: Swift has no `new`, so `Foo()` is a free call
|
|
222
|
+
// whose callee is a type. Re-tag an UpperCamelCase free-call callee as
|
|
223
|
+
// a constructor reference so the resolver's constructor branch targets
|
|
224
|
+
// the type's Constructor/Class (mirrors how other no-`new` languages
|
|
225
|
+
// classify `Type(...)`). Types are UpperCamelCase by Swift convention;
|
|
226
|
+
// functions are lowerCamelCase — so the first-letter test is a reliable
|
|
227
|
+
// syntactic discriminator with no scope lookup. ──────────────────────
|
|
228
|
+
if (grouped['@reference.call.free'] !== undefined) {
|
|
229
|
+
const calleeName = grouped['@reference.name']?.text ?? '';
|
|
230
|
+
const first = calleeName.charAt(0);
|
|
231
|
+
if (first !== '' && first === first.toUpperCase() && first !== first.toLowerCase()) {
|
|
232
|
+
// Build a fresh capture whose `.name` is the constructor tag — the
|
|
233
|
+
// extractor's anchor classifier reads the capture's `.name`, not the
|
|
234
|
+
// map key, so reusing the free-call capture object would keep
|
|
235
|
+
// classifying it as a free call (silent no-op).
|
|
236
|
+
const callNode = nodeMap['@reference.call.free'];
|
|
237
|
+
grouped['@reference.call.constructor'] = nodeToCapture('@reference.call.constructor', callNode);
|
|
238
|
+
nodeMap['@reference.call.constructor'] = callNode;
|
|
239
|
+
delete grouped['@reference.call.free'];
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// ── @reference.arity on call sites. ──────────────────────────────
|
|
243
|
+
const callTag = ['@reference.call.free', '@reference.call.member', '@reference.call.constructor'].find((t) => grouped[t] !== undefined);
|
|
244
|
+
if (callTag !== undefined && grouped['@reference.arity'] === undefined) {
|
|
245
|
+
const callNode = nodeIfType(nodeMap[callTag], 'call_expression');
|
|
246
|
+
if (callNode !== null) {
|
|
247
|
+
grouped['@reference.arity'] = syntheticCapture('@reference.arity', callNode, String(countCallArguments(callNode)));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
out.push(grouped);
|
|
251
|
+
}
|
|
252
|
+
// ── Emit inheritance references for scope-resolution EXTENDS / IMPLEMENTS ──
|
|
253
|
+
// Walk every class/struct/enum/actor/extension and protocol declaration's
|
|
254
|
+
// inheritance specifiers and synthesize `@reference.inherits` captures so
|
|
255
|
+
// the registry-primary path emits EXTENDS / IMPLEMENTS (mirrors C++ /
|
|
256
|
+
// C# / Java). Without this, Swift inheritance edges came only from the
|
|
257
|
+
// legacy heritage-capture leg (removed in #942), which the worker pipeline
|
|
258
|
+
// drops for registry-primary languages (issue #1951).
|
|
259
|
+
out.push(...synthesizeSwiftInheritanceReferences(tree.rootNode));
|
|
260
|
+
return out;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Synthesize `@reference.inherits` captures from Swift inheritance
|
|
264
|
+
* specifiers so the registry-primary scope-resolution path emits
|
|
265
|
+
* EXTENDS / IMPLEMENTS edges (mirrors `synthesizeCsharpInheritanceReferences`
|
|
266
|
+
* / `emitCppInheritanceCaptures`). Without this, Swift inheritance edges came
|
|
267
|
+
* only from the legacy heritage-capture leg (removed in #942), dropped for
|
|
268
|
+
* registry-primary languages in the worker pipeline (issue #1951).
|
|
269
|
+
*
|
|
270
|
+
* Scope matches the legacy SWIFT_QUERIES heritage blocks exactly: a
|
|
271
|
+
* `class_declaration` (class / struct / enum / actor / extension all share
|
|
272
|
+
* this node) or a `protocol_declaration`, each with an
|
|
273
|
+
* `(inheritance_specifier inherits_from: (user_type (type_identifier)))`.
|
|
274
|
+
* The EXTENDS-vs-IMPLEMENTS split is decided downstream from the resolved
|
|
275
|
+
* target's symbol kind (`preEmitInheritanceEdges` → Interface = IMPLEMENTS,
|
|
276
|
+
* else EXTENDS), so every base is emitted with the same `inherits` kind here.
|
|
277
|
+
* The base lookup name is normalized to its bare simple identifier
|
|
278
|
+
* (`SomeProtocol<T>` → `SomeProtocol`, `Outer.Inner` → `Inner`) to match the
|
|
279
|
+
* V1 simple-name `findClassBindingInScope` contract.
|
|
280
|
+
*/
|
|
281
|
+
function synthesizeSwiftInheritanceReferences(root) {
|
|
282
|
+
const out = [];
|
|
283
|
+
walkNamedTree(root, (node) => {
|
|
284
|
+
if (node.type !== 'class_declaration' && node.type !== 'protocol_declaration')
|
|
285
|
+
return;
|
|
286
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
287
|
+
const child = node.namedChild(i);
|
|
288
|
+
if (child === null || child.type !== 'inheritance_specifier')
|
|
289
|
+
continue;
|
|
290
|
+
const inheritsFrom = child.childForFieldName('inherits_from') ?? child.firstNamedChild;
|
|
291
|
+
if (inheritsFrom === null)
|
|
292
|
+
continue;
|
|
293
|
+
const nameNode = swiftBaseTypeIdentifier(inheritsFrom);
|
|
294
|
+
if (nameNode === null)
|
|
295
|
+
continue;
|
|
296
|
+
out.push({
|
|
297
|
+
'@reference.inherits': nodeToCapture('@reference.inherits', child),
|
|
298
|
+
'@reference.name': nodeToCapture('@reference.name', nameNode),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
return out;
|
|
303
|
+
}
|
|
304
|
+
/** Normalize an `inherits_from` node to its bare simple identifier node.
|
|
305
|
+
* Only a `user_type`-shaped base contributes an edge; its trailing
|
|
306
|
+
* `type_identifier` (the actual base — see `swiftQualifiedBaseTail`) is
|
|
307
|
+
* returned. Returns null for any other base shape (e.g. a tuple /
|
|
308
|
+
* function-type conformance), so no edge is synthesized — matching the legacy
|
|
309
|
+
* query's `user_type` gate. */
|
|
310
|
+
function swiftBaseTypeIdentifier(inheritsFrom) {
|
|
311
|
+
if (inheritsFrom.type === 'type_identifier')
|
|
312
|
+
return inheritsFrom;
|
|
313
|
+
if (inheritsFrom.type !== 'user_type')
|
|
314
|
+
return null;
|
|
315
|
+
return swiftQualifiedBaseTail(inheritsFrom);
|
|
316
|
+
}
|
|
317
|
+
/** Pre-order walk over named children (mirrors C#'s `visit`). */
|
|
318
|
+
/** Synthesize a `@type-binding.constructor` for EACH clause of an
|
|
319
|
+
* if-let / guard-let optional binding:
|
|
320
|
+
* `if let u = getUser()` → one binding `u: getUser`
|
|
321
|
+
* `if let a = makeA(), let b = makeB()` → two bindings `a: makeA`, `b: makeB`
|
|
322
|
+
* (chain-follow resolves each callee → its return type).
|
|
323
|
+
*
|
|
324
|
+
* The statement has a FLAT child list (verified, tree-sitter-swift 0.7.1):
|
|
325
|
+
* each clause is `value_binding_pattern` · `simple_identifier` (the bound
|
|
326
|
+
* name) · `=` · value, where value is a `call_expression` directly, or an
|
|
327
|
+
* `await_expression` / `try_expression` wrapping one. NOTE: every bound
|
|
328
|
+
* name carries the `bound_identifier` field, but `childForFieldName`
|
|
329
|
+
* returns only the FIRST — so we walk the children in order instead.
|
|
330
|
+
*
|
|
331
|
+
* Clauses whose value isn't a call (`if let a = optionalVar`) are skipped
|
|
332
|
+
* WITHOUT consuming the following clause's call. Single-clause output is
|
|
333
|
+
* byte-identical to the prior single-binding implementation. `if_statement`
|
|
334
|
+
* and `guard_statement` share this shape and are handled identically. */
|
|
335
|
+
function synthesizeOptionalBindings(stmtNode) {
|
|
336
|
+
const out = [];
|
|
337
|
+
// State machine over the flat clause list. `pendingName` is the bound
|
|
338
|
+
// name of the clause currently awaiting its value; `awaitingName` is set
|
|
339
|
+
// right after a `value_binding_pattern` so the next `simple_identifier`
|
|
340
|
+
// is taken as the name (not as a value).
|
|
341
|
+
let pendingName = null;
|
|
342
|
+
let awaitingName = false;
|
|
343
|
+
for (let i = 0; i < stmtNode.childCount; i++) {
|
|
344
|
+
const child = stmtNode.child(i);
|
|
345
|
+
if (child === null)
|
|
346
|
+
continue;
|
|
347
|
+
// The clause list ends at the body / else / statements.
|
|
348
|
+
if (child.type === 'statements' || child.type === '{' || child.text === 'else')
|
|
349
|
+
break;
|
|
350
|
+
if (child.type === 'value_binding_pattern') {
|
|
351
|
+
// A new clause begins; any prior clause whose value never arrived was
|
|
352
|
+
// a non-call clause — drop it without consuming this one.
|
|
353
|
+
pendingName = null;
|
|
354
|
+
awaitingName = true;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (awaitingName) {
|
|
358
|
+
if (child.type === 'simple_identifier') {
|
|
359
|
+
pendingName = child;
|
|
360
|
+
awaitingName = false;
|
|
361
|
+
}
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (pendingName === null)
|
|
365
|
+
continue;
|
|
366
|
+
if (child.text === '=' || child.text === ',')
|
|
367
|
+
continue;
|
|
368
|
+
// First non-`=` node after the name is the clause value. Take a binding
|
|
369
|
+
// only when it's a call; clear pendingName either way so a non-call
|
|
370
|
+
// clause doesn't steal the next clause's call.
|
|
371
|
+
const callee = optionalBindingCallee(child);
|
|
372
|
+
if (callee !== null) {
|
|
373
|
+
out.push({
|
|
374
|
+
'@type-binding.constructor': nodeToCapture('@type-binding.constructor', stmtNode),
|
|
375
|
+
'@type-binding.name': syntheticCapture('@type-binding.name', pendingName, pendingName.text),
|
|
376
|
+
'@type-binding.type': syntheticCapture('@type-binding.type', callee, callee.text),
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
pendingName = null;
|
|
380
|
+
}
|
|
381
|
+
return out;
|
|
382
|
+
}
|
|
383
|
+
/** Resolve an optional-binding clause VALUE node to its call callee
|
|
384
|
+
* (`simple_identifier`), unwrapping a single `await`/`try` layer. Returns
|
|
385
|
+
* null when the value isn't a bare-identifier call (e.g. `optionalVar`,
|
|
386
|
+
* or `obj.method()` — which must NOT bind to `obj`). */
|
|
387
|
+
function optionalBindingCallee(value) {
|
|
388
|
+
let call = null;
|
|
389
|
+
if (value.type === 'call_expression') {
|
|
390
|
+
call = value;
|
|
391
|
+
}
|
|
392
|
+
else if (value.type === 'await_expression' || value.type === 'try_expression') {
|
|
393
|
+
for (let j = 0; j < value.namedChildCount; j++) {
|
|
394
|
+
const inner = value.namedChild(j);
|
|
395
|
+
if (inner !== null && inner.type === 'call_expression') {
|
|
396
|
+
call = inner;
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (call === null)
|
|
402
|
+
return null;
|
|
403
|
+
const callee = call.namedChild(0);
|
|
404
|
+
return callee !== null && callee.type === 'simple_identifier' ? callee : null;
|
|
405
|
+
}
|
|
406
|
+
/** Synthesize a `@type-binding.constructor` for `let x = Type.init(...)`.
|
|
407
|
+
* The property's `value:` is a call_expression whose callee is a
|
|
408
|
+
* navigation_expression `Type.init`; bind `x` to the navigation target
|
|
409
|
+
* `Type` (the explicit-initializer form of `let x = Type(...)`). Returns
|
|
410
|
+
* null for any other value shape (e.g. `let x = obj.method()`, which must
|
|
411
|
+
* NOT bind x to `obj`). */
|
|
412
|
+
function synthesizeInitCtorBinding(propNode) {
|
|
413
|
+
const namePattern = propNode.childForFieldName('name');
|
|
414
|
+
const nameNode = namePattern?.childForFieldName('bound_identifier') ?? null;
|
|
415
|
+
if (nameNode === null)
|
|
416
|
+
return null;
|
|
417
|
+
const value = propNode.childForFieldName('value');
|
|
418
|
+
if (value === null || value.type !== 'call_expression')
|
|
419
|
+
return null;
|
|
420
|
+
const callee = value.namedChild(0);
|
|
421
|
+
if (callee === null || callee.type !== 'navigation_expression')
|
|
422
|
+
return null;
|
|
423
|
+
const target = callee.childForFieldName('target');
|
|
424
|
+
const suffix = callee.childForFieldName('suffix');
|
|
425
|
+
const member = suffix?.childForFieldName('suffix') ?? null;
|
|
426
|
+
if (target === null ||
|
|
427
|
+
target.type !== 'simple_identifier' ||
|
|
428
|
+
member === null ||
|
|
429
|
+
member.text !== 'init') {
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
const m = {
|
|
433
|
+
'@type-binding.constructor': nodeToCapture('@type-binding.constructor', propNode),
|
|
434
|
+
'@type-binding.name': syntheticCapture('@type-binding.name', nameNode, nameNode.text),
|
|
435
|
+
'@type-binding.type': syntheticCapture('@type-binding.type', target, target.text),
|
|
436
|
+
};
|
|
437
|
+
return m;
|
|
438
|
+
}
|
|
439
|
+
/** Is this navigation_expression the callee of a call (`a.b` in `a.b()`)?
|
|
440
|
+
* That is a member call, already captured by @reference.call.member, so
|
|
441
|
+
* the read.member emission must be dropped. */
|
|
442
|
+
function isSwiftMemberCallCallee(navNode) {
|
|
443
|
+
return navNode.parent?.type === 'call_expression';
|
|
444
|
+
}
|
|
445
|
+
/** Is this navigation_expression the LHS of an assignment (`a.b = …` — a
|
|
446
|
+
* field write)? tree-sitter-swift wraps the assignment target in a
|
|
447
|
+
* `directly_assignable_expression`, so the write discriminator is the
|
|
448
|
+
* GRANDPARENT `assignment` reached via that wrapper — NOT a direct
|
|
449
|
+
* `parent.type === 'assignment'` (which never matches; the old guard was
|
|
450
|
+
* dead). The inner `obj.a` of `obj.a.b = x` has parent
|
|
451
|
+
* `navigation_expression` (the outer access), so it is correctly NOT a
|
|
452
|
+
* write — only the outermost nav under `directly_assignable_expression`
|
|
453
|
+
* is the write target. */
|
|
454
|
+
function isSwiftMemberWriteLhs(navNode) {
|
|
455
|
+
const parent = navNode.parent;
|
|
456
|
+
if (parent === null || parent.type !== 'directly_assignable_expression')
|
|
457
|
+
return false;
|
|
458
|
+
return parent.parent?.type === 'assignment';
|
|
459
|
+
}
|
|
460
|
+
/** Attach @declaration.parameter-count / required-parameter-count /
|
|
461
|
+
* parameter-types synthesized from a function-like node. */
|
|
462
|
+
function attachArityMetadata(grouped, fnNode) {
|
|
463
|
+
const arity = computeSwiftArityMetadata(fnNode);
|
|
464
|
+
if (arity.parameterCount !== undefined) {
|
|
465
|
+
grouped['@declaration.parameter-count'] = syntheticCapture('@declaration.parameter-count', fnNode, String(arity.parameterCount));
|
|
466
|
+
}
|
|
467
|
+
if (arity.requiredParameterCount !== undefined) {
|
|
468
|
+
grouped['@declaration.required-parameter-count'] = syntheticCapture('@declaration.required-parameter-count', fnNode, String(arity.requiredParameterCount));
|
|
469
|
+
}
|
|
470
|
+
if (arity.parameterTypes !== undefined) {
|
|
471
|
+
grouped['@declaration.parameter-types'] = syntheticCapture('@declaration.parameter-types', fnNode, JSON.stringify(arity.parameterTypes));
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
/** Count call arguments: the `value_argument` named children of the
|
|
475
|
+
* call's `call_suffix > value_arguments`. */
|
|
476
|
+
function countCallArguments(callNode) {
|
|
477
|
+
for (let i = 0; i < callNode.namedChildCount; i++) {
|
|
478
|
+
const child = callNode.namedChild(i);
|
|
479
|
+
if (child === null || child.type !== 'call_suffix')
|
|
480
|
+
continue;
|
|
481
|
+
for (let j = 0; j < child.namedChildCount; j++) {
|
|
482
|
+
const va = child.namedChild(j);
|
|
483
|
+
if (va === null || va.type !== 'value_arguments')
|
|
484
|
+
continue;
|
|
485
|
+
let n = 0;
|
|
486
|
+
for (let k = 0; k < va.namedChildCount; k++) {
|
|
487
|
+
const arg = va.namedChild(k);
|
|
488
|
+
if (arg !== null && arg.type === 'value_argument')
|
|
489
|
+
n++;
|
|
490
|
+
}
|
|
491
|
+
return n;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return 0;
|
|
495
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 type { ParsedFile } from '../../../../_shared/index.js';
|
|
32
|
+
import type { KnowledgeGraph } from '../../../graph/types.js';
|
|
33
|
+
import type { GraphNodeLookup } from '../../scope-resolution/graph-bridge/node-lookup.js';
|
|
34
|
+
export declare function emitSwiftImplicitImportEdges(graph: KnowledgeGraph, parsedFiles: readonly ParsedFile[], _nodeLookup: GraphNodeLookup, resolutionConfig?: unknown): void;
|