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
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* "resolve member on owner with MRO" pattern. All four are reusable
|
|
20
20
|
* as-is for TypeScript, Java, Kotlin, Ruby, etc.
|
|
21
21
|
*/
|
|
22
|
+
import { normalizeQualifiedName, splitQualifiedName, stripTrailingTypeArguments, } from '../../utils/qualified-name.js';
|
|
22
23
|
const EMPTY_BINDINGS = Object.freeze([]);
|
|
23
24
|
/**
|
|
24
25
|
* Look up binding refs at `scopeId` for `name`, consulting both the
|
|
@@ -45,41 +46,69 @@ export function lookupBindingsAt(scopeId, name, scopes) {
|
|
|
45
46
|
const finalized = scopes.bindings.get(scopeId)?.get(name);
|
|
46
47
|
const augmented = scopes.bindingAugmentations.get(scopeId)?.get(name);
|
|
47
48
|
const workspace = scopes.workspaceFqnBindings?.get(name);
|
|
49
|
+
// Per-namespace channel (#1871 named-namespace generalization). Gated by
|
|
50
|
+
// accessibility: only a *module* scope carries an `accessibleNamespacesByScope`
|
|
51
|
+
// entry, so this collects nothing at child scopes and at module scopes only for
|
|
52
|
+
// the namespaces that file can see. Empty (no entry) for every non-C# bundle,
|
|
53
|
+
// so the behavior of the three pre-existing channels is unchanged.
|
|
54
|
+
const namespaceRefs = collectNamespaceFqnBindings(scopeId, name, scopes);
|
|
48
55
|
const fLen = finalized?.length ?? 0;
|
|
49
56
|
const aLen = augmented?.length ?? 0;
|
|
50
57
|
const wLen = workspace?.length ?? 0;
|
|
51
|
-
|
|
58
|
+
const nLen = namespaceRefs?.length ?? 0;
|
|
59
|
+
if (fLen === 0 && aLen === 0 && wLen === 0 && nLen === 0)
|
|
52
60
|
return EMPTY_BINDINGS;
|
|
53
|
-
if (aLen === 0 && wLen === 0)
|
|
61
|
+
if (aLen === 0 && wLen === 0 && nLen === 0)
|
|
54
62
|
return finalized;
|
|
55
|
-
if (fLen === 0 && wLen === 0)
|
|
63
|
+
if (fLen === 0 && wLen === 0 && nLen === 0)
|
|
56
64
|
return augmented;
|
|
57
|
-
if (fLen === 0 && aLen === 0)
|
|
65
|
+
if (fLen === 0 && aLen === 0 && nLen === 0)
|
|
58
66
|
return workspace;
|
|
67
|
+
if (fLen === 0 && aLen === 0 && wLen === 0)
|
|
68
|
+
return namespaceRefs;
|
|
69
|
+
// Merge in precedence order, deduped by `def.nodeId` so the strongest source
|
|
70
|
+
// wins duplicate metadata. Named-namespace refs come BEFORE the flat global
|
|
71
|
+
// `workspace` channel: pre-#1871 these lived in `bindingAugmentations` (which
|
|
72
|
+
// `lookupBindingsAt` already ranks above `workspaceFqnBindings`), so a name in
|
|
73
|
+
// both an accessible named namespace and the global namespace must still
|
|
74
|
+
// resolve named-first. Order: finalized > augmented > namespace > workspace.
|
|
59
75
|
const seen = new Set();
|
|
60
76
|
const out = [];
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (aLen > 0) {
|
|
68
|
-
for (const r of augmented) {
|
|
77
|
+
for (const src of [finalized, augmented, namespaceRefs, workspace]) {
|
|
78
|
+
if (src === undefined)
|
|
79
|
+
continue;
|
|
80
|
+
for (const r of src) {
|
|
69
81
|
if (seen.has(r.def.nodeId))
|
|
70
82
|
continue;
|
|
71
83
|
seen.add(r.def.nodeId);
|
|
72
84
|
out.push(r);
|
|
73
85
|
}
|
|
74
86
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Collect `BindingRef`s for `name` from the per-namespace channel
|
|
91
|
+
* (`namespaceFqnBindings`) across every namespace accessible from `scopeId`.
|
|
92
|
+
* Accessibility comes from `accessibleNamespacesByScope`, which is keyed by
|
|
93
|
+
* *module* scope id — so this returns `undefined` at non-module scopes and at
|
|
94
|
+
* every scope in a bundle that didn't populate the channel (all non-C# today).
|
|
95
|
+
* Language-neutral: keyed only by namespace strings and the index.
|
|
96
|
+
*/
|
|
97
|
+
function collectNamespaceFqnBindings(scopeId, name, scopes) {
|
|
98
|
+
const namespaces = scopes.accessibleNamespacesByScope?.get(scopeId);
|
|
99
|
+
if (namespaces === undefined || namespaces.length === 0)
|
|
100
|
+
return undefined;
|
|
101
|
+
let collected;
|
|
102
|
+
for (const ns of namespaces) {
|
|
103
|
+
const bucket = scopes.namespaceFqnBindings?.get(ns)?.get(name);
|
|
104
|
+
if (bucket !== undefined && bucket.length > 0) {
|
|
105
|
+
if (collected === undefined)
|
|
106
|
+
collected = [];
|
|
107
|
+
for (const r of bucket)
|
|
108
|
+
collected.push(r);
|
|
80
109
|
}
|
|
81
110
|
}
|
|
82
|
-
return
|
|
111
|
+
return collected;
|
|
83
112
|
}
|
|
84
113
|
const EMPTY_NAMES = Object.freeze([]);
|
|
85
114
|
/**
|
|
@@ -142,6 +171,7 @@ export function isClassLike(t) {
|
|
|
142
171
|
export function findReceiverTypeBinding(startScope, receiverName, scopes) {
|
|
143
172
|
let currentId = startScope;
|
|
144
173
|
const visited = new Set();
|
|
174
|
+
let moduleScopeId = null;
|
|
145
175
|
while (currentId !== null) {
|
|
146
176
|
if (visited.has(currentId))
|
|
147
177
|
return undefined;
|
|
@@ -152,10 +182,65 @@ export function findReceiverTypeBinding(startScope, receiverName, scopes) {
|
|
|
152
182
|
const typeRef = scope.typeBindings.get(receiverName);
|
|
153
183
|
if (typeRef !== undefined)
|
|
154
184
|
return typeRef;
|
|
185
|
+
if (scope.kind === 'Module')
|
|
186
|
+
moduleScopeId = currentId;
|
|
155
187
|
currentId = scope.parent;
|
|
156
188
|
}
|
|
189
|
+
// Fallback 1 — named namespaces accessible from this file (own + `using`d),
|
|
190
|
+
// gated by `accessibleNamespacesByScope`. Consulted BEFORE the global channel
|
|
191
|
+
// so a more-specific named binding wins, matching the pre-#1871 order where
|
|
192
|
+
// these lived in the file's own `Scope.typeBindings` (the chain, above the
|
|
193
|
+
// global fallback). Shared-channel routing avoids the O(files × names) blow-up.
|
|
194
|
+
const named = namespaceTypeBindingFor(moduleScopeId, receiverName, scopes);
|
|
195
|
+
if (named !== undefined)
|
|
196
|
+
return named;
|
|
197
|
+
// Fallback 2 — global/default namespace: C# global types are visible from
|
|
198
|
+
// every file (see `workspaceTypeBindings` doc), so this flat channel is the
|
|
199
|
+
// final, unconditional fallback (#1871).
|
|
200
|
+
return scopes.workspaceTypeBindings?.get(receiverName);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Resolve a typeBinding for `name` from the per-namespace channel
|
|
204
|
+
* (`namespaceTypeBindings`) across the namespaces accessible from `moduleScopeId`.
|
|
205
|
+
* First accessible-namespace hit wins. Returns `undefined` when the module has no
|
|
206
|
+
* accessibility entry (non-module scope id, or a bundle that didn't populate the
|
|
207
|
+
* channel — all non-C# today). Shared by the two typeBindings chain-walkers so
|
|
208
|
+
* the named-namespace fallback stays identical between them.
|
|
209
|
+
*/
|
|
210
|
+
export function namespaceTypeBindingFor(moduleScopeId, name, scopes) {
|
|
211
|
+
if (moduleScopeId === null)
|
|
212
|
+
return undefined;
|
|
213
|
+
const namespaces = scopes.accessibleNamespacesByScope?.get(moduleScopeId);
|
|
214
|
+
if (namespaces === undefined)
|
|
215
|
+
return undefined;
|
|
216
|
+
for (const ns of namespaces) {
|
|
217
|
+
const hit = scopes.namespaceTypeBindings?.get(ns)?.get(name);
|
|
218
|
+
if (hit !== undefined)
|
|
219
|
+
return hit;
|
|
220
|
+
}
|
|
157
221
|
return undefined;
|
|
158
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Walk the scope chain from `startScope` to its enclosing Module scope id, or
|
|
225
|
+
* `null` if none is found. Used by chain-followers that need the module scope to
|
|
226
|
+
* consult the accessibility-gated per-namespace channels.
|
|
227
|
+
*/
|
|
228
|
+
export function moduleScopeIdOf(startScope, scopes) {
|
|
229
|
+
let currentId = startScope;
|
|
230
|
+
const visited = new Set();
|
|
231
|
+
while (currentId !== null) {
|
|
232
|
+
if (visited.has(currentId))
|
|
233
|
+
return null;
|
|
234
|
+
visited.add(currentId);
|
|
235
|
+
const scope = scopes.scopeTree.getScope(currentId);
|
|
236
|
+
if (scope === undefined)
|
|
237
|
+
return null;
|
|
238
|
+
if (scope.kind === 'Module')
|
|
239
|
+
return currentId;
|
|
240
|
+
currentId = scope.parent;
|
|
241
|
+
}
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
159
244
|
/**
|
|
160
245
|
* Look up a class-like binding by name in the given scope's chain.
|
|
161
246
|
*
|
|
@@ -202,6 +287,242 @@ export function findClassBindingInScope(startScope, receiverName, scopes) {
|
|
|
202
287
|
}
|
|
203
288
|
return undefined;
|
|
204
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Resolve a class-like inheritance target using the shared inheritance
|
|
292
|
+
* resolution chain. Keeps pre-emitted heritage edges and language-specific
|
|
293
|
+
* consumers of `inherits` sites aligned.
|
|
294
|
+
*/
|
|
295
|
+
export function resolveInheritanceBaseInScope(startScope, baseName, scopes, rawQualifiedName, enclosingClassDef) {
|
|
296
|
+
// #1982: when the source wrote a qualified base (`Other::Inner`), resolve it
|
|
297
|
+
// against the full-path QualifiedNameIndex FIRST, so a same-tail nested base
|
|
298
|
+
// binds to the matching sibling instead of the first-inserted one that the
|
|
299
|
+
// simple-tail scope walk picks. Falls through to the existing walk when the
|
|
300
|
+
// base is unqualified, unknown, or the qualified lookup can't pick a unique
|
|
301
|
+
// winner — so unqualified bases and the cross-file single-candidate case are
|
|
302
|
+
// unchanged. `enclosingClassDef` (the deriving class) is threaded from the
|
|
303
|
+
// caller to skip a redundant enclosing-class walk (#1982 perf).
|
|
304
|
+
if (rawQualifiedName !== undefined) {
|
|
305
|
+
const qualified = resolveQualifiedInheritanceBase(startScope, rawQualifiedName, scopes, enclosingClassDef);
|
|
306
|
+
if (qualified !== undefined)
|
|
307
|
+
return qualified;
|
|
308
|
+
}
|
|
309
|
+
return (findClassBindingInScope(startScope, baseName, scopes) ??
|
|
310
|
+
resolveAmbiguousInheritanceBaseViaImports(startScope, baseName, scopes));
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Resolve a qualified inheritance base (`Other::Inner`, `ns::Base`) against the
|
|
314
|
+
* full-path `QualifiedNameIndex` (keyed by `def.qualifiedName`, which carries
|
|
315
|
+
* the promoted dotted path post-`populateOwners`). Tries the referencing site's
|
|
316
|
+
* enclosing-scope segments as progressive prefixes (longest first) before the
|
|
317
|
+
* root-anchored qualifier, so a *relative* base like `Outer::Inner` written
|
|
318
|
+
* inside `namespace NS` resolves to the root-anchored key `NS.Outer.Inner`.
|
|
319
|
+
* Returns a unique class-like def, or `undefined` when the base is unqualified,
|
|
320
|
+
* unknown, or genuinely ambiguous at a key (refuse-on-tie — never guess; a
|
|
321
|
+
* wrong EXTENDS edge silently corrupts impact analysis).
|
|
322
|
+
*/
|
|
323
|
+
function resolveQualifiedInheritanceBase(startScope, rawQualifiedName, scopes, enclosingClassDef) {
|
|
324
|
+
const normalized = stripTrailingTypeArguments(normalizeQualifiedName(rawQualifiedName));
|
|
325
|
+
// No qualifier after normalization → nothing the simple-tail walk doesn't do.
|
|
326
|
+
if (normalized.length === 0 || !normalized.includes('.'))
|
|
327
|
+
return undefined;
|
|
328
|
+
// #1982: a root-anchored base (`::Net::X`) names the GLOBAL scope, so it must
|
|
329
|
+
// NOT be prefixed with the referencing site's enclosing segments — try only
|
|
330
|
+
// the root-anchored key. normalizeQualifiedName strips the leading `::`, so
|
|
331
|
+
// detect the anchor on the raw text (after leading whitespace).
|
|
332
|
+
const isRootAnchored = /^\s*::/.test(rawQualifiedName);
|
|
333
|
+
const enclosing = isRootAnchored
|
|
334
|
+
? []
|
|
335
|
+
: enclosingScopeSegments(startScope, scopes, enclosingClassDef);
|
|
336
|
+
// Candidate keys: longest enclosing prefix first for *relative* qualified
|
|
337
|
+
// bases (`Outer.Inner` inside `NS.Outer.Derived` → `NS.Outer.Inner`). When the
|
|
338
|
+
// qualifier names a *different* namespace than the enclosing scope (`new B.Foo()`
|
|
339
|
+
// inside `namespace A` → `B.Foo`, not `A.Foo`), try the raw normalized key
|
|
340
|
+
// FIRST so same-tail local bindings don't win (#2046 / #1991).
|
|
341
|
+
const normParts = splitQualifiedName(normalized);
|
|
342
|
+
const isRelativeToEnclosing = enclosing.length > 0 &&
|
|
343
|
+
normParts.length > 0 &&
|
|
344
|
+
normParts[0] === enclosing[enclosing.length - 1];
|
|
345
|
+
const keys = [];
|
|
346
|
+
if (!isRelativeToEnclosing) {
|
|
347
|
+
keys.push(normalized);
|
|
348
|
+
}
|
|
349
|
+
for (let i = enclosing.length; i >= 1; i--) {
|
|
350
|
+
keys.push([...enclosing.slice(0, i), normalized].join('.'));
|
|
351
|
+
}
|
|
352
|
+
if (!keys.includes(normalized)) {
|
|
353
|
+
keys.push(normalized);
|
|
354
|
+
}
|
|
355
|
+
for (const key of keys) {
|
|
356
|
+
const ids = scopes.qualifiedNames.get(key);
|
|
357
|
+
if (ids.length === 0)
|
|
358
|
+
continue;
|
|
359
|
+
let unique;
|
|
360
|
+
let count = 0;
|
|
361
|
+
for (const id of ids) {
|
|
362
|
+
const def = scopes.defs.get(id);
|
|
363
|
+
if (def !== undefined && isClassLike(def.type)) {
|
|
364
|
+
unique = def;
|
|
365
|
+
count++;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (count === 1)
|
|
369
|
+
return unique;
|
|
370
|
+
if (count > 1) {
|
|
371
|
+
// #1993: same-tail bases collide at this namespace-omitted key (`NS1::A::Inner`
|
|
372
|
+
// and `NS2::A::Inner` both key `A.Inner`). Break the tie with the bridge's
|
|
373
|
+
// `namespacePrefix` sidecar — prefer the candidate in the SAME enclosing
|
|
374
|
+
// namespace as the deriving class. Bridge-held: `def.qualifiedName` and the
|
|
375
|
+
// index keys are untouched; still refuse when the sidecar can't pick a unique.
|
|
376
|
+
const childPrefix = enclosingClassDef?.namespacePrefix;
|
|
377
|
+
if (childPrefix !== undefined && childPrefix.length > 0) {
|
|
378
|
+
let nsUnique;
|
|
379
|
+
let nsCount = 0;
|
|
380
|
+
for (const id of ids) {
|
|
381
|
+
const def = scopes.defs.get(id);
|
|
382
|
+
if (def !== undefined && isClassLike(def.type) && def.namespacePrefix === childPrefix) {
|
|
383
|
+
nsUnique = def;
|
|
384
|
+
nsCount++;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (nsCount === 1)
|
|
388
|
+
return nsUnique;
|
|
389
|
+
}
|
|
390
|
+
return undefined; // genuine tie → refuse, don't guess
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
// Qualifier-vs-sidecar fallback (#2046). Languages whose class `qualifiedName`
|
|
394
|
+
// is the SIMPLE name (C#) never populate a qualified key in the index, so the
|
|
395
|
+
// keyed loop above can't see `B.Foo`. Resolve the simple TAIL and break the
|
|
396
|
+
// same-tail collision by matching the explicit qualifier (`B`) against each
|
|
397
|
+
// candidate's `namespacePrefix` sidecar. Commit only on a unique match — a
|
|
398
|
+
// still-ambiguous qualifier refuses (never guesses a wrong EXTENDS/CALLS edge).
|
|
399
|
+
const tail = normParts[normParts.length - 1];
|
|
400
|
+
const qualifier = normParts.slice(0, -1).join('.');
|
|
401
|
+
if (tail !== undefined && qualifier.length > 0) {
|
|
402
|
+
const tailIds = scopes.qualifiedNames.get(tail);
|
|
403
|
+
let qUnique;
|
|
404
|
+
let qCount = 0;
|
|
405
|
+
for (const id of tailIds) {
|
|
406
|
+
const def = scopes.defs.get(id);
|
|
407
|
+
if (def === undefined || !isClassLike(def.type))
|
|
408
|
+
continue;
|
|
409
|
+
const np = def.namespacePrefix;
|
|
410
|
+
if (np === undefined || np.length === 0)
|
|
411
|
+
continue;
|
|
412
|
+
if (np === qualifier || np.endsWith(`.${qualifier}`)) {
|
|
413
|
+
qUnique = def;
|
|
414
|
+
qCount++;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (qCount === 1)
|
|
418
|
+
return qUnique;
|
|
419
|
+
}
|
|
420
|
+
return undefined;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Enclosing scope segments of an inheritance site, derived from the deriving
|
|
424
|
+
* (child) class def's `qualifiedName` minus its own tail. For child
|
|
425
|
+
* `NS.Other.Derived` this is `['NS', 'Other']`; empty for a file-scope child.
|
|
426
|
+
* Used to build progressive-prefix lookup keys for relative qualified bases.
|
|
427
|
+
*/
|
|
428
|
+
function enclosingScopeSegments(startScope, scopes, enclosingClassDef) {
|
|
429
|
+
// Reuse the caller-provided deriving class when available (#1982 perf); only
|
|
430
|
+
// walk the scope chain when it wasn't threaded in.
|
|
431
|
+
const child = enclosingClassDef ?? findEnclosingClassDef(startScope, scopes);
|
|
432
|
+
const q = child?.qualifiedName;
|
|
433
|
+
if (q === undefined || q.length === 0)
|
|
434
|
+
return [];
|
|
435
|
+
const segs = q.split('.').filter(Boolean);
|
|
436
|
+
return segs.slice(0, -1);
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Import/include-aware disambiguation for an *ambiguous* class-like base
|
|
440
|
+
* name. Engages ONLY as a fallback after `findClassBindingInScope` has
|
|
441
|
+
* already returned `undefined` — i.e. the scope-chain walk and the
|
|
442
|
+
* single-match `qualifiedNames` fast paths could not pick a winner because
|
|
443
|
+
* several same-named class-like defs exist (e.g. two `class Handler`s in
|
|
444
|
+
* different headers/namespaces).
|
|
445
|
+
*
|
|
446
|
+
* Disambiguates by the referencing file's import graph: the enclosing
|
|
447
|
+
* module scope's finalized `ImportEdge[]` (C++ `#include`, C# `using`, etc.)
|
|
448
|
+
* each carry the exporting file in `targetFile`. A candidate whose defining
|
|
449
|
+
* file is brought in by one of those edges is preferred. Resolution is
|
|
450
|
+
* tiered, strictest first, and only commits when EXACTLY ONE candidate
|
|
451
|
+
* survives a tier — so a still-ambiguous name keeps the historical
|
|
452
|
+
* "return undefined" refusal:
|
|
453
|
+
*
|
|
454
|
+
* 1. Exact file match — candidate.filePath === an import's `targetFile`
|
|
455
|
+
* (covers C++ `#include "handler_a.h"` → that header's class).
|
|
456
|
+
* 2. Same-directory match — candidate.filePath sits in the same directory
|
|
457
|
+
* as some import target file (covers C# `using MyApp.Models;`, where the
|
|
458
|
+
* namespace import resolves to ONE representative file in the namespace's
|
|
459
|
+
* directory, not necessarily the file declaring the referenced type).
|
|
460
|
+
*
|
|
461
|
+
* Language-neutral: keyed only on the finalized import edges and the
|
|
462
|
+
* candidate defs' `filePath`. Returns `undefined` (preserving refusal) when
|
|
463
|
+
* the name is single-match-resolvable already (never reached — caller gates
|
|
464
|
+
* on `findClassBindingInScope` miss), when no import disambiguates, or when
|
|
465
|
+
* a tier leaves more than one survivor.
|
|
466
|
+
*/
|
|
467
|
+
export function resolveAmbiguousInheritanceBaseViaImports(startScope, baseName, scopes) {
|
|
468
|
+
// Gather the class-like candidates that share this simple name. Defs are
|
|
469
|
+
// indexed by their `qualifiedName` in `qualifiedNames`; for languages whose
|
|
470
|
+
// class qualifiedName IS the simple name (C++, C#, etc.) this is the full
|
|
471
|
+
// candidate set. A single candidate is not "ambiguous" — leave it to the
|
|
472
|
+
// existing single-match fast path (this fallback shouldn't have been called).
|
|
473
|
+
const candidateIds = scopes.qualifiedNames.get(baseName);
|
|
474
|
+
if (candidateIds.length < 2)
|
|
475
|
+
return undefined;
|
|
476
|
+
const candidates = [];
|
|
477
|
+
for (const id of candidateIds) {
|
|
478
|
+
const def = scopes.defs.get(id);
|
|
479
|
+
if (def !== undefined && isClassLike(def.type))
|
|
480
|
+
candidates.push(def);
|
|
481
|
+
}
|
|
482
|
+
if (candidates.length < 2)
|
|
483
|
+
return undefined;
|
|
484
|
+
// Collect the exporting files imported by the referencing file's enclosing
|
|
485
|
+
// module scope (the chain may carry function-local imports too, but the
|
|
486
|
+
// module scope is where `#include` / `using` land).
|
|
487
|
+
const moduleScopeId = moduleScopeIdOf(startScope, scopes);
|
|
488
|
+
if (moduleScopeId === null)
|
|
489
|
+
return undefined;
|
|
490
|
+
const importEdges = scopes.imports.get(moduleScopeId);
|
|
491
|
+
if (importEdges === undefined || importEdges.length === 0)
|
|
492
|
+
return undefined;
|
|
493
|
+
const importedFiles = new Set();
|
|
494
|
+
const importedDirs = new Set();
|
|
495
|
+
for (const edge of importEdges) {
|
|
496
|
+
if (edge.targetFile === null)
|
|
497
|
+
continue;
|
|
498
|
+
importedFiles.add(edge.targetFile);
|
|
499
|
+
importedDirs.add(dirnameOf(edge.targetFile));
|
|
500
|
+
}
|
|
501
|
+
if (importedFiles.size === 0)
|
|
502
|
+
return undefined;
|
|
503
|
+
// Tier 1 — exact file match (C++ `#include "handler_a.h"`).
|
|
504
|
+
const exact = candidates.filter((c) => importedFiles.has(c.filePath));
|
|
505
|
+
if (exact.length === 1)
|
|
506
|
+
return exact[0];
|
|
507
|
+
if (exact.length > 1)
|
|
508
|
+
return undefined; // still ambiguous → refuse
|
|
509
|
+
// Tier 2 — same-directory match (C# namespace `using`, where the namespace
|
|
510
|
+
// import resolves to one representative file in the namespace's directory).
|
|
511
|
+
const sameDir = candidates.filter((c) => importedDirs.has(dirnameOf(c.filePath)));
|
|
512
|
+
if (sameDir.length === 1)
|
|
513
|
+
return sameDir[0];
|
|
514
|
+
return undefined;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Directory portion of a forward-slash workspace-relative path. Returns `''`
|
|
518
|
+
* for a bare filename (no directory). Workspace paths are always normalized to
|
|
519
|
+
* `/` separators upstream, so a simple `lastIndexOf('/')` is sufficient and
|
|
520
|
+
* keeps this dependency-free.
|
|
521
|
+
*/
|
|
522
|
+
function dirnameOf(filePath) {
|
|
523
|
+
const idx = filePath.lastIndexOf('/');
|
|
524
|
+
return idx === -1 ? '' : filePath.slice(0, idx);
|
|
525
|
+
}
|
|
205
526
|
/**
|
|
206
527
|
* Predicate for value-receiver bridge: the labels for which
|
|
207
528
|
* `reconcileOwnership` registers methods/fields under the def's
|
|
@@ -472,6 +793,97 @@ export function populateClassOwnedMembers(parsed) {
|
|
|
472
793
|
}
|
|
473
794
|
}
|
|
474
795
|
}
|
|
796
|
+
/**
|
|
797
|
+
* Tag every def declared inside one or more `Namespace` scopes with its
|
|
798
|
+
* enclosing-namespace path (`NS`, `Outer.Inner`) on a sidecar `namespacePrefix`
|
|
799
|
+
* field — WITHOUT touching `qualifiedName`.
|
|
800
|
+
*
|
|
801
|
+
* Some scope-extractors qualify a nested type by its enclosing CLASS chain
|
|
802
|
+
* (`A.Inner`) but drop the enclosing NAMESPACE, while the structure phase keys
|
|
803
|
+
* the graph node by the full path (`NS.A.Inner`). `resolveDefGraphId` reads this
|
|
804
|
+
* tag to retry the node lookup with the namespace-prefixed key before the
|
|
805
|
+
* simple-name fallback, so same-tail nested bases don't collapse across sibling
|
|
806
|
+
* namespace members (#1982). `qualifiedName` is deliberately left unchanged, so
|
|
807
|
+
* the `qualifiedName`-keyed resolution index and existing namespace resolution
|
|
808
|
+
* (brace-init, UDC ranking, two-phase lookup) are untouched.
|
|
809
|
+
*
|
|
810
|
+
* Language-agnostic: it acts only on `Namespace`-kind scopes (a namespace-free
|
|
811
|
+
* language is a no-op) and is opt-in per provider (call after `populateOwners`).
|
|
812
|
+
* Namespace segments are taken as each namespace def's own tail, so it composes
|
|
813
|
+
* for nested namespaces regardless of whether the inner namespace's name is
|
|
814
|
+
* stored simple or already dotted. Skips defs already carrying the prefix.
|
|
815
|
+
*/
|
|
816
|
+
export function tagNamespacePrefixes(parsed) {
|
|
817
|
+
const scopesById = new Map();
|
|
818
|
+
for (const scope of parsed.scopes)
|
|
819
|
+
scopesById.set(scope.id, scope);
|
|
820
|
+
// Enclosing-namespace prefix for a scope: the dotted path of each ancestor
|
|
821
|
+
// Namespace scope's name, outermost-first (`['Outer','Inner'] → 'Outer.Inner'`).
|
|
822
|
+
const namespacePrefixOf = (scope) => {
|
|
823
|
+
const segments = [];
|
|
824
|
+
let parentId = scope.parent;
|
|
825
|
+
while (parentId !== null) {
|
|
826
|
+
const parent = scopesById.get(parentId);
|
|
827
|
+
if (parent === undefined)
|
|
828
|
+
break;
|
|
829
|
+
if (parent.kind === 'Namespace') {
|
|
830
|
+
const nsDef = parent.ownedDefs.find((d) => d.type === 'Namespace');
|
|
831
|
+
const nsQ = nsDef?.qualifiedName;
|
|
832
|
+
if (nsQ !== undefined && nsQ.length > 0) {
|
|
833
|
+
const dot = nsQ.lastIndexOf('.');
|
|
834
|
+
segments.unshift(dot === -1 ? nsQ : nsQ.slice(dot + 1));
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
parentId = parent.parent;
|
|
838
|
+
}
|
|
839
|
+
return segments.join('.');
|
|
840
|
+
};
|
|
841
|
+
for (const scope of parsed.scopes) {
|
|
842
|
+
if (scope.kind === 'Namespace')
|
|
843
|
+
continue;
|
|
844
|
+
const prefix = namespacePrefixOf(scope);
|
|
845
|
+
if (prefix.length === 0)
|
|
846
|
+
continue;
|
|
847
|
+
for (const def of scope.ownedDefs) {
|
|
848
|
+
const q = def.qualifiedName;
|
|
849
|
+
if (q === undefined || q.length === 0)
|
|
850
|
+
continue;
|
|
851
|
+
if (q === prefix || q.startsWith(`${prefix}.`))
|
|
852
|
+
continue; // already namespaced
|
|
853
|
+
def.namespacePrefix = prefix;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
// #1993: also tag defs declared DIRECTLY in a Namespace scope with that
|
|
857
|
+
// namespace's OWN full path. The loop above only reaches class-nested defs
|
|
858
|
+
// (`A::Inner`); a deriving class like `NS1::DA` lives in the namespace scope and
|
|
859
|
+
// is skipped, so it would carry no prefix and a same-tail cross-namespace base
|
|
860
|
+
// tie (`NS1::A::Inner` vs `NS2::A::Inner`) could not be broken by the deriving
|
|
861
|
+
// side. Composed identically to the class-nested path (enclosing tails + own
|
|
862
|
+
// tail) so the two agree; still sidecar-only (`qualifiedName` untouched).
|
|
863
|
+
for (const scope of parsed.scopes) {
|
|
864
|
+
if (scope.kind !== 'Namespace')
|
|
865
|
+
continue;
|
|
866
|
+
const ownNsDef = scope.ownedDefs.find((d) => d.type === 'Namespace');
|
|
867
|
+
const ownQ = ownNsDef?.qualifiedName;
|
|
868
|
+
if (ownQ === undefined || ownQ.length === 0)
|
|
869
|
+
continue;
|
|
870
|
+
const ownTail = ownQ.slice(ownQ.lastIndexOf('.') + 1);
|
|
871
|
+
const parentPrefix = namespacePrefixOf(scope);
|
|
872
|
+
const fullPrefix = parentPrefix.length > 0 ? `${parentPrefix}.${ownTail}` : ownTail;
|
|
873
|
+
for (const def of scope.ownedDefs) {
|
|
874
|
+
if (def.type === 'Namespace')
|
|
875
|
+
continue;
|
|
876
|
+
const q = def.qualifiedName;
|
|
877
|
+
if (q === undefined || q.length === 0)
|
|
878
|
+
continue;
|
|
879
|
+
if (q === fullPrefix || q.startsWith(`${fullPrefix}.`))
|
|
880
|
+
continue; // already namespaced
|
|
881
|
+
if (def.namespacePrefix !== undefined)
|
|
882
|
+
continue;
|
|
883
|
+
def.namespacePrefix = fullPrefix;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
475
887
|
/**
|
|
476
888
|
* Walk a scope chain upward looking for the innermost enclosing
|
|
477
889
|
* Class scope and return that class's def. Used by per-language
|
|
@@ -532,27 +944,16 @@ export function findExportedDefByName(name, inScope, scopes, index) {
|
|
|
532
944
|
}
|
|
533
945
|
currentId = scope.parent;
|
|
534
946
|
}
|
|
535
|
-
// Workspace-wide fallback:
|
|
536
|
-
//
|
|
537
|
-
//
|
|
538
|
-
//
|
|
539
|
-
//
|
|
540
|
-
//
|
|
541
|
-
//
|
|
542
|
-
//
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
if (refs === undefined)
|
|
546
|
-
continue;
|
|
547
|
-
for (const ref of refs) {
|
|
548
|
-
if (ref.origin !== 'local')
|
|
549
|
-
continue;
|
|
550
|
-
const t = ref.def.type;
|
|
551
|
-
if (t === 'Function' || t === 'Method' || t === 'Constructor')
|
|
552
|
-
return ref.def;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
return undefined;
|
|
947
|
+
// Workspace-wide fallback: the first locally-declared callable binding
|
|
948
|
+
// matching `name` across every file's Module scope (first-seen-by-file wins;
|
|
949
|
+
// `origin === 'local'`, callable types Function/Method/Constructor). This is
|
|
950
|
+
// precomputed ONCE into `index.exportedCallableByName` — byte-identical to the
|
|
951
|
+
// old per-call scan over `moduleScopeByFile`, but O(1) and disk-read-free
|
|
952
|
+
// (the old scan faulted every module scope in from disk under the out-of-core scope index). We use
|
|
953
|
+
// this scope-derived index rather than `SemanticModel.symbols.lookupCallableByName`
|
|
954
|
+
// because the `origin === 'local'` module-export-visibility filter is a scope
|
|
955
|
+
// concept the raw symbol index doesn't express.
|
|
956
|
+
return index.exportedCallableByName.get(name);
|
|
556
957
|
}
|
|
557
958
|
/**
|
|
558
959
|
* Find a member of a class by simple name — delegates to
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
*
|
|
39
39
|
* Build cost is O(totalScopes). Read-only after construction.
|
|
40
40
|
*/
|
|
41
|
-
import type { ParsedFile, Scope, ScopeId } from '../../../_shared/index.js';
|
|
41
|
+
import type { ParsedFile, Scope, ScopeId, ScopeTree, SymbolDefinition } from '../../../_shared/index.js';
|
|
42
42
|
export interface WorkspaceResolutionIndex {
|
|
43
43
|
/** Class def `nodeId` → that class's `Scope`. */
|
|
44
44
|
readonly classScopeByDefId: ReadonlyMap<string, Scope>;
|
|
@@ -48,5 +48,21 @@ export interface WorkspaceResolutionIndex {
|
|
|
48
48
|
readonly classScopeIdToDefId: ReadonlyMap<ScopeId, string>;
|
|
49
49
|
/** Module scope by file path. */
|
|
50
50
|
readonly moduleScopeByFile: ReadonlyMap<string, Scope>;
|
|
51
|
+
/** Precomputed `simpleName → first module-local callable def` (the
|
|
52
|
+
* workspace-wide fallback of `findExportedDefByName`). Materialized here
|
|
53
|
+
* ONCE from the resident module scopes so that fallback is an O(1) lookup
|
|
54
|
+
* instead of an O(files) scan over every module scope's bindings on each
|
|
55
|
+
* unresolved free call — which, under the disk-backed scopeTree, would
|
|
56
|
+
* otherwise fault every module scope in from disk per call (the throughput
|
|
57
|
+
* killer). "First module-local callable in `moduleScopeByFile` order" is the
|
|
58
|
+
* exact semantics the old scan returned, so it is byte-identical. */
|
|
59
|
+
readonly exportedCallableByName: ReadonlyMap<string, SymbolDefinition>;
|
|
51
60
|
}
|
|
52
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Build the workspace scope-lookup index. When `scopeTree` is supplied (the live
|
|
63
|
+
* pipeline), the `Scope`-valued maps are id-backed views that delegate to it —
|
|
64
|
+
* so this index never pins `Scope` objects and the disk seal can actually
|
|
65
|
+
* reclaim them. Without it (unit tests), the legacy direct `Map<K, Scope>` form
|
|
66
|
+
* is returned unchanged.
|
|
67
|
+
*/
|
|
68
|
+
export declare function buildWorkspaceResolutionIndex(parsedFiles: readonly ParsedFile[], scopeTree?: ScopeTree): WorkspaceResolutionIndex;
|