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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nodeIfType, nodeToCapture, syntheticCapture, walkNamedTree, } from '../../utils/ast-helpers.js';
|
|
2
2
|
import { getRustParser, getRustScopeQuery } from './query.js';
|
|
3
3
|
import { recordRustCacheHit, recordRustCacheMiss } from './cache-stats.js';
|
|
4
4
|
import { splitRustUseDeclaration } from './import-decomposer.js';
|
|
@@ -20,18 +20,24 @@ export function emitRustScopeCaptures(sourceText, _filePath, cachedTree) {
|
|
|
20
20
|
const out = [];
|
|
21
21
|
for (const m of rawMatches) {
|
|
22
22
|
const grouped = {};
|
|
23
|
+
// Parallel tag -> captured SyntaxNode map: the query hands us each matched
|
|
24
|
+
// node as c.node, so anchors resolve via a type-guarded lookup (nodeIfType)
|
|
25
|
+
// instead of re-deriving them with findNodeAtRange(tree.rootNode, ...) per
|
|
26
|
+
// match — the O(matches x rootChildren) root-walk fixed for go #1915 /
|
|
27
|
+
// python #1918, mirrored here.
|
|
28
|
+
const nodeMap = {};
|
|
23
29
|
for (const c of m.captures) {
|
|
24
30
|
const tag = '@' + c.name;
|
|
25
31
|
if (tag.startsWith('@_'))
|
|
26
32
|
continue;
|
|
27
33
|
grouped[tag] = nodeToCapture(tag, c.node);
|
|
34
|
+
nodeMap[tag] = c.node;
|
|
28
35
|
}
|
|
29
36
|
if (Object.keys(grouped).length === 0)
|
|
30
37
|
continue;
|
|
31
38
|
// Decompose use declarations into individual import captures
|
|
32
39
|
if (grouped['@import.statement'] !== undefined) {
|
|
33
|
-
const
|
|
34
|
-
const useNode = findNodeAtRange(tree.rootNode, anchor.range, 'use_declaration');
|
|
40
|
+
const useNode = nodeIfType(nodeMap['@import.statement'], 'use_declaration');
|
|
35
41
|
if (useNode !== null) {
|
|
36
42
|
out.push(...splitRustUseDeclaration(useNode));
|
|
37
43
|
continue;
|
|
@@ -40,8 +46,7 @@ export function emitRustScopeCaptures(sourceText, _filePath, cachedTree) {
|
|
|
40
46
|
// Synthesize self receiver bindings for methods inside impl blocks
|
|
41
47
|
let cachedImplLookup;
|
|
42
48
|
if (grouped['@scope.function'] !== undefined) {
|
|
43
|
-
const
|
|
44
|
-
const fnNode = findNodeAtRange(tree.rootNode, scopeCap.range, 'function_item');
|
|
49
|
+
const fnNode = nodeIfType(nodeMap['@scope.function'], 'function_item');
|
|
45
50
|
if (fnNode !== null) {
|
|
46
51
|
const implNode = findEnclosingImpl(fnNode);
|
|
47
52
|
cachedImplLookup = { fnNode, implNode };
|
|
@@ -53,7 +58,7 @@ export function emitRustScopeCaptures(sourceText, _filePath, cachedTree) {
|
|
|
53
58
|
// Attach declaration arity for functions/methods
|
|
54
59
|
const declAnchor = grouped['@declaration.function'];
|
|
55
60
|
if (declAnchor !== undefined) {
|
|
56
|
-
const fnNode =
|
|
61
|
+
const fnNode = nodeIfType(nodeMap['@declaration.function'], 'function_item');
|
|
57
62
|
if (fnNode !== null) {
|
|
58
63
|
const implNode = cachedImplLookup?.fnNode === fnNode
|
|
59
64
|
? cachedImplLookup.implNode
|
|
@@ -86,7 +91,7 @@ export function emitRustScopeCaptures(sourceText, _filePath, cachedTree) {
|
|
|
86
91
|
if (grouped['@type-binding.return'] !== undefined &&
|
|
87
92
|
grouped['@type-binding.name'] !== undefined) {
|
|
88
93
|
const tbReturnAnchor = grouped['@type-binding.return'];
|
|
89
|
-
const fnNode =
|
|
94
|
+
const fnNode = nodeIfType(nodeMap['@type-binding.return'], 'function_item');
|
|
90
95
|
if (fnNode !== null) {
|
|
91
96
|
const implNode = findEnclosingImpl(fnNode);
|
|
92
97
|
if (implNode !== null) {
|
|
@@ -99,12 +104,11 @@ export function emitRustScopeCaptures(sourceText, _filePath, cachedTree) {
|
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
106
|
// Attach call arity for call expressions
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
const callNode =
|
|
107
|
-
findNodeAtRange(tree.rootNode, callAnchor.range, 'struct_expression');
|
|
107
|
+
const callAnchorNode = nodeMap['@reference.call.free'] ??
|
|
108
|
+
nodeMap['@reference.call.member'] ??
|
|
109
|
+
nodeMap['@reference.call.constructor'];
|
|
110
|
+
if (callAnchorNode !== undefined) {
|
|
111
|
+
const callNode = nodeIfType(callAnchorNode, 'call_expression', 'struct_expression');
|
|
108
112
|
if (callNode !== null) {
|
|
109
113
|
const arity = computeRustCallArity(callNode);
|
|
110
114
|
grouped['@reference.arity'] = syntheticCapture('@reference.arity', callNode, String(arity));
|
|
@@ -112,8 +116,86 @@ export function emitRustScopeCaptures(sourceText, _filePath, cachedTree) {
|
|
|
112
116
|
}
|
|
113
117
|
out.push(grouped);
|
|
114
118
|
}
|
|
119
|
+
out.push(...synthesizeRustInheritanceReferences(tree.rootNode));
|
|
115
120
|
return out;
|
|
116
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Synthesize `@reference.inherits` captures from Rust trait `impl` blocks so
|
|
124
|
+
* the registry-primary scope-resolution path can emit the IMPLEMENTS edge for
|
|
125
|
+
* `impl Trait for Struct` (mirrors the legacy heritage-capture leg, removed in
|
|
126
|
+
* #942, which the worker pipeline drops for registry-primary languages — #1951).
|
|
127
|
+
*
|
|
128
|
+
* Rust inheritance is structurally unlike a base list on a type declaration:
|
|
129
|
+
* the relationship lives on `impl_item { trait: T, type: S }`, meaning
|
|
130
|
+
* `S IMPLEMENTS T`. The shared `preEmitInheritanceEdges` derives an edge's
|
|
131
|
+
* SOURCE from the enclosing *class* def of the `@reference.inherits` site, but
|
|
132
|
+
* an `impl_item` scope owns no class-like def (the struct `S` is declared
|
|
133
|
+
* elsewhere as a `struct_item`), so `findEnclosingClassDef` returns undefined
|
|
134
|
+
* and that pass emits nothing for these sites (it still marks them handled,
|
|
135
|
+
* suppressing the generic reference bridge). The real IMPLEMENTS edge is
|
|
136
|
+
* therefore emitted by `rustScopeResolver.emitHeritageEdges`, which reads these
|
|
137
|
+
* sites back from `parsedFiles[*].referenceSites`.
|
|
138
|
+
*
|
|
139
|
+
* To carry both ends of the relationship through a single reference site we
|
|
140
|
+
* encode: `@reference.name` = the trait `T` (becomes `site.name`, the IMPLEMENTS
|
|
141
|
+
* target) and `@reference.receiver` = the struct `S` (becomes
|
|
142
|
+
* `site.explicitReceiver.name`, the IMPLEMENTS source).
|
|
143
|
+
*
|
|
144
|
+
* Parity is intentionally pinned to the legacy heritage query's `impl_item`
|
|
145
|
+
* patterns: both `trait:` and `type:` normalize to the base's trailing bare
|
|
146
|
+
* `type_identifier` — directly, via a `scoped_type_identifier`'s `name:` tail
|
|
147
|
+
* (`crate::traits::Drawable` → `Drawable`; KTD-1 tail resolution), or through a
|
|
148
|
+
* `generic_type`'s `type:` field (which may itself be either). Inherent impls
|
|
149
|
+
* (`impl S {}`, no `trait:` field) still emit nothing.
|
|
150
|
+
*/
|
|
151
|
+
function synthesizeRustInheritanceReferences(root) {
|
|
152
|
+
const out = [];
|
|
153
|
+
walkNamedTree(root, (node) => {
|
|
154
|
+
if (node.type !== 'impl_item')
|
|
155
|
+
return;
|
|
156
|
+
const traitField = node.childForFieldName('trait');
|
|
157
|
+
const typeField = node.childForFieldName('type');
|
|
158
|
+
if (traitField === null || typeField === null)
|
|
159
|
+
return;
|
|
160
|
+
const traitName = bareTypeIdentifier(traitField);
|
|
161
|
+
const structName = bareTypeIdentifier(typeField);
|
|
162
|
+
if (traitName === null || structName === null)
|
|
163
|
+
return;
|
|
164
|
+
out.push({
|
|
165
|
+
'@reference.inherits': nodeToCapture('@reference.inherits', traitName),
|
|
166
|
+
'@reference.name': nodeToCapture('@reference.name', traitName),
|
|
167
|
+
'@reference.receiver': syntheticCapture('@reference.receiver', structName, structName.text),
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Normalize a `trait:` / `type:` impl_item field to the base's trailing bare
|
|
174
|
+
* `type_identifier`, matching exactly the node shapes the legacy heritage
|
|
175
|
+
* query accepted (kept at parity — see the `impl_item` heritage arm in
|
|
176
|
+
* tree-sitter-queries.ts):
|
|
177
|
+
* - `type_identifier` → the node itself
|
|
178
|
+
* - `scoped_type_identifier name: (type_identifier)` → the trailing `name:` id
|
|
179
|
+
* (`crate::traits::Drawable` → `Drawable`; KTD-1 tail resolution — the
|
|
180
|
+
* simple name then resolves scope-aware via `emitRustTraitImplEdges`)
|
|
181
|
+
* - `generic_type type: <any of the above>` → recurse into `type:`
|
|
182
|
+
* (covers `Box<T>` and `m::Wrapped<T>`)
|
|
183
|
+
* Any other node type returns null (no edge), keeping this emitter at parity
|
|
184
|
+
* with the legacy query.
|
|
185
|
+
*/
|
|
186
|
+
function bareTypeIdentifier(node) {
|
|
187
|
+
if (node.type === 'type_identifier')
|
|
188
|
+
return node;
|
|
189
|
+
if (node.type === 'scoped_type_identifier') {
|
|
190
|
+
const tail = node.childForFieldName('name');
|
|
191
|
+
return tail !== null && tail.type === 'type_identifier' ? tail : null;
|
|
192
|
+
}
|
|
193
|
+
if (node.type === 'generic_type') {
|
|
194
|
+
const inner = node.childForFieldName('type');
|
|
195
|
+
return inner !== null ? bareTypeIdentifier(inner) : null;
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
117
199
|
function findEnclosingImpl(node) {
|
|
118
200
|
let current = node.parent;
|
|
119
201
|
while (current !== null) {
|
|
@@ -7,6 +7,7 @@ const RUST_SCOPE_QUERY = `
|
|
|
7
7
|
(trait_item) @scope.class
|
|
8
8
|
(impl_item) @scope.class
|
|
9
9
|
(enum_item) @scope.class
|
|
10
|
+
(union_item) @scope.class
|
|
10
11
|
(function_item) @scope.function
|
|
11
12
|
(closure_expression) @scope.function
|
|
12
13
|
(block) @scope.block
|
|
@@ -29,6 +30,26 @@ const RUST_SCOPE_QUERY = `
|
|
|
29
30
|
(enum_item
|
|
30
31
|
name: (type_identifier) @declaration.name) @declaration.enum
|
|
31
32
|
|
|
33
|
+
;; Declarations — union
|
|
34
|
+
;; Deliberately tagged @declaration.struct (→ Struct label), NOT a
|
|
35
|
+
;; @declaration.union: every registry-primary resolution gate —
|
|
36
|
+
;; isLinkableLabel (node-lookup.ts), CALLABLE_OR_TYPE_LIKE
|
|
37
|
+
;; (finalize-algorithm.ts), ClassLikeNodeLabel (class-types.ts) — includes
|
|
38
|
+
;; Struct but EXCLUDES Union, so a Union-labeled node would be an
|
|
39
|
+
;; unresolvable orphan. A Rust union is a type whose literal is a real
|
|
40
|
+
;; constructor, so Struct is both the resolvable and the semantically
|
|
41
|
+
;; honest label here. #1934 F71.
|
|
42
|
+
(union_item
|
|
43
|
+
name: (type_identifier) @declaration.name) @declaration.struct
|
|
44
|
+
|
|
45
|
+
;; Declarations — macro (macro_rules! foo { ... })
|
|
46
|
+
;; Captured as @declaration.macro → Macro label. A macro invocation
|
|
47
|
+
;; (@reference.macro, below) resolves to this definition via MacroRegistry,
|
|
48
|
+
;; whose acceptedKinds is ['Macro'] ONLY — so an invoked macro never binds
|
|
49
|
+
;; to a same-named free function (log!() is not fn log). #1934 F72.
|
|
50
|
+
(macro_definition
|
|
51
|
+
name: (identifier) @declaration.name) @declaration.macro
|
|
52
|
+
|
|
32
53
|
;; Declarations — function (top-level or inside mod)
|
|
33
54
|
(function_item
|
|
34
55
|
name: (identifier) @declaration.name) @declaration.function
|
|
@@ -39,6 +60,10 @@ const RUST_SCOPE_QUERY = `
|
|
|
39
60
|
type: (_) @declaration.field-type) @declaration.field
|
|
40
61
|
|
|
41
62
|
;; Declarations — variables (let bindings)
|
|
63
|
+
;; Uses pattern:(identifier) — works for let x and let mut x (mutable_specifier
|
|
64
|
+
;; is a sibling, not a wrapper). Destructuring patterns like let (a, b) use
|
|
65
|
+
;; tuple_pattern etc. which pattern:(identifier) intentionally does not match;
|
|
66
|
+
;; capturing them with (_) would produce "(a, b)" as the name, which is useless.
|
|
42
67
|
(let_declaration
|
|
43
68
|
pattern: (identifier) @declaration.name) @declaration.variable
|
|
44
69
|
|
|
@@ -108,8 +133,46 @@ const RUST_SCOPE_QUERY = `
|
|
|
108
133
|
name: (identifier) @reference.name)) @reference.call.free
|
|
109
134
|
|
|
110
135
|
;; References — constructor calls (struct literal)
|
|
136
|
+
;; tree-sitter-rust gives struct_expression.name one of three node types
|
|
137
|
+
;; (type_identifier | scoped_type_identifier | generic_type_with_turbofish);
|
|
138
|
+
;; the turbofish form additionally nests either a type_identifier or a
|
|
139
|
+
;; scoped_identifier. We enumerate all four shapes below so the capture is
|
|
140
|
+
;; always the trailing identifier (resolved scope-aware), not the full path:
|
|
141
|
+
;; bare Foo {}
|
|
142
|
+
;; scoped foo::bar::Baz {}
|
|
143
|
+
;; turbofish Foo::<T> {}
|
|
144
|
+
;; scoped+turbofish foo::Bar::<T> {}
|
|
145
|
+
(struct_expression
|
|
146
|
+
name: (type_identifier) @reference.name) @reference.call.constructor
|
|
147
|
+
|
|
148
|
+
;; Scoped struct (foo::bar::Baz {})
|
|
149
|
+
(struct_expression
|
|
150
|
+
name: (scoped_type_identifier
|
|
151
|
+
name: (type_identifier) @reference.name)) @reference.call.constructor
|
|
152
|
+
|
|
153
|
+
;; Turbofish struct (Foo::<T> {})
|
|
154
|
+
(struct_expression
|
|
155
|
+
name: (generic_type_with_turbofish
|
|
156
|
+
type: (type_identifier) @reference.name)) @reference.call.constructor
|
|
157
|
+
|
|
158
|
+
;; Scoped + turbofish struct (foo::Bar::<T> {}) — the turbofish wraps a
|
|
159
|
+
;; scoped_identifier whose tail is an identifier (not a type_identifier).
|
|
111
160
|
(struct_expression
|
|
112
|
-
name: (
|
|
161
|
+
name: (generic_type_with_turbofish
|
|
162
|
+
type: (scoped_identifier
|
|
163
|
+
name: (identifier) @reference.name))) @reference.call.constructor
|
|
164
|
+
|
|
165
|
+
;; References — macro invocations (disjoint namespace from functions)
|
|
166
|
+
;; Resolved via MacroRegistry → Macro defs only (never fn of the same name).
|
|
167
|
+
(macro_invocation
|
|
168
|
+
macro: (identifier) @reference.name) @reference.macro
|
|
169
|
+
|
|
170
|
+
;; Scoped macro invocation (log::info!(…)) — capture the tail identifier,
|
|
171
|
+
;; mirroring the scoped free-call pattern above, so the resolved name is
|
|
172
|
+
;; the tail (info), not the full path (log::info).
|
|
173
|
+
(macro_invocation
|
|
174
|
+
macro: (scoped_identifier
|
|
175
|
+
name: (identifier) @reference.name)) @reference.macro
|
|
113
176
|
|
|
114
177
|
;; References — field reads
|
|
115
178
|
(field_expression
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getRustParser } from './query.js';
|
|
2
2
|
import { getTreeSitterBufferSize } from '../../constants.js';
|
|
3
|
-
import { parseSourceSafe } from '../../../tree-sitter/safe-parse.js';
|
|
3
|
+
import { parseSourceSafe, ParseTimeoutError } from '../../../tree-sitter/safe-parse.js';
|
|
4
|
+
import { logger } from '../../../logger.js';
|
|
4
5
|
/**
|
|
5
6
|
* Populate type bindings for patterns and iterators that the tree-sitter
|
|
6
7
|
* query can't handle (they need runtime type lookup, not just syntax).
|
|
@@ -20,10 +21,24 @@ export function populateRustRangeBindings(parsedFiles, _indexes, ctx) {
|
|
|
20
21
|
if (sourceText === undefined)
|
|
21
22
|
continue;
|
|
22
23
|
const cachedTree = ctx.treeCache?.get(parsed.filePath);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
let tree;
|
|
25
|
+
if (cachedTree !== undefined) {
|
|
26
|
+
tree = cachedTree;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
try {
|
|
30
|
+
tree = parseSourceSafe(parser, sourceText, undefined, {
|
|
31
|
+
bufferSize: getTreeSitterBufferSize(sourceText),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
if (err instanceof ParseTimeoutError) {
|
|
36
|
+
logger.warn({ file: parsed.filePath }, 'rust range-binding: parse timed out, skipping file');
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
27
42
|
for (const fn of tree.rootNode.descendantsOfType('function_item')) {
|
|
28
43
|
const nameNode = fn.childForFieldName('name');
|
|
29
44
|
const retType = fn.childForFieldName('return_type');
|
|
@@ -66,10 +81,24 @@ export function populateRustRangeBindings(parsedFiles, _indexes, ctx) {
|
|
|
66
81
|
if (sourceText === undefined)
|
|
67
82
|
continue;
|
|
68
83
|
const cachedTree = ctx.treeCache?.get(parsed.filePath);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
84
|
+
let tree;
|
|
85
|
+
if (cachedTree !== undefined) {
|
|
86
|
+
tree = cachedTree;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
try {
|
|
90
|
+
tree = parseSourceSafe(parser, sourceText, undefined, {
|
|
91
|
+
bufferSize: getTreeSitterBufferSize(sourceText),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
if (err instanceof ParseTimeoutError) {
|
|
96
|
+
logger.warn({ file: parsed.filePath }, 'rust range-binding: parse timed out, skipping file');
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
73
102
|
const scopeMap = new Map(parsed.scopes.map((s) => [s.id, s]));
|
|
74
103
|
const moduleScope = parsed.scopes.find((s) => s.kind === 'Module');
|
|
75
104
|
if (moduleScope === undefined)
|
|
@@ -233,11 +262,10 @@ function processStructDestructuring(root, parsed, scopeMap, moduleScope, allFiel
|
|
|
233
262
|
for (const fieldNode of patternNode.namedChildren) {
|
|
234
263
|
let fieldName;
|
|
235
264
|
if (fieldNode.type === 'field_pattern') {
|
|
265
|
+
// shorthand `{ a }` and full `{ b: c }` are both field_pattern; the
|
|
266
|
+
// `name` field is shorthand_field_identifier or field_identifier.
|
|
236
267
|
fieldName = fieldNode.childForFieldName('name')?.text;
|
|
237
268
|
}
|
|
238
|
-
else if (fieldNode.type === 'shorthand_field_pattern') {
|
|
239
|
-
fieldName = fieldNode.firstNamedChild?.text;
|
|
240
|
-
}
|
|
241
269
|
if (fieldName === undefined)
|
|
242
270
|
continue;
|
|
243
271
|
let fieldType = lookupFieldType(typeName, fieldName, parsed, scopeMap, moduleScope);
|
|
@@ -121,6 +121,15 @@ export function getImplTraitName(implNode) {
|
|
|
121
121
|
}
|
|
122
122
|
return null;
|
|
123
123
|
}
|
|
124
|
+
// NOTE: this strips reference/pointer sigils and generic arguments but NOT a
|
|
125
|
+
// path qualifier, so `crate::traits::Drawable` stays qualified here — whereas
|
|
126
|
+
// the inheritance synth (rust/captures.ts `bareTypeIdentifier`) resolves scoped
|
|
127
|
+
// bases by their trailing simple name (`Drawable`). The two intentionally
|
|
128
|
+
// diverge for scoped paths. This is inert today (`getImplTraitName` has no
|
|
129
|
+
// ingestion consumer and Rust's `isSuperReceiver` is false, so nothing keys an
|
|
130
|
+
// edge on this name); the synth is the single source of truth for the
|
|
131
|
+
// inheritance edge. A future change that wires `getImplTraitName` into
|
|
132
|
+
// resolution must reconcile this with the synth's tail-only normalization.
|
|
124
133
|
function normalizeRustTypeName(text) {
|
|
125
134
|
let t = text.trim();
|
|
126
135
|
while (t.startsWith('&'))
|
|
@@ -4,8 +4,81 @@ import { rustProvider } from '../rust.js';
|
|
|
4
4
|
import { rustArityCompatibility, rustMergeBindings, resolveRustImportTarget } from './index.js';
|
|
5
5
|
import { populateRustOwners } from './method-owners.js';
|
|
6
6
|
import { populateRustRangeBindings } from './range-binding.js';
|
|
7
|
-
import { isClassLike } from '../../scope-resolution/scope/walkers.js';
|
|
7
|
+
import { isClassLike, findClassBindingInScope, resolveAmbiguousInheritanceBaseViaImports, } from '../../scope-resolution/scope/walkers.js';
|
|
8
8
|
import { resolveDefGraphId } from '../../scope-resolution/graph-bridge/ids.js';
|
|
9
|
+
import { generateId } from '../../../../lib/utils.js';
|
|
10
|
+
/**
|
|
11
|
+
* Emit Rust `S IMPLEMENTS T` edges from `impl T for S` trait implementations.
|
|
12
|
+
*
|
|
13
|
+
* Rust inheritance is not a base list on the type declaration — it lives on
|
|
14
|
+
* `impl_item { trait: T, type: S }`. The shared `preEmitInheritanceEdges` pass
|
|
15
|
+
* derives an `@reference.inherits` site's edge SOURCE from the enclosing class
|
|
16
|
+
* def, but an `impl_item` scope owns no class-like def, so that pass cannot
|
|
17
|
+
* produce these edges (it only marks the sites handled). The `@reference.inherits`
|
|
18
|
+
* sites synthesized in `captures.ts` carry the trait `T` as `site.name` (target)
|
|
19
|
+
* and the struct `S` as `site.explicitReceiver.name` (source); this hook reads
|
|
20
|
+
* them back and emits the IMPLEMENTS edge with source `S`, target `T`, and the
|
|
21
|
+
* legacy `'trait-impl'` reason — matching the legacy heritage DAG (#1951).
|
|
22
|
+
*
|
|
23
|
+
* Resolution is scope-aware and import-aware, mirroring the shared
|
|
24
|
+
* `preEmitInheritanceEdges` pass: both `S` and `T` resolve from the `impl`
|
|
25
|
+
* block's own scope via `findClassBindingInScope` (scope-chain + single-match
|
|
26
|
+
* fallbacks), then `resolveAmbiguousInheritanceBaseViaImports` for a name that
|
|
27
|
+
* several modules declare (disambiguated by the referencing file's `use`
|
|
28
|
+
* imports). A trait `T` is commonly declared in a different file (e.g. the
|
|
29
|
+
* `rust-traits` fixture imports `Drawable`/`Clickable` from a sibling module);
|
|
30
|
+
* the scope chain reaches it through those `use` bindings. When a name does
|
|
31
|
+
* not resolve to exactly one class-like def — unresolved (e.g. a std trait
|
|
32
|
+
* like `Default`) OR ambiguous across modules (two same-named `struct`s /
|
|
33
|
+
* traits) — NO edge is emitted, restoring the legacy file-scoped path's
|
|
34
|
+
* "a wrong edge is worse than no edge" invariant. (The prior global
|
|
35
|
+
* simple-name index used last-write-wins and could source an `impl` edge from
|
|
36
|
+
* the wrong same-named def across modules.) Idempotent: pre-seeds the dedup
|
|
37
|
+
* set from existing IMPLEMENTS edges so a worker-mode legacy emission (or a
|
|
38
|
+
* re-resolution) is not duplicated.
|
|
39
|
+
*/
|
|
40
|
+
function emitRustTraitImplEdges(graph, parsedFiles, nodeLookup, scopes) {
|
|
41
|
+
if (scopes === undefined)
|
|
42
|
+
return;
|
|
43
|
+
const emitted = new Set();
|
|
44
|
+
for (const rel of graph.iterRelationshipsByType('IMPLEMENTS')) {
|
|
45
|
+
emitted.add(`${rel.sourceId}->${rel.targetId}`);
|
|
46
|
+
}
|
|
47
|
+
for (const parsed of parsedFiles) {
|
|
48
|
+
for (const site of parsed.referenceSites) {
|
|
49
|
+
if (site.kind !== 'inherits')
|
|
50
|
+
continue;
|
|
51
|
+
const structName = site.explicitReceiver?.name;
|
|
52
|
+
const traitName = site.name;
|
|
53
|
+
if (structName === undefined || structName === '' || traitName === '')
|
|
54
|
+
continue;
|
|
55
|
+
// Scope-aware (+ import-aware) resolution from the impl block's scope.
|
|
56
|
+
// Refuse when either end is unresolved or ambiguous.
|
|
57
|
+
const structDef = findClassBindingInScope(site.inScope, structName, scopes) ??
|
|
58
|
+
resolveAmbiguousInheritanceBaseViaImports(site.inScope, structName, scopes);
|
|
59
|
+
const traitDef = findClassBindingInScope(site.inScope, traitName, scopes) ??
|
|
60
|
+
resolveAmbiguousInheritanceBaseViaImports(site.inScope, traitName, scopes);
|
|
61
|
+
if (structDef === undefined || traitDef === undefined)
|
|
62
|
+
continue;
|
|
63
|
+
const structGraphId = resolveDefGraphId(structDef.filePath, structDef, nodeLookup);
|
|
64
|
+
const traitGraphId = resolveDefGraphId(traitDef.filePath, traitDef, nodeLookup);
|
|
65
|
+
if (structGraphId === undefined || traitGraphId === undefined)
|
|
66
|
+
continue;
|
|
67
|
+
const edgeKey = `${structGraphId}->${traitGraphId}`;
|
|
68
|
+
if (emitted.has(edgeKey))
|
|
69
|
+
continue;
|
|
70
|
+
emitted.add(edgeKey);
|
|
71
|
+
graph.addRelationship({
|
|
72
|
+
id: generateId('IMPLEMENTS', `${edgeKey}:trait-impl`),
|
|
73
|
+
sourceId: structGraphId,
|
|
74
|
+
targetId: traitGraphId,
|
|
75
|
+
type: 'IMPLEMENTS',
|
|
76
|
+
confidence: 0.85,
|
|
77
|
+
reason: 'trait-impl',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
9
82
|
function buildRustMro(graph, parsedFiles, nodeLookup) {
|
|
10
83
|
const baseMro = buildMro(graph, parsedFiles, nodeLookup, defaultLinearize);
|
|
11
84
|
const defIdByGraphId = new Map();
|
|
@@ -52,6 +125,7 @@ export const rustScopeResolver = {
|
|
|
52
125
|
mergeBindings: (existing, incoming, scopeId) => rustMergeBindings(existing, incoming, scopeId),
|
|
53
126
|
arityCompatibility: (callsite, def) => rustArityCompatibility(def, callsite),
|
|
54
127
|
buildMro: (graph, parsedFiles, nodeLookup) => buildRustMro(graph, parsedFiles, nodeLookup),
|
|
128
|
+
emitHeritageEdges: (graph, parsedFiles, nodeLookup, scopes) => emitRustTraitImplEdges(graph, parsedFiles, nodeLookup, scopes),
|
|
55
129
|
populateOwners: (parsed) => populateRustOwners(parsed),
|
|
56
130
|
isSuperReceiver: () => false,
|
|
57
131
|
populateRangeBindings: populateRustRangeBindings,
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* LanguageProvider, following the Strategy pattern used by the pipeline.
|
|
6
6
|
*
|
|
7
7
|
* Key Rust traits:
|
|
8
|
-
* - importSemantics: 'named' (Rust has use X::{a, b})
|
|
9
8
|
* - mroStrategy: 'qualified-syntax' (Rust uses trait qualification, not MRO)
|
|
10
|
-
* - namedBindingExtractor: present (use X::{a, b} extracts named bindings)
|
|
11
9
|
*/
|
|
12
10
|
export declare const rustProvider: import("../language-provider.js").LanguageProvider;
|
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
* LanguageProvider, following the Strategy pattern used by the pipeline.
|
|
6
6
|
*
|
|
7
7
|
* Key Rust traits:
|
|
8
|
-
* - importSemantics: 'named' (Rust has use X::{a, b})
|
|
9
8
|
* - mroStrategy: 'qualified-syntax' (Rust uses trait qualification, not MRO)
|
|
10
|
-
* - namedBindingExtractor: present (use X::{a, b} extracts named bindings)
|
|
11
9
|
*/
|
|
12
10
|
import { SupportedLanguages } from '../../../_shared/index.js';
|
|
13
11
|
import { createClassExtractor } from '../class-extractors/generic.js';
|
|
@@ -17,7 +15,6 @@ import { typeConfig as rustConfig } from '../type-extractors/rust.js';
|
|
|
17
15
|
import { rustExportChecker } from '../export-detection.js';
|
|
18
16
|
import { createImportResolver } from '../import-resolvers/resolver-factory.js';
|
|
19
17
|
import { rustImportConfig } from '../import-resolvers/configs/rust.js';
|
|
20
|
-
import { extractRustNamedBindings } from '../named-bindings/rust.js';
|
|
21
18
|
import { RUST_QUERIES } from '../tree-sitter-queries.js';
|
|
22
19
|
import { createFieldExtractor } from '../field-extractors/generic.js';
|
|
23
20
|
import { rustConfig as rustFieldConfig } from '../field-extractors/configs/rust.js';
|
|
@@ -27,7 +24,6 @@ import { createVariableExtractor } from '../variable-extractors/generic.js';
|
|
|
27
24
|
import { rustVariableConfig } from '../variable-extractors/configs/rust.js';
|
|
28
25
|
import { createCallExtractor } from '../call-extractors/generic.js';
|
|
29
26
|
import { rustCallConfig } from '../call-extractors/configs/rust.js';
|
|
30
|
-
import { createHeritageExtractor } from '../heritage-extractors/generic.js';
|
|
31
27
|
import { emitRustScopeCaptures, rustArityCompatibility, rustBindingScopeFor, rustImportOwningScope, rustReceiverBinding, interpretRustImport, interpretRustTypeBinding, } from './rust/index.js';
|
|
32
28
|
/** Rust impl_item: find the function_item child and extract its name as a Method. */
|
|
33
29
|
const rustExtractFunctionName = (node) => {
|
|
@@ -153,7 +149,6 @@ export const rustProvider = defineLanguage({
|
|
|
153
149
|
typeConfig: rustConfig,
|
|
154
150
|
exportChecker: rustExportChecker,
|
|
155
151
|
importResolver: createImportResolver(rustImportConfig),
|
|
156
|
-
namedBindingExtractor: extractRustNamedBindings,
|
|
157
152
|
mroStrategy: 'qualified-syntax',
|
|
158
153
|
callExtractor: createCallExtractor(rustCallConfig),
|
|
159
154
|
fieldExtractor: createFieldExtractor(rustFieldConfig),
|
|
@@ -163,7 +158,6 @@ export const rustProvider = defineLanguage({
|
|
|
163
158
|
}),
|
|
164
159
|
variableExtractor: createVariableExtractor(rustVariableConfig),
|
|
165
160
|
classExtractor: createClassExtractor(rustClassConfig),
|
|
166
|
-
heritageExtractor: createHeritageExtractor(SupportedLanguages.Rust),
|
|
167
161
|
builtInNames: BUILT_INS,
|
|
168
162
|
// ── RFC #909 Ring 3: scope-based resolution hooks ──────────
|
|
169
163
|
emitScopeCaptures: emitRustScopeCaptures,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract Swift arity metadata from a function-like tree-sitter node —
|
|
3
|
+
* `function_declaration`, `protocol_function_declaration`, or
|
|
4
|
+
* `init_declaration`.
|
|
5
|
+
*
|
|
6
|
+
* Reuses `swiftMethodConfig.extractParameters` so scope-extracted defs
|
|
7
|
+
* carry the same arity semantics as the legacy parse-worker path:
|
|
8
|
+
* - Variadic params (`xs: Int...`) collapse `parameterCount` to
|
|
9
|
+
* `undefined`, which `swiftArityCompatibility` treats as "max
|
|
10
|
+
* unknown" — the candidate stays eligible at `argCount >= required`.
|
|
11
|
+
* - Defaulted params (`= expr`) contribute to `optionalCount`;
|
|
12
|
+
* `requiredParameterCount = total − optionalCount`.
|
|
13
|
+
* - `parameterTypes` collects declared type names for narrowing; a
|
|
14
|
+
* literal `'variadic'` marker is appended for variadic methods so
|
|
15
|
+
* `swiftArityCompatibility` can detect them without re-reading AST.
|
|
16
|
+
*/
|
|
17
|
+
import type { SyntaxNode } from '../../utils/ast-helpers.js';
|
|
18
|
+
interface SwiftArityMetadata {
|
|
19
|
+
readonly parameterCount: number | undefined;
|
|
20
|
+
readonly requiredParameterCount: number | undefined;
|
|
21
|
+
readonly parameterTypes: readonly string[] | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare function computeSwiftArityMetadata(fnNode: SyntaxNode): SwiftArityMetadata;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract Swift arity metadata from a function-like tree-sitter node —
|
|
3
|
+
* `function_declaration`, `protocol_function_declaration`, or
|
|
4
|
+
* `init_declaration`.
|
|
5
|
+
*
|
|
6
|
+
* Reuses `swiftMethodConfig.extractParameters` so scope-extracted defs
|
|
7
|
+
* carry the same arity semantics as the legacy parse-worker path:
|
|
8
|
+
* - Variadic params (`xs: Int...`) collapse `parameterCount` to
|
|
9
|
+
* `undefined`, which `swiftArityCompatibility` treats as "max
|
|
10
|
+
* unknown" — the candidate stays eligible at `argCount >= required`.
|
|
11
|
+
* - Defaulted params (`= expr`) contribute to `optionalCount`;
|
|
12
|
+
* `requiredParameterCount = total − optionalCount`.
|
|
13
|
+
* - `parameterTypes` collects declared type names for narrowing; a
|
|
14
|
+
* literal `'variadic'` marker is appended for variadic methods so
|
|
15
|
+
* `swiftArityCompatibility` can detect them without re-reading AST.
|
|
16
|
+
*/
|
|
17
|
+
import { swiftMethodConfig } from '../../method-extractors/configs/swift.js';
|
|
18
|
+
export function computeSwiftArityMetadata(fnNode) {
|
|
19
|
+
const params = swiftMethodConfig.extractParameters?.(fnNode) ?? [];
|
|
20
|
+
let hasVariadic = false;
|
|
21
|
+
let optionalCount = 0;
|
|
22
|
+
const types = [];
|
|
23
|
+
for (const p of params) {
|
|
24
|
+
if (p.isVariadic)
|
|
25
|
+
hasVariadic = true;
|
|
26
|
+
else if (p.isOptional)
|
|
27
|
+
optionalCount++;
|
|
28
|
+
if (p.type !== null)
|
|
29
|
+
types.push(p.type);
|
|
30
|
+
}
|
|
31
|
+
if (hasVariadic)
|
|
32
|
+
types.push('variadic');
|
|
33
|
+
const total = params.length;
|
|
34
|
+
const parameterCount = hasVariadic ? undefined : total;
|
|
35
|
+
const requiredParameterCount = hasVariadic ? undefined : total - optionalCount;
|
|
36
|
+
return {
|
|
37
|
+
parameterCount,
|
|
38
|
+
requiredParameterCount,
|
|
39
|
+
parameterTypes: types.length > 0 ? types : undefined,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift arity check, accommodating variadic and default parameters.
|
|
3
|
+
*
|
|
4
|
+
* Per the migration decision (count-primary, labels soft): we narrow on
|
|
5
|
+
* arity only. Swift's argument labels are a soft signal — a label
|
|
6
|
+
* mismatch is NOT treated as incompatible here, mirroring how the other
|
|
7
|
+
* migrated languages narrow and aligning with RFC §4 soft-penalty
|
|
8
|
+
* semantics. Label-precise dispatch is left to the registry's
|
|
9
|
+
* type-binding layer.
|
|
10
|
+
*
|
|
11
|
+
* The `def` metadata we care about (synthesized by `arity-metadata.ts`):
|
|
12
|
+
* - `parameterCount` — total formal parameters; `undefined`
|
|
13
|
+
* when the method has a variadic param.
|
|
14
|
+
* - `requiredParameterCount` — min required (excludes defaulted params
|
|
15
|
+
* and the variadic).
|
|
16
|
+
* - `parameterTypes` — declared type strings; contains the
|
|
17
|
+
* literal `'variadic'` when variadic.
|
|
18
|
+
*
|
|
19
|
+
* Verdicts:
|
|
20
|
+
* - `'compatible'` — `requiredParameterCount <= argCount <= parameterCount`,
|
|
21
|
+
* OR the def is variadic (then any `argCount >= required`).
|
|
22
|
+
* - `'incompatible'` — argCount below required, OR above max with no variadic.
|
|
23
|
+
* - `'unknown'` — metadata absent / incomplete.
|
|
24
|
+
*
|
|
25
|
+
* `'incompatible'` is a soft signal in `Registry.lookup` (penalized but
|
|
26
|
+
* still considered when no compatible candidate exists), per RFC §4.
|
|
27
|
+
*/
|
|
28
|
+
import type { Callsite, SymbolDefinition } from '../../../../_shared/index.js';
|
|
29
|
+
export declare function swiftArityCompatibility(def: SymbolDefinition, callsite: Callsite): 'compatible' | 'unknown' | 'incompatible';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swift arity check, accommodating variadic and default parameters.
|
|
3
|
+
*
|
|
4
|
+
* Per the migration decision (count-primary, labels soft): we narrow on
|
|
5
|
+
* arity only. Swift's argument labels are a soft signal — a label
|
|
6
|
+
* mismatch is NOT treated as incompatible here, mirroring how the other
|
|
7
|
+
* migrated languages narrow and aligning with RFC §4 soft-penalty
|
|
8
|
+
* semantics. Label-precise dispatch is left to the registry's
|
|
9
|
+
* type-binding layer.
|
|
10
|
+
*
|
|
11
|
+
* The `def` metadata we care about (synthesized by `arity-metadata.ts`):
|
|
12
|
+
* - `parameterCount` — total formal parameters; `undefined`
|
|
13
|
+
* when the method has a variadic param.
|
|
14
|
+
* - `requiredParameterCount` — min required (excludes defaulted params
|
|
15
|
+
* and the variadic).
|
|
16
|
+
* - `parameterTypes` — declared type strings; contains the
|
|
17
|
+
* literal `'variadic'` when variadic.
|
|
18
|
+
*
|
|
19
|
+
* Verdicts:
|
|
20
|
+
* - `'compatible'` — `requiredParameterCount <= argCount <= parameterCount`,
|
|
21
|
+
* OR the def is variadic (then any `argCount >= required`).
|
|
22
|
+
* - `'incompatible'` — argCount below required, OR above max with no variadic.
|
|
23
|
+
* - `'unknown'` — metadata absent / incomplete.
|
|
24
|
+
*
|
|
25
|
+
* `'incompatible'` is a soft signal in `Registry.lookup` (penalized but
|
|
26
|
+
* still considered when no compatible candidate exists), per RFC §4.
|
|
27
|
+
*/
|
|
28
|
+
export function swiftArityCompatibility(def, callsite) {
|
|
29
|
+
const max = def.parameterCount;
|
|
30
|
+
const min = def.requiredParameterCount;
|
|
31
|
+
if (max === undefined && min === undefined)
|
|
32
|
+
return 'unknown';
|
|
33
|
+
const argCount = callsite.arity;
|
|
34
|
+
if (!Number.isFinite(argCount) || argCount < 0)
|
|
35
|
+
return 'unknown';
|
|
36
|
+
const hasVarArgs = def.parameterTypes !== undefined && def.parameterTypes.some((t) => t === 'variadic');
|
|
37
|
+
if (min !== undefined && argCount < min)
|
|
38
|
+
return 'incompatible';
|
|
39
|
+
if (max !== undefined && argCount > max && !hasVarArgs)
|
|
40
|
+
return 'incompatible';
|
|
41
|
+
return 'compatible';
|
|
42
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SyntaxNode } from '../../utils/ast-helpers.js';
|
|
2
|
+
/**
|
|
3
|
+
* Trailing simple-name `type_identifier` of a Swift `user_type` base. A
|
|
4
|
+
* qualified `Outer.Inner` parses flat as
|
|
5
|
+
* `(user_type (type_identifier "Outer") (type_identifier "Inner"))`, and the
|
|
6
|
+
* actual base type is the TRAILING segment `Inner` (mirrors Java
|
|
7
|
+
* `scoped_type_identifier` → `lastNamedChild` and TS `nested_type_identifier`
|
|
8
|
+
* → tail). Generic arguments live in a sibling `type_arguments` node — never a
|
|
9
|
+
* `type_identifier` — so they are skipped: `Box<Int>` → `Box`,
|
|
10
|
+
* `Outer.Inner<T>` → `Inner`. Returns null when the `user_type` has no
|
|
11
|
+
* `type_identifier` child.
|
|
12
|
+
*
|
|
13
|
+
* Shared by `swiftBaseTypeIdentifier` (captures.ts — returns the node for an
|
|
14
|
+
* `@reference.inherits` site) and `firstInheritedType` (receiver-binding.ts —
|
|
15
|
+
* reads `.text` for `super` receiver binding). It lives in this leaf module
|
|
16
|
+
* rather than being exported from captures.ts because captures.ts already
|
|
17
|
+
* imports receiver-binding.ts, so a captures.ts export would create a
|
|
18
|
+
* bidirectional import cycle (#1956 tri-review U7).
|
|
19
|
+
*/
|
|
20
|
+
export declare function swiftQualifiedBaseTail(userType: SyntaxNode): SyntaxNode | null;
|