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,337 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolution Context
|
|
3
|
-
*
|
|
4
|
-
* Single implementation of tiered name resolution.
|
|
5
|
-
*
|
|
6
|
-
* Resolution tiers (highest confidence first):
|
|
7
|
-
* 1. Same file (lookupExactAll — authoritative)
|
|
8
|
-
* 2a-named. Named binding chain (walkBindingChain via NamedImportMap)
|
|
9
|
-
* 2a. Import-scoped (iterate importedFiles with lookupExactAll per file)
|
|
10
|
-
* 2b. Package-scoped (iterate indexed files matching package dir with lookupExactAll)
|
|
11
|
-
* 3. Global (lookupClassByName + lookupImplByName + lookupCallableByName — consumers must check count)
|
|
12
|
-
*
|
|
13
|
-
* Each tier queries the minimum necessary scope directly:
|
|
14
|
-
* - Tier 2a iterates the caller's import set (O(imports) × O(1) lookupExactAll).
|
|
15
|
-
* - Tier 2b iterates all indexed files filtered by package dir
|
|
16
|
-
* (O(files) × O(1) lookupExactAll — avoids a global name scan).
|
|
17
|
-
* - Tier 3 combines lookupClassByName + lookupImplByName + lookupCallableByName
|
|
18
|
-
* (three O(1) index lookups with a narrow, type-specific result set).
|
|
19
|
-
*/
|
|
20
|
-
import { createSemanticModel } from './semantic-model.js';
|
|
21
|
-
/**
|
|
22
|
-
* Check if a file path is directly inside a package directory identified by
|
|
23
|
-
* its suffix. Used by Tier 2b package-scoped resolution (Go / C#).
|
|
24
|
-
*/
|
|
25
|
-
export function isFileInPackageDir(filePath, dirSuffix) {
|
|
26
|
-
// Prepend '/' so paths like "internal/auth/service.go" match suffix "/internal/auth/"
|
|
27
|
-
const normalized = '/' + filePath.replace(/\\/g, '/');
|
|
28
|
-
if (!normalized.includes(dirSuffix))
|
|
29
|
-
return false;
|
|
30
|
-
const afterDir = normalized.substring(normalized.indexOf(dirSuffix) + dirSuffix.length);
|
|
31
|
-
return !afterDir.includes('/');
|
|
32
|
-
}
|
|
33
|
-
/** Maximum re-export hops walkBindingChain will follow before giving up.
|
|
34
|
-
* A hard cap is needed to defend against pathological cycles that slip
|
|
35
|
-
* past the `visited` Set (e.g. a binding chain whose key is equal by
|
|
36
|
-
* string value but visits distinct modules). Five hops covers the
|
|
37
|
-
* common TypeScript monorepo pattern (component → pkg/index →
|
|
38
|
-
* packages/index → root/index → types/index). Chains longer than this
|
|
39
|
-
* fall through to Tier 2a-import / Tier 2b / Tier 3 resolution, which
|
|
40
|
-
* is a silent false-negative that the caller may or may not recover
|
|
41
|
-
* from. If a real repo hits this limit, raise it — there is no
|
|
42
|
-
* correctness reason to keep it at exactly 5. */
|
|
43
|
-
const MAX_BINDING_CHAIN_DEPTH = 5;
|
|
44
|
-
/**
|
|
45
|
-
* Walk a named-binding re-export chain through NamedImportMap.
|
|
46
|
-
*
|
|
47
|
-
* When file A imports { User } from B, and B re-exports { User } from C,
|
|
48
|
-
* the NamedImportMap for A points to B, but B has no User definition.
|
|
49
|
-
* This function follows the chain: A → B → C until a definition is found.
|
|
50
|
-
*
|
|
51
|
-
* Returns the definitions found at the end of the chain, or null if the
|
|
52
|
-
* chain breaks (missing binding, circular reference, or
|
|
53
|
-
* {@link MAX_BINDING_CHAIN_DEPTH} exceeded). Internal to
|
|
54
|
-
* resolution-context — not exported from the model barrel.
|
|
55
|
-
*/
|
|
56
|
-
function walkBindingChain(name, currentFilePath, symbolTable, namedImportMap) {
|
|
57
|
-
// Fast exit: most files have no named imports at all. Skip the Set
|
|
58
|
-
// allocation + loop entry on the common empty-binding path so resolve()
|
|
59
|
-
// stays allocation-free for the typical call site.
|
|
60
|
-
const firstBindings = namedImportMap.get(currentFilePath);
|
|
61
|
-
if (!firstBindings)
|
|
62
|
-
return null;
|
|
63
|
-
const firstBinding = firstBindings.get(name);
|
|
64
|
-
if (!firstBinding)
|
|
65
|
-
return null;
|
|
66
|
-
let lookupFile = currentFilePath;
|
|
67
|
-
let lookupName = name;
|
|
68
|
-
const visited = new Set();
|
|
69
|
-
for (let depth = 0; depth < MAX_BINDING_CHAIN_DEPTH; depth++) {
|
|
70
|
-
const bindings = depth === 0 ? firstBindings : namedImportMap.get(lookupFile);
|
|
71
|
-
if (!bindings)
|
|
72
|
-
return null;
|
|
73
|
-
const binding = depth === 0 ? firstBinding : bindings.get(lookupName);
|
|
74
|
-
if (!binding)
|
|
75
|
-
return null;
|
|
76
|
-
const key = `${binding.sourcePath}:${binding.exportedName}`;
|
|
77
|
-
if (visited.has(key))
|
|
78
|
-
return null; // circular
|
|
79
|
-
visited.add(key);
|
|
80
|
-
const targetName = binding.exportedName;
|
|
81
|
-
const resolvedDefs = symbolTable.lookupExactAll(binding.sourcePath, targetName);
|
|
82
|
-
if (resolvedDefs.length > 0)
|
|
83
|
-
return resolvedDefs;
|
|
84
|
-
// No definition in source file → follow re-export chain
|
|
85
|
-
lookupFile = binding.sourcePath;
|
|
86
|
-
lookupName = targetName;
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
/** Confidence scores per resolution tier. */
|
|
91
|
-
export const TIER_CONFIDENCE = {
|
|
92
|
-
'same-file': 0.95,
|
|
93
|
-
'import-scoped': 0.9,
|
|
94
|
-
global: 0.5,
|
|
95
|
-
};
|
|
96
|
-
export const createResolutionContext = () => {
|
|
97
|
-
const model = createSemanticModel();
|
|
98
|
-
const symbols = model.symbols;
|
|
99
|
-
const importMap = new Map();
|
|
100
|
-
const packageMap = new Map();
|
|
101
|
-
const namedImportMap = new Map();
|
|
102
|
-
const moduleAliasMap = new Map();
|
|
103
|
-
// Inverted index: packageDirSuffix → Set<filePath>.
|
|
104
|
-
// Built lazily on first Tier 2b hit — one-time cost of O(totalFiles ×
|
|
105
|
-
// allUniqueDirSuffixes) isFileInPackageDir calls across the entire
|
|
106
|
-
// packageMap, amortized over the pipeline run. Subsequent Tier 2b
|
|
107
|
-
// resolutions are O(callerPackages × filesInPackage × O(1)).
|
|
108
|
-
let packageDirIndex = null;
|
|
109
|
-
// Per-file cache state
|
|
110
|
-
let cacheFile = null;
|
|
111
|
-
let cache = null;
|
|
112
|
-
let cacheHits = 0;
|
|
113
|
-
let cacheMisses = 0;
|
|
114
|
-
// Tier hit counters — replaces the lost fuzzyCallCount diagnostic
|
|
115
|
-
let tierSameFile = 0;
|
|
116
|
-
let tierImportScoped = 0;
|
|
117
|
-
let tierGlobal = 0;
|
|
118
|
-
let tierMiss = 0;
|
|
119
|
-
// --- Core resolution (single implementation of tier logic) ---
|
|
120
|
-
const resolveUncached = (name, fromFile) => {
|
|
121
|
-
// Tier 1: Same file — authoritative match (returns all overloads)
|
|
122
|
-
const localDefs = symbols.lookupExactAll(fromFile, name);
|
|
123
|
-
if (localDefs.length > 0) {
|
|
124
|
-
tierSameFile++;
|
|
125
|
-
return { candidates: localDefs, tier: 'same-file' };
|
|
126
|
-
}
|
|
127
|
-
// Tier 2a-named: Named binding chain (aliased / re-exported imports)
|
|
128
|
-
// Checked before import-scoped so that `import { User as U }` resolves
|
|
129
|
-
// correctly even when lookupExactAll on the alias name returns nothing.
|
|
130
|
-
const chainResult = walkBindingChain(name, fromFile, symbols, namedImportMap);
|
|
131
|
-
if (chainResult && chainResult.length > 0) {
|
|
132
|
-
tierImportScoped++;
|
|
133
|
-
return { candidates: chainResult, tier: 'import-scoped' };
|
|
134
|
-
}
|
|
135
|
-
// Tier 2a: Import-scoped — iterate the caller's imported files directly.
|
|
136
|
-
// O(importedFiles) × O(1) lookupExactAll — no global name scan needed.
|
|
137
|
-
const importedFiles = importMap.get(fromFile);
|
|
138
|
-
if (importedFiles) {
|
|
139
|
-
const importedDefs = [];
|
|
140
|
-
for (const file of importedFiles) {
|
|
141
|
-
importedDefs.push(...symbols.lookupExactAll(file, name));
|
|
142
|
-
}
|
|
143
|
-
if (importedDefs.length > 0) {
|
|
144
|
-
tierImportScoped++;
|
|
145
|
-
return { candidates: importedDefs, tier: 'import-scoped' };
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// Tier 2b: Package-scoped — look up files in the caller's imported package
|
|
149
|
-
// directories via an inverted index (packageDirSuffix → Set<filePath>),
|
|
150
|
-
// then do O(1) lookupExactAll per file. The inverted index is built lazily
|
|
151
|
-
// on first Tier 2b hit by scanning symbols.getFiles() once, making
|
|
152
|
-
// subsequent Tier 2b resolutions O(packages × filesInPackage) instead of
|
|
153
|
-
// O(allFiles × packages).
|
|
154
|
-
const importedPackages = packageMap.get(fromFile);
|
|
155
|
-
if (importedPackages) {
|
|
156
|
-
// Lazily build the inverted index on first use. For each indexed file,
|
|
157
|
-
// test it against isFileInPackageDir for all known dirSuffixes collected
|
|
158
|
-
// from packageMap. This scans all files once (instead of per-resolution)
|
|
159
|
-
// and produces a dirSuffix → Set<filePath> map.
|
|
160
|
-
if (!packageDirIndex) {
|
|
161
|
-
// Collect all unique dir suffixes across the entire packageMap
|
|
162
|
-
const allDirSuffixes = new Set();
|
|
163
|
-
for (const dirs of packageMap.values()) {
|
|
164
|
-
for (const d of dirs)
|
|
165
|
-
allDirSuffixes.add(d);
|
|
166
|
-
}
|
|
167
|
-
packageDirIndex = new Map();
|
|
168
|
-
for (const file of symbols.getFiles()) {
|
|
169
|
-
for (const dirSuffix of allDirSuffixes) {
|
|
170
|
-
if (isFileInPackageDir(file, dirSuffix)) {
|
|
171
|
-
let files = packageDirIndex.get(dirSuffix);
|
|
172
|
-
if (!files) {
|
|
173
|
-
files = new Set();
|
|
174
|
-
packageDirIndex.set(dirSuffix, files);
|
|
175
|
-
}
|
|
176
|
-
files.add(file);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
const packageDefs = [];
|
|
182
|
-
for (const dirSuffix of importedPackages) {
|
|
183
|
-
const filesInDir = packageDirIndex.get(dirSuffix);
|
|
184
|
-
if (filesInDir) {
|
|
185
|
-
for (const file of filesInDir) {
|
|
186
|
-
packageDefs.push(...symbols.lookupExactAll(file, name));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (packageDefs.length > 0) {
|
|
191
|
-
tierImportScoped++;
|
|
192
|
-
return { candidates: packageDefs, tier: 'import-scoped' };
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
// Tier 3: Global — targeted O(1) index lookups for each symbol category.
|
|
196
|
-
// Class-like symbols (Class, Struct, Interface, Enum, Record, Trait) are
|
|
197
|
-
// covered by lookupClassByName; Rust impl blocks by lookupImplByName
|
|
198
|
-
// (separate to avoid polluting heritage resolution); free callables
|
|
199
|
-
// (Function, Macro, Delegate) by lookupCallableByName; owner-scoped
|
|
200
|
-
// methods and constructors by `model.methods.lookupMethodByName`.
|
|
201
|
-
//
|
|
202
|
-
// FREE_CALLABLE_TYPES excludes Method/Constructor, so strictly-labeled
|
|
203
|
-
// methods are disjoint between the two indexes.
|
|
204
|
-
//
|
|
205
|
-
// Partial-state caveat: Python/Rust/Kotlin class methods are emitted
|
|
206
|
-
// as Function + ownerId — `rawSymbols.add` routes them through both
|
|
207
|
-
// the Function callable index AND, via the dispatch-key normalization
|
|
208
|
-
// in `wrappedAdd`, the method registry. The same `SymbolDefinition`
|
|
209
|
-
// reference lands in both `callableDefs` and `methodDefs`, so the
|
|
210
|
-
// Set-based dedup below is required.
|
|
211
|
-
//
|
|
212
|
-
// Known exclusion: TypeAlias, Const, and Variable are NOT reachable at
|
|
213
|
-
// Tier 3 — they don't belong to any of the indexes. TypeAlias is not
|
|
214
|
-
// a call target; Const/Variable are resolved via import or same-file
|
|
215
|
-
// tiers. Macro (C/C++) and Delegate (C#) stay in the callable index
|
|
216
|
-
// since call-processor.ts treats them as callable targets.
|
|
217
|
-
const classDefs = model.types.lookupClassByName(name);
|
|
218
|
-
const implDefs = model.types.lookupImplByName(name);
|
|
219
|
-
const callableDefs = symbols.lookupCallableByName(name);
|
|
220
|
-
const methodDefs = model.methods.lookupMethodByName(name);
|
|
221
|
-
if (classDefs.length === 0 &&
|
|
222
|
-
implDefs.length === 0 &&
|
|
223
|
-
callableDefs.length === 0 &&
|
|
224
|
-
methodDefs.length === 0) {
|
|
225
|
-
tierMiss++;
|
|
226
|
-
return null;
|
|
227
|
-
}
|
|
228
|
-
// Fast path: if no `Function + ownerId` class method was ever
|
|
229
|
-
// registered into the method registry (the only source of
|
|
230
|
-
// cross-index duplication), the callable and method indexes are
|
|
231
|
-
// guaranteed disjoint and we can concat without dedup.
|
|
232
|
-
if (!model.methods.hasFunctionMethods) {
|
|
233
|
-
const globalDefs = [
|
|
234
|
-
...classDefs,
|
|
235
|
-
...implDefs,
|
|
236
|
-
...callableDefs,
|
|
237
|
-
...methodDefs,
|
|
238
|
-
];
|
|
239
|
-
tierGlobal++;
|
|
240
|
-
return { candidates: globalDefs, tier: 'global' };
|
|
241
|
-
}
|
|
242
|
-
// Slow path: dedup by nodeId because the same SymbolDefinition
|
|
243
|
-
// reference can land in both `callableDefs` (via the Function
|
|
244
|
-
// callable-index gate) and `methodDefs` (via the dispatch-key
|
|
245
|
-
// normalization routing Function+ownerId into MethodRegistry).
|
|
246
|
-
// Dedup covers all four index reads so any nodeId overlap (even
|
|
247
|
-
// theoretical ones between classDefs/implDefs) is caught.
|
|
248
|
-
const globalDefs = [];
|
|
249
|
-
const seen = new Set();
|
|
250
|
-
const pushUnique = (pool) => {
|
|
251
|
-
for (const def of pool) {
|
|
252
|
-
if (seen.has(def.nodeId))
|
|
253
|
-
continue;
|
|
254
|
-
seen.add(def.nodeId);
|
|
255
|
-
globalDefs.push(def);
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
pushUnique(classDefs);
|
|
259
|
-
pushUnique(implDefs);
|
|
260
|
-
pushUnique(callableDefs);
|
|
261
|
-
pushUnique(methodDefs);
|
|
262
|
-
tierGlobal++;
|
|
263
|
-
return { candidates: globalDefs, tier: 'global' };
|
|
264
|
-
};
|
|
265
|
-
const resolve = (name, fromFile) => {
|
|
266
|
-
// Check cache (only when enabled AND fromFile matches cached file)
|
|
267
|
-
if (cache && cacheFile === fromFile) {
|
|
268
|
-
if (cache.has(name)) {
|
|
269
|
-
cacheHits++;
|
|
270
|
-
return cache.get(name);
|
|
271
|
-
}
|
|
272
|
-
cacheMisses++;
|
|
273
|
-
}
|
|
274
|
-
const result = resolveUncached(name, fromFile);
|
|
275
|
-
// Store in cache if active and file matches
|
|
276
|
-
if (cache && cacheFile === fromFile) {
|
|
277
|
-
cache.set(name, result);
|
|
278
|
-
}
|
|
279
|
-
return result;
|
|
280
|
-
};
|
|
281
|
-
// --- Cache lifecycle ---
|
|
282
|
-
const enableCache = (filePath) => {
|
|
283
|
-
cacheFile = filePath;
|
|
284
|
-
if (!cache)
|
|
285
|
-
cache = new Map();
|
|
286
|
-
else
|
|
287
|
-
cache.clear();
|
|
288
|
-
};
|
|
289
|
-
const clearCache = () => {
|
|
290
|
-
cacheFile = null;
|
|
291
|
-
// Reuse the Map instance — just clear entries to reduce GC pressure at scale.
|
|
292
|
-
cache?.clear();
|
|
293
|
-
// Note: packageDirIndex is NOT invalidated here. It is built lazily on
|
|
294
|
-
// first Tier 2b hit and remains valid across file boundaries because
|
|
295
|
-
// packageMap and the symbol file set are append-only during the calls
|
|
296
|
-
// phase (all parsing/import processing completes before resolution).
|
|
297
|
-
// Invalidating per-file would destroy the amortization benefit — the
|
|
298
|
-
// O(files × dirs) rebuild would run per-file instead of once.
|
|
299
|
-
// Full invalidation happens in clear() (pipeline reset).
|
|
300
|
-
};
|
|
301
|
-
const getStats = () => ({
|
|
302
|
-
...symbols.getStats(),
|
|
303
|
-
cacheHits,
|
|
304
|
-
cacheMisses,
|
|
305
|
-
tierSameFile,
|
|
306
|
-
tierImportScoped,
|
|
307
|
-
tierGlobal,
|
|
308
|
-
tierMiss,
|
|
309
|
-
});
|
|
310
|
-
const clear = () => {
|
|
311
|
-
model.clear();
|
|
312
|
-
importMap.clear();
|
|
313
|
-
packageMap.clear();
|
|
314
|
-
namedImportMap.clear();
|
|
315
|
-
moduleAliasMap.clear();
|
|
316
|
-
packageDirIndex = null; // invalidate — will rebuild on next Tier 2b hit
|
|
317
|
-
clearCache();
|
|
318
|
-
cacheHits = 0;
|
|
319
|
-
cacheMisses = 0;
|
|
320
|
-
tierSameFile = 0;
|
|
321
|
-
tierImportScoped = 0;
|
|
322
|
-
tierGlobal = 0;
|
|
323
|
-
tierMiss = 0;
|
|
324
|
-
};
|
|
325
|
-
return {
|
|
326
|
-
resolve,
|
|
327
|
-
model,
|
|
328
|
-
importMap,
|
|
329
|
-
packageMap,
|
|
330
|
-
namedImportMap,
|
|
331
|
-
moduleAliasMap,
|
|
332
|
-
enableCache,
|
|
333
|
-
clearCache,
|
|
334
|
-
getStats,
|
|
335
|
-
clear,
|
|
336
|
-
};
|
|
337
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export function extractCSharpNamedBindings(importNode) {
|
|
2
|
-
// using_directive — three forms:
|
|
3
|
-
// using Alias = NS.Type; → aliasIdent + qualifiedName
|
|
4
|
-
// using static NS.Type; → static + qualifiedName (no alias)
|
|
5
|
-
// using NS; → qualifiedName only (namespace, not capturable)
|
|
6
|
-
if (importNode.type !== 'using_directive')
|
|
7
|
-
return undefined;
|
|
8
|
-
let aliasIdent = null;
|
|
9
|
-
let qualifiedName = null;
|
|
10
|
-
let isStatic = false;
|
|
11
|
-
for (let i = 0; i < importNode.childCount; i++) {
|
|
12
|
-
const child = importNode.child(i);
|
|
13
|
-
if (child?.text === 'static')
|
|
14
|
-
isStatic = true;
|
|
15
|
-
}
|
|
16
|
-
for (let i = 0; i < importNode.namedChildCount; i++) {
|
|
17
|
-
const child = importNode.namedChild(i);
|
|
18
|
-
if (child?.type === 'identifier' && !aliasIdent)
|
|
19
|
-
aliasIdent = child;
|
|
20
|
-
else if (child?.type === 'qualified_name')
|
|
21
|
-
qualifiedName = child;
|
|
22
|
-
}
|
|
23
|
-
// Form 1: using Alias = NS.Type;
|
|
24
|
-
if (aliasIdent && qualifiedName) {
|
|
25
|
-
const fullText = qualifiedName.text;
|
|
26
|
-
const exportedName = fullText.includes('.') ? fullText.split('.').pop() : fullText;
|
|
27
|
-
return [{ local: aliasIdent.text, exported: exportedName }];
|
|
28
|
-
}
|
|
29
|
-
// Form 2: using static NS.Type; — last segment is the class name
|
|
30
|
-
if (isStatic && qualifiedName) {
|
|
31
|
-
const fullText = qualifiedName.text;
|
|
32
|
-
const lastSegment = fullText.includes('.') ? fullText.split('.').pop() : fullText;
|
|
33
|
-
return [{ local: lastSegment, exported: lastSegment }];
|
|
34
|
-
}
|
|
35
|
-
// Form 3: using NS; — namespace import, can't resolve to per-symbol bindings
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { findChild } from '../utils/ast-helpers.js';
|
|
2
|
-
export function extractJavaNamedBindings(importNode) {
|
|
3
|
-
// import_declaration > scoped_identifier "com.example.models.User"
|
|
4
|
-
// Wildcard imports (.*) don't produce named bindings
|
|
5
|
-
if (importNode.type !== 'import_declaration')
|
|
6
|
-
return undefined;
|
|
7
|
-
// Check for asterisk (wildcard import) and static modifier
|
|
8
|
-
let isStatic = false;
|
|
9
|
-
for (let i = 0; i < importNode.childCount; i++) {
|
|
10
|
-
const child = importNode.child(i);
|
|
11
|
-
if (child?.type === 'asterisk')
|
|
12
|
-
return undefined;
|
|
13
|
-
if (child?.text === 'static')
|
|
14
|
-
isStatic = true;
|
|
15
|
-
}
|
|
16
|
-
const scopedId = findChild(importNode, 'scoped_identifier');
|
|
17
|
-
if (!scopedId)
|
|
18
|
-
return undefined;
|
|
19
|
-
const fullText = scopedId.text;
|
|
20
|
-
const lastDot = fullText.lastIndexOf('.');
|
|
21
|
-
if (lastDot === -1)
|
|
22
|
-
return undefined;
|
|
23
|
-
const name = fullText.slice(lastDot + 1);
|
|
24
|
-
// Non-static: skip lowercase names — those are package imports, not class imports.
|
|
25
|
-
// Static: allow lowercase — `import static models.UserFactory.getUser` imports a method.
|
|
26
|
-
if (!isStatic && name[0] && name[0] === name[0].toLowerCase())
|
|
27
|
-
return undefined;
|
|
28
|
-
return [{ local: name, exported: name }];
|
|
29
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { findChild } from '../utils/ast-helpers.js';
|
|
2
|
-
export function extractKotlinNamedBindings(importNode) {
|
|
3
|
-
// import_header > identifier + import_alias > simple_identifier
|
|
4
|
-
if (importNode.type !== 'import_header')
|
|
5
|
-
return undefined;
|
|
6
|
-
const fullIdent = findChild(importNode, 'identifier');
|
|
7
|
-
if (!fullIdent)
|
|
8
|
-
return undefined;
|
|
9
|
-
const fullText = fullIdent.text;
|
|
10
|
-
const exportedName = fullText.includes('.') ? fullText.split('.').pop() : fullText;
|
|
11
|
-
const importAlias = findChild(importNode, 'import_alias');
|
|
12
|
-
if (importAlias) {
|
|
13
|
-
// Aliased: import com.example.User as U
|
|
14
|
-
const aliasIdent = findChild(importAlias, 'simple_identifier');
|
|
15
|
-
if (!aliasIdent)
|
|
16
|
-
return undefined;
|
|
17
|
-
return [{ local: aliasIdent.text, exported: exportedName }];
|
|
18
|
-
}
|
|
19
|
-
// Non-aliased: import com.example.User → local="User", exported="User"
|
|
20
|
-
// Also handles top-level function imports: import models.getUser → local="getUser"
|
|
21
|
-
// Skip wildcard imports (ending in *)
|
|
22
|
-
if (fullText.endsWith('.*') || fullText.endsWith('*'))
|
|
23
|
-
return undefined;
|
|
24
|
-
// Skip class-member imports (e.g., import util.OneArg.writeAudit) where the
|
|
25
|
-
// second-to-last segment is PascalCase (a class name). Multiple member imports
|
|
26
|
-
// with the same function name would collide in NamedImportMap, breaking
|
|
27
|
-
// arity-based disambiguation. Top-level function imports (import models.getUser)
|
|
28
|
-
// and class imports (import models.User) have package-only prefixes.
|
|
29
|
-
const segments = fullText.split('.');
|
|
30
|
-
if (segments.length >= 3) {
|
|
31
|
-
const parentSegment = segments[segments.length - 2];
|
|
32
|
-
if (parentSegment[0] && parentSegment[0] === parentSegment[0].toUpperCase())
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
return [{ local: exportedName, exported: exportedName }];
|
|
36
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export function extractPhpNamedBindings(importNode) {
|
|
2
|
-
// namespace_use_declaration > namespace_use_clause* (flat)
|
|
3
|
-
// namespace_use_declaration > namespace_use_group > namespace_use_clause* (grouped)
|
|
4
|
-
if (importNode.type !== 'namespace_use_declaration')
|
|
5
|
-
return undefined;
|
|
6
|
-
// Skip 'use function' and 'use const' declarations — these import callables/constants,
|
|
7
|
-
// not class types, and should not be added to namedImportMap as type bindings.
|
|
8
|
-
const useTypeNode = importNode.childForFieldName?.('type');
|
|
9
|
-
if (useTypeNode && (useTypeNode.text === 'function' || useTypeNode.text === 'const')) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
const bindings = [];
|
|
13
|
-
// Collect all clauses — from direct children AND from namespace_use_group
|
|
14
|
-
const clauses = [];
|
|
15
|
-
for (let i = 0; i < importNode.namedChildCount; i++) {
|
|
16
|
-
const child = importNode.namedChild(i);
|
|
17
|
-
if (child?.type === 'namespace_use_clause') {
|
|
18
|
-
clauses.push(child);
|
|
19
|
-
}
|
|
20
|
-
else if (child?.type === 'namespace_use_group') {
|
|
21
|
-
for (let j = 0; j < child.namedChildCount; j++) {
|
|
22
|
-
const groupChild = child.namedChild(j);
|
|
23
|
-
if (groupChild?.type === 'namespace_use_clause')
|
|
24
|
-
clauses.push(groupChild);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
for (const clause of clauses) {
|
|
29
|
-
// Flat imports: qualified_name + name (alias)
|
|
30
|
-
let qualifiedName = null;
|
|
31
|
-
const names = [];
|
|
32
|
-
for (let j = 0; j < clause.namedChildCount; j++) {
|
|
33
|
-
const child = clause.namedChild(j);
|
|
34
|
-
if (child?.type === 'qualified_name')
|
|
35
|
-
qualifiedName = child;
|
|
36
|
-
else if (child?.type === 'name')
|
|
37
|
-
names.push(child);
|
|
38
|
-
}
|
|
39
|
-
if (qualifiedName && names.length > 0) {
|
|
40
|
-
// Flat aliased import: use App\Models\Repo as R;
|
|
41
|
-
const fullText = qualifiedName.text;
|
|
42
|
-
const exportedName = fullText.includes('\\') ? fullText.split('\\').pop() : fullText;
|
|
43
|
-
bindings.push({ local: names[0].text, exported: exportedName });
|
|
44
|
-
}
|
|
45
|
-
else if (qualifiedName && names.length === 0) {
|
|
46
|
-
// Flat non-aliased import: use App\Models\User;
|
|
47
|
-
const fullText = qualifiedName.text;
|
|
48
|
-
const lastSegment = fullText.includes('\\') ? fullText.split('\\').pop() : fullText;
|
|
49
|
-
bindings.push({ local: lastSegment, exported: lastSegment });
|
|
50
|
-
}
|
|
51
|
-
else if (!qualifiedName && names.length >= 2) {
|
|
52
|
-
// Grouped aliased import: {Repo as R} — first name = exported, second = alias
|
|
53
|
-
bindings.push({ local: names[1].text, exported: names[0].text });
|
|
54
|
-
}
|
|
55
|
-
else if (!qualifiedName && names.length === 1) {
|
|
56
|
-
// Grouped non-aliased import: {User} in use App\Models\{User, Repo as R}
|
|
57
|
-
bindings.push({ local: names[0].text, exported: names[0].text });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return bindings.length > 0 ? bindings : undefined;
|
|
61
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { findChild } from '../utils/ast-helpers.js';
|
|
2
|
-
export function extractPythonNamedBindings(importNode) {
|
|
3
|
-
// Handle: from x import User, Repo as R
|
|
4
|
-
if (importNode.type === 'import_from_statement') {
|
|
5
|
-
const bindings = [];
|
|
6
|
-
for (let i = 0; i < importNode.namedChildCount; i++) {
|
|
7
|
-
const child = importNode.namedChild(i);
|
|
8
|
-
if (!child)
|
|
9
|
-
continue;
|
|
10
|
-
if (child.type === 'dotted_name') {
|
|
11
|
-
// Skip the module_name (first dotted_name is the source module)
|
|
12
|
-
const fieldName = importNode.childForFieldName?.('module_name');
|
|
13
|
-
if (fieldName && child.startIndex === fieldName.startIndex)
|
|
14
|
-
continue;
|
|
15
|
-
// This is an imported name: from x import User
|
|
16
|
-
const name = child.text;
|
|
17
|
-
if (name)
|
|
18
|
-
bindings.push({ local: name, exported: name });
|
|
19
|
-
}
|
|
20
|
-
if (child.type === 'aliased_import') {
|
|
21
|
-
// from x import Repo as R
|
|
22
|
-
const dottedName = findChild(child, 'dotted_name');
|
|
23
|
-
const aliasIdent = findChild(child, 'identifier');
|
|
24
|
-
if (dottedName && aliasIdent) {
|
|
25
|
-
bindings.push({ local: aliasIdent.text, exported: dottedName.text });
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return bindings.length > 0 ? bindings : undefined;
|
|
30
|
-
}
|
|
31
|
-
// Handle: import numpy as np (import_statement with aliased_import child)
|
|
32
|
-
// Tagged with isModuleAlias so applyImportResult routes these directly to
|
|
33
|
-
// moduleAliasMap (e.g. "np" → "numpy.py") instead of namedImportMap.
|
|
34
|
-
if (importNode.type === 'import_statement') {
|
|
35
|
-
const bindings = [];
|
|
36
|
-
for (let i = 0; i < importNode.namedChildCount; i++) {
|
|
37
|
-
const child = importNode.namedChild(i);
|
|
38
|
-
if (!child || child.type !== 'aliased_import')
|
|
39
|
-
continue;
|
|
40
|
-
const dottedName = findChild(child, 'dotted_name');
|
|
41
|
-
const aliasIdent = findChild(child, 'identifier');
|
|
42
|
-
if (dottedName && aliasIdent) {
|
|
43
|
-
bindings.push({ local: aliasIdent.text, exported: dottedName.text, isModuleAlias: true });
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return bindings.length > 0 ? bindings : undefined;
|
|
47
|
-
}
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export function extractRustNamedBindings(importNode) {
|
|
2
|
-
// use_declaration may contain use_as_clause at any depth
|
|
3
|
-
if (importNode.type !== 'use_declaration')
|
|
4
|
-
return undefined;
|
|
5
|
-
const bindings = [];
|
|
6
|
-
collectRustBindings(importNode, bindings);
|
|
7
|
-
return bindings.length > 0 ? bindings : undefined;
|
|
8
|
-
}
|
|
9
|
-
function collectRustBindings(node, bindings) {
|
|
10
|
-
if (node.type === 'use_as_clause') {
|
|
11
|
-
// First identifier = exported name, second identifier = local alias
|
|
12
|
-
const idents = [];
|
|
13
|
-
for (let i = 0; i < node.namedChildCount; i++) {
|
|
14
|
-
const child = node.namedChild(i);
|
|
15
|
-
if (child?.type === 'identifier')
|
|
16
|
-
idents.push(child.text);
|
|
17
|
-
// For scoped_identifier, extract the last segment
|
|
18
|
-
if (child?.type === 'scoped_identifier') {
|
|
19
|
-
const nameNode = child.childForFieldName?.('name');
|
|
20
|
-
if (nameNode)
|
|
21
|
-
idents.push(nameNode.text);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (idents.length === 2) {
|
|
25
|
-
bindings.push({ local: idents[1], exported: idents[0] });
|
|
26
|
-
}
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
// Terminal identifier in a use_list: use crate::models::{User, Repo}
|
|
30
|
-
if (node.type === 'identifier' && node.parent?.type === 'use_list') {
|
|
31
|
-
bindings.push({ local: node.text, exported: node.text });
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
// Skip scoped_identifier that serves as path prefix in scoped_use_list
|
|
35
|
-
// e.g. use crate::models::{User, Repo} — the path node "crate::models" is not an importable symbol
|
|
36
|
-
if (node.type === 'scoped_identifier' && node.parent?.type === 'scoped_use_list') {
|
|
37
|
-
return; // path prefix — the use_list sibling handles the actual symbols
|
|
38
|
-
}
|
|
39
|
-
// Terminal scoped_identifier: use crate::models::User;
|
|
40
|
-
// Only extract if this is a leaf (no deeper use_list/use_as_clause/scoped_use_list)
|
|
41
|
-
if (node.type === 'scoped_identifier') {
|
|
42
|
-
let hasDeeper = false;
|
|
43
|
-
for (let i = 0; i < node.namedChildCount; i++) {
|
|
44
|
-
const child = node.namedChild(i);
|
|
45
|
-
if (child?.type === 'use_list' ||
|
|
46
|
-
child?.type === 'use_as_clause' ||
|
|
47
|
-
child?.type === 'scoped_use_list') {
|
|
48
|
-
hasDeeper = true;
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (!hasDeeper) {
|
|
53
|
-
const nameNode = node.childForFieldName?.('name');
|
|
54
|
-
if (nameNode) {
|
|
55
|
-
bindings.push({ local: nameNode.text, exported: nameNode.text });
|
|
56
|
-
}
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// Recurse into children
|
|
61
|
-
for (let i = 0; i < node.namedChildCount; i++) {
|
|
62
|
-
const child = node.namedChild(i);
|
|
63
|
-
if (child)
|
|
64
|
-
collectRustBindings(child, bindings);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Named binding types — shared across all per-language binding extractors.
|
|
3
|
-
*
|
|
4
|
-
* Extracted from import-resolution.ts to co-locate types with their consumers.
|
|
5
|
-
*/
|
|
6
|
-
import type { SyntaxNode } from '../utils/ast-helpers.js';
|
|
7
|
-
/** A single named import binding: local name in the importing file and exported name from the source.
|
|
8
|
-
* When `isModuleAlias` is true, the binding represents a Python `import X as Y` module alias
|
|
9
|
-
* and is routed to moduleAliasMap instead of namedImportMap during import processing. */
|
|
10
|
-
export interface NamedBinding {
|
|
11
|
-
local: string;
|
|
12
|
-
exported: string;
|
|
13
|
-
isModuleAlias?: boolean;
|
|
14
|
-
}
|
|
15
|
-
/** Per-language named binding extractor -- optional (returns undefined if language has no named imports). */
|
|
16
|
-
export type NamedBindingExtractorFn = (importNode: SyntaxNode) => NamedBinding[] | undefined;
|