gitnexus 1.6.6-rc.99 → 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 +162 -3
- package/dist/core/ingestion/languages/go/interface-impls.js +476 -50
- package/dist/core/ingestion/languages/go/interpret.js +21 -11
- package/dist/core/ingestion/languages/go/method-owners.js +20 -8
- package/dist/core/ingestion/languages/go/query.js +15 -7
- package/dist/core/ingestion/languages/go/range-binding.js +24 -9
- package/dist/core/ingestion/languages/go/receiver-binding.js +1 -1
- package/dist/core/ingestion/languages/go/scope-resolver.js +2 -2
- package/dist/core/ingestion/languages/go/simple-hooks.js +10 -5
- package/dist/core/ingestion/languages/go/type-binding.d.ts +1 -0
- package/dist/core/ingestion/languages/go/type-binding.js +40 -2
- package/dist/core/ingestion/languages/go.d.ts +0 -1
- package/dist/core/ingestion/languages/go.js +0 -5
- package/dist/core/ingestion/languages/index.d.ts +0 -5
- package/dist/core/ingestion/languages/index.js +0 -3
- package/dist/core/ingestion/languages/java/captures.js +252 -23
- package/dist/core/ingestion/languages/java/interpret.js +12 -6
- package/dist/core/ingestion/languages/java/package-siblings.js +18 -5
- package/dist/core/ingestion/languages/java/query.js +16 -1
- package/dist/core/ingestion/languages/java/scope-resolver.d.ts +2 -8
- package/dist/core/ingestion/languages/java/scope-resolver.js +2 -8
- package/dist/core/ingestion/languages/java.js +0 -5
- package/dist/core/ingestion/languages/javascript/captures.js +185 -11
- package/dist/core/ingestion/languages/javascript/query.js +107 -1
- package/dist/core/ingestion/languages/kotlin/capture-side-channel.d.ts +57 -0
- package/dist/core/ingestion/languages/kotlin/capture-side-channel.js +60 -0
- package/dist/core/ingestion/languages/kotlin/captures.js +213 -22
- package/dist/core/ingestion/languages/kotlin/companion-scopes.d.ts +7 -0
- package/dist/core/ingestion/languages/kotlin/companion-scopes.js +10 -0
- package/dist/core/ingestion/languages/kotlin/index.d.ts +1 -0
- package/dist/core/ingestion/languages/kotlin/index.js +1 -0
- package/dist/core/ingestion/languages/kotlin/query.js +30 -0
- package/dist/core/ingestion/languages/kotlin/scope-resolver.d.ts +5 -7
- package/dist/core/ingestion/languages/kotlin/scope-resolver.js +22 -7
- package/dist/core/ingestion/languages/kotlin.js +8 -5
- package/dist/core/ingestion/languages/php/captures.js +135 -19
- package/dist/core/ingestion/languages/php/import-decomposer.js +21 -63
- package/dist/core/ingestion/languages/php/index.d.ts +3 -4
- package/dist/core/ingestion/languages/php/index.js +3 -4
- package/dist/core/ingestion/languages/php/query.js +5 -0
- package/dist/core/ingestion/languages/php/receiver-binding.js +8 -4
- package/dist/core/ingestion/languages/php.js +0 -4
- package/dist/core/ingestion/languages/python/captures.js +128 -13
- package/dist/core/ingestion/languages/python/depends-references.js +1 -1
- package/dist/core/ingestion/languages/python/import-target.d.ts +4 -5
- package/dist/core/ingestion/languages/python/import-target.js +108 -16
- package/dist/core/ingestion/languages/python/index-stats.d.ts +18 -0
- package/dist/core/ingestion/languages/python/index-stats.js +25 -0
- package/dist/core/ingestion/languages/python/index.d.ts +3 -4
- package/dist/core/ingestion/languages/python/index.js +3 -4
- package/dist/core/ingestion/languages/python/query.js +17 -0
- package/dist/core/ingestion/languages/python/scope-resolver.js +7 -6
- package/dist/core/ingestion/languages/python.d.ts +0 -2
- package/dist/core/ingestion/languages/python.js +0 -7
- package/dist/core/ingestion/languages/ruby/captures.js +174 -31
- package/dist/core/ingestion/languages/ruby/import-target.js +2 -1
- package/dist/core/ingestion/languages/ruby/interpret.js +2 -1
- package/dist/core/ingestion/languages/ruby/query.js +10 -0
- package/dist/core/ingestion/languages/ruby/scope-resolver.js +61 -11
- package/dist/core/ingestion/languages/ruby.js +4 -53
- package/dist/core/ingestion/languages/rust/captures.js +95 -13
- package/dist/core/ingestion/languages/rust/query.js +64 -1
- package/dist/core/ingestion/languages/rust/range-binding.js +40 -12
- package/dist/core/ingestion/languages/rust/receiver-binding.js +9 -0
- package/dist/core/ingestion/languages/rust/scope-resolver.js +75 -1
- package/dist/core/ingestion/languages/rust.d.ts +0 -2
- package/dist/core/ingestion/languages/rust.js +0 -6
- package/dist/core/ingestion/languages/swift/arity-metadata.d.ts +24 -0
- package/dist/core/ingestion/languages/swift/arity-metadata.js +41 -0
- package/dist/core/ingestion/languages/swift/arity.d.ts +29 -0
- package/dist/core/ingestion/languages/swift/arity.js +42 -0
- package/dist/core/ingestion/languages/swift/base-type.d.ts +20 -0
- package/dist/core/ingestion/languages/swift/base-type.js +27 -0
- package/dist/core/ingestion/languages/swift/cache-stats.d.ts +15 -0
- package/dist/core/ingestion/languages/swift/cache-stats.js +26 -0
- package/dist/core/ingestion/languages/swift/captures.d.ts +35 -0
- package/dist/core/ingestion/languages/swift/captures.js +495 -0
- package/dist/core/ingestion/languages/swift/implicit-imports.d.ts +34 -0
- package/dist/core/ingestion/languages/swift/implicit-imports.js +57 -0
- package/dist/core/ingestion/languages/swift/import-decomposer.d.ts +24 -0
- package/dist/core/ingestion/languages/swift/import-decomposer.js +84 -0
- package/dist/core/ingestion/languages/swift/import-target.d.ts +33 -0
- package/dist/core/ingestion/languages/swift/import-target.js +81 -0
- package/dist/core/ingestion/languages/swift/index.d.ts +37 -0
- package/dist/core/ingestion/languages/swift/index.js +37 -0
- package/dist/core/ingestion/languages/swift/interpret.d.ts +15 -0
- package/dist/core/ingestion/languages/swift/interpret.js +89 -0
- package/dist/core/ingestion/languages/swift/merge-bindings.d.ts +20 -0
- package/dist/core/ingestion/languages/swift/merge-bindings.js +48 -0
- package/dist/core/ingestion/languages/swift/query.d.ts +46 -0
- package/dist/core/ingestion/languages/swift/query.js +194 -0
- package/dist/core/ingestion/languages/swift/receiver-binding.d.ts +40 -0
- package/dist/core/ingestion/languages/swift/receiver-binding.js +161 -0
- package/dist/core/ingestion/languages/swift/scope-resolver.d.ts +50 -0
- package/dist/core/ingestion/languages/swift/scope-resolver.js +189 -0
- package/dist/core/ingestion/languages/swift/sibling-type-bindings.d.ts +34 -0
- package/dist/core/ingestion/languages/swift/sibling-type-bindings.js +65 -0
- package/dist/core/ingestion/languages/swift/signature-bindings.d.ts +25 -0
- package/dist/core/ingestion/languages/swift/signature-bindings.js +66 -0
- package/dist/core/ingestion/languages/swift/simple-hooks.d.ts +37 -0
- package/dist/core/ingestion/languages/swift/simple-hooks.js +60 -0
- package/dist/core/ingestion/languages/swift/target-grouping.d.ts +51 -0
- package/dist/core/ingestion/languages/swift/target-grouping.js +93 -0
- package/dist/core/ingestion/languages/swift/target-siblings.d.ts +30 -0
- package/dist/core/ingestion/languages/swift/target-siblings.js +71 -0
- package/dist/core/ingestion/languages/swift.d.ts +0 -5
- package/dist/core/ingestion/languages/swift.js +11 -87
- package/dist/core/ingestion/languages/typescript/array-callback.d.ts +3 -29
- package/dist/core/ingestion/languages/typescript/array-callback.js +4 -43
- package/dist/core/ingestion/languages/typescript/captures.js +147 -17
- package/dist/core/ingestion/languages/typescript/index.d.ts +3 -4
- package/dist/core/ingestion/languages/typescript/index.js +3 -4
- package/dist/core/ingestion/languages/typescript/query.d.ts +2 -3
- package/dist/core/ingestion/languages/typescript/query.js +125 -4
- package/dist/core/ingestion/languages/typescript/receiver-binding.js +0 -1
- package/dist/core/ingestion/languages/typescript.d.ts +2 -3
- package/dist/core/ingestion/languages/typescript.js +46 -23
- package/dist/core/ingestion/languages/vue/captures.d.ts +46 -0
- package/dist/core/ingestion/languages/vue/captures.js +67 -0
- package/dist/core/ingestion/languages/vue/import-target.d.ts +27 -0
- package/dist/core/ingestion/languages/vue/import-target.js +58 -0
- package/dist/core/ingestion/languages/vue/index.d.ts +49 -0
- package/dist/core/ingestion/languages/vue/index.js +49 -0
- package/dist/core/ingestion/languages/vue/scope-resolver.d.ts +55 -0
- package/dist/core/ingestion/languages/vue/scope-resolver.js +292 -0
- package/dist/core/ingestion/languages/vue.js +12 -4
- package/dist/core/ingestion/local-symbol-pruner.d.ts +11 -0
- package/dist/core/ingestion/local-symbol-pruner.js +63 -0
- package/dist/core/ingestion/method-extractors/configs/dart.js +14 -1
- package/dist/core/ingestion/method-extractors/configs/jvm.js +37 -20
- package/dist/core/ingestion/method-extractors/configs/php.js +0 -1
- package/dist/core/ingestion/method-extractors/configs/swift.js +11 -4
- package/dist/core/ingestion/method-types.d.ts +2 -2
- package/dist/core/ingestion/model/index.d.ts +0 -3
- package/dist/core/ingestion/model/index.js +0 -8
- package/dist/core/ingestion/model/resolve.d.ts +7 -43
- package/dist/core/ingestion/model/resolve.js +7 -226
- package/dist/core/ingestion/model/scope-resolution-indexes.d.ts +46 -1
- package/dist/core/ingestion/model/semantic-model.d.ts +4 -6
- package/dist/core/ingestion/model/semantic-model.js +1 -1
- package/dist/core/ingestion/model/symbol-table.d.ts +3 -4
- package/dist/core/ingestion/model/symbol-table.js +3 -4
- package/dist/core/ingestion/parsing-processor.d.ts +30 -24
- package/dist/core/ingestion/parsing-processor.js +76 -640
- package/dist/core/ingestion/pipeline-phases/communities.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/communities.js +5 -2
- package/dist/core/ingestion/pipeline-phases/cross-file.d.ts +9 -8
- package/dist/core/ingestion/pipeline-phases/cross-file.js +16 -12
- package/dist/core/ingestion/pipeline-phases/index.d.ts +1 -0
- package/dist/core/ingestion/pipeline-phases/index.js +1 -0
- package/dist/core/ingestion/pipeline-phases/mro.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/mro.js +2 -2
- package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +44 -22
- package/dist/core/ingestion/pipeline-phases/parse-impl.js +426 -565
- package/dist/core/ingestion/pipeline-phases/parse.d.ts +13 -33
- package/dist/core/ingestion/pipeline-phases/parse.js +2 -2
- package/dist/core/ingestion/pipeline-phases/processes.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/processes.js +5 -3
- package/dist/core/ingestion/pipeline-phases/prune-local-symbols.d.ts +14 -0
- package/dist/core/ingestion/pipeline-phases/prune-local-symbols.js +26 -0
- package/dist/core/ingestion/pipeline.d.ts +27 -19
- package/dist/core/ingestion/pipeline.js +4 -2
- package/dist/core/ingestion/resolve-references.js +15 -3
- package/dist/core/ingestion/route-extractors/laravel.d.ts +10 -0
- package/dist/core/ingestion/route-extractors/laravel.js +88 -9
- package/dist/core/ingestion/scope-extractor-bridge.d.ts +2 -1
- package/dist/core/ingestion/scope-extractor-bridge.js +2 -2
- package/dist/core/ingestion/scope-extractor.js +13 -0
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +181 -15
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.js +21 -10
- package/dist/core/ingestion/scope-resolution/graph-bridge/edges.js +10 -2
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.d.ts +7 -1
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.js +58 -6
- package/dist/core/ingestion/scope-resolution/graph-bridge/node-lookup.js +24 -5
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.d.ts +68 -1
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.js +189 -29
- package/dist/core/ingestion/scope-resolution/passes/imported-return-types.js +21 -1
- package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +1 -1
- package/dist/core/ingestion/scope-resolution/pipeline/phase.d.ts +8 -11
- package/dist/core/ingestion/scope-resolution/pipeline/phase.js +171 -50
- package/dist/core/ingestion/scope-resolution/pipeline/registry.d.ts +3 -4
- package/dist/core/ingestion/scope-resolution/pipeline/registry.js +9 -4
- package/dist/core/ingestion/scope-resolution/pipeline/run.d.ts +28 -5
- package/dist/core/ingestion/scope-resolution/pipeline/run.js +191 -24
- package/dist/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.js +31 -0
- package/dist/core/ingestion/scope-resolution/scope/walkers.d.ts +72 -0
- package/dist/core/ingestion/scope-resolution/scope/walkers.js +440 -39
- package/dist/core/ingestion/scope-resolution/workspace-index.d.ts +18 -2
- package/dist/core/ingestion/scope-resolution/workspace-index.js +94 -7
- package/dist/core/ingestion/tree-sitter-queries.d.ts +14 -14
- package/dist/core/ingestion/tree-sitter-queries.js +380 -158
- package/dist/core/ingestion/ts-js-hoc-utils.d.ts +12 -0
- package/dist/core/ingestion/ts-js-hoc-utils.js +105 -0
- package/dist/core/ingestion/type-env.d.ts +2 -1
- package/dist/core/ingestion/type-env.js +6 -8
- package/dist/core/ingestion/type-extractors/c-cpp.js +8 -10
- package/dist/core/ingestion/type-extractors/csharp.js +18 -34
- package/dist/core/ingestion/type-extractors/go.js +2 -10
- package/dist/core/ingestion/type-extractors/jvm.js +6 -5
- package/dist/core/ingestion/type-extractors/php.js +1 -1
- package/dist/core/ingestion/type-extractors/python.js +1 -1
- package/dist/core/ingestion/type-extractors/ruby.js +2 -2
- package/dist/core/ingestion/type-extractors/rust.js +0 -16
- package/dist/core/ingestion/type-extractors/shared.d.ts +2 -2
- package/dist/core/ingestion/type-extractors/shared.js +25 -11
- package/dist/core/ingestion/type-extractors/swift.js +5 -5
- package/dist/core/ingestion/type-extractors/types.d.ts +1 -1
- package/dist/core/ingestion/type-extractors/typescript.js +1 -1
- package/dist/core/ingestion/utils/ast-helpers.d.ts +119 -1
- package/dist/core/ingestion/utils/ast-helpers.js +260 -13
- package/dist/core/ingestion/utils/callable-labels.d.ts +13 -0
- package/dist/core/ingestion/utils/callable-labels.js +14 -0
- package/dist/core/ingestion/utils/deferred-resolution-profile.d.ts +10 -0
- package/dist/core/ingestion/utils/deferred-resolution-profile.js +30 -0
- package/dist/core/ingestion/utils/heap-probe.d.ts +20 -0
- package/dist/core/ingestion/utils/heap-probe.js +39 -0
- package/dist/core/ingestion/utils/heritage-marker.d.ts +33 -0
- package/dist/core/ingestion/utils/heritage-marker.js +41 -0
- package/dist/core/ingestion/utils/qualified-name.d.ts +37 -0
- package/dist/core/ingestion/utils/qualified-name.js +67 -0
- package/dist/core/ingestion/variable-extractors/configs/c-cpp.js +49 -0
- package/dist/core/ingestion/variable-extractors/configs/dart.js +76 -62
- package/dist/core/ingestion/variable-extractors/configs/go.js +74 -7
- package/dist/core/ingestion/variable-extractors/configs/jvm.js +35 -8
- package/dist/core/ingestion/variable-extractors/generic.js +40 -12
- package/dist/core/ingestion/variable-types.d.ts +9 -0
- package/dist/core/ingestion/vue-sfc-extractor.d.ts +97 -7
- package/dist/core/ingestion/vue-sfc-extractor.js +433 -11
- package/dist/core/ingestion/workers/parse-worker.d.ts +0 -11
- package/dist/core/ingestion/workers/parse-worker.js +358 -187
- package/dist/core/ingestion/workers/worker-pool.d.ts +78 -9
- package/dist/core/ingestion/workers/worker-pool.js +346 -49
- package/dist/core/lbug/csv-generator.js +20 -2
- package/dist/core/lbug/lbug-adapter.js +29 -10
- package/dist/core/lbug/native-check.js +17 -5
- package/dist/core/lbug/pool-adapter.d.ts +0 -19
- package/dist/core/lbug/pool-adapter.js +40 -77
- package/dist/core/lbug/query-result-utils.d.ts +19 -0
- package/dist/core/lbug/query-result-utils.js +28 -0
- package/dist/core/run-analyze.d.ts +9 -2
- package/dist/core/run-analyze.js +24 -3
- package/dist/core/tree-sitter/parser-loader.d.ts +13 -0
- package/dist/core/tree-sitter/parser-loader.js +4 -0
- package/dist/core/tree-sitter/safe-parse.d.ts +70 -3
- package/dist/core/tree-sitter/safe-parse.js +214 -11
- package/dist/core/wiki/generator.js +13 -5
- package/dist/core/wiki/graph-queries.d.ts +3 -0
- package/dist/core/wiki/graph-queries.js +9 -1
- package/dist/core/wiki/llm-client.d.ts +1 -1
- package/dist/core/wiki/llm-client.js +7 -2
- package/dist/core/wiki/local-cli-client.d.ts +2 -1
- package/dist/core/wiki/local-cli-client.js +62 -4
- package/dist/mcp/compatible-stdio-transport.d.ts +3 -0
- package/dist/mcp/compatible-stdio-transport.js +22 -0
- package/dist/mcp/core/embedder.d.ts +1 -1
- package/dist/mcp/core/embedder.js +13 -1
- package/dist/mcp/local/local-backend.d.ts +37 -5
- package/dist/mcp/local/local-backend.js +227 -129
- package/dist/mcp/resources.js +3 -3
- package/dist/mcp/server.js +9 -1
- package/dist/storage/git.d.ts +11 -0
- package/dist/storage/git.js +30 -0
- package/dist/storage/parse-cache.d.ts +23 -1
- package/dist/storage/parse-cache.js +138 -32
- package/dist/storage/parsedfile-store.d.ts +142 -0
- package/dist/storage/parsedfile-store.js +367 -0
- package/dist/storage/repo-manager.d.ts +2 -1
- package/dist/storage/scope-index-store.d.ts +114 -0
- package/dist/storage/scope-index-store.js +236 -0
- package/dist/types/pipeline.d.ts +6 -3
- package/hooks/antigravity/gitnexus-antigravity-hook.cjs +2 -1
- package/hooks/claude/gitnexus-hook.cjs +2 -1
- package/hooks/claude/resolve-analyze-cmd.cjs +323 -0
- package/package.json +4 -5
- package/scripts/bench-scope-resolution.ts +1 -3
- package/scripts/cross-platform-tests.ts +4 -1
- package/skills/gitnexus-cli.md +8 -6
- package/skills/gitnexus-debugging.md +15 -15
- package/skills/gitnexus-exploring.md +11 -11
- package/skills/gitnexus-guide.md +1 -1
- package/skills/gitnexus-impact-analysis.md +10 -10
- package/skills/gitnexus-pr-review.md +19 -19
- package/skills/gitnexus-refactoring.md +25 -25
- package/web/assets/{agent-BRX-afm3.js → agent-EkX7webX.js} +156 -131
- package/web/assets/{architectureDiagram-UL44E2DR-B1oYB8-c.js → architectureDiagram-UL44E2DR-BoczH8cv.js} +1 -1
- package/web/assets/{chunk-LCXTWHL2-SPC6pgWI.js → chunk-LCXTWHL2-By5HB3b-.js} +1 -1
- package/web/assets/{chunk-RG4AUYOV-DZXr4Yv3.js → chunk-RG4AUYOV-BQE_DkpL.js} +1 -1
- package/web/assets/{classDiagram-KGZ6W3CR-BqpOj8L9.js → classDiagram-KGZ6W3CR-Dj_02GUH.js} +1 -1
- package/web/assets/{classDiagram-v2-72OJOZXJ-FmElywK2.js → classDiagram-v2-72OJOZXJ-D-NArMpf.js} +1 -1
- package/web/assets/{diagram-3NCE3AQN-BWtJXMDq.js → diagram-3NCE3AQN-VXtXDO95.js} +1 -1
- package/web/assets/{diagram-GF46GFSD-Hh-fChxU.js → diagram-GF46GFSD-B1qab2Ah.js} +1 -1
- package/web/assets/{diagram-QXG6HAR7-DYeQHxGU.js → diagram-QXG6HAR7-BSCHGzzT.js} +1 -1
- package/web/assets/{diagram-WEQXMOUZ-DYGU4T0y.js → diagram-WEQXMOUZ-DHtknmNT.js} +1 -1
- package/web/assets/{erDiagram-L5TCEMPS-bN3wlP2A.js → erDiagram-L5TCEMPS-Db-IYTmm.js} +1 -1
- package/web/assets/{flowDiagram-H6V6AXG4-YACVtF3-.js → flowDiagram-H6V6AXG4-BHDoyVoW.js} +1 -1
- package/web/assets/{index-BhnAdWTt.js → index-BR0IhgbR.js} +10 -10
- package/web/assets/{infoDiagram-3YFTVSEB-BWBzD28-.js → infoDiagram-3YFTVSEB-6h8wbWEe.js} +1 -1
- package/web/assets/{ishikawaDiagram-BNXS4ZKH-B8qYT-j9.js → ishikawaDiagram-BNXS4ZKH-Dx2OkPk1.js} +1 -1
- package/web/assets/{kanban-definition-75IXJCU3-BeoPr5Tl.js → kanban-definition-75IXJCU3-CIIEZfqV.js} +1 -1
- package/web/assets/{mindmap-definition-2TDM6QVE-CdLLN_so.js → mindmap-definition-2TDM6QVE-DUAqydRq.js} +1 -1
- package/web/assets/{pieDiagram-CU6KROY3-DEd2a_k_.js → pieDiagram-CU6KROY3-BntYuYZa.js} +1 -1
- package/web/assets/{requirementDiagram-JXO7QTGE-QNeTo5C_.js → requirementDiagram-JXO7QTGE-QCD6I29n.js} +1 -1
- package/web/assets/{sequenceDiagram-VS2MUI6T-BHC7q7yJ.js → sequenceDiagram-VS2MUI6T-DScFwLz2.js} +1 -1
- package/web/assets/{stateDiagram-7D4R322I-KONnc2Px.js → stateDiagram-7D4R322I-AkRAm6Hl.js} +1 -1
- package/web/assets/{stateDiagram-v2-36443NZ5-C2QfuMlu.js → stateDiagram-v2-36443NZ5-BCK1vigR.js} +1 -1
- package/web/assets/{timeline-definition-O6YCAMPW-D4t4NJx1.js → timeline-definition-O6YCAMPW-BvpIVXjX.js} +1 -1
- package/web/assets/{vennDiagram-MWXL3ELB-6bctC9Yg.js → vennDiagram-MWXL3ELB-BYGWk6dK.js} +1 -1
- package/web/assets/{wardleyDiagram-CUQ6CDDI-BPZYNTvC.js → wardleyDiagram-CUQ6CDDI-Dk1z7H2T.js} +1 -1
- package/web/assets/{xychartDiagram-N2JHSOCM-lBI9O6DW.js → xychartDiagram-N2JHSOCM-2N6NCSWN.js} +1 -1
- package/web/index.html +1 -1
- package/dist/_shared/scope-resolution/shadow/aggregate.d.ts +0 -63
- package/dist/_shared/scope-resolution/shadow/aggregate.d.ts.map +0 -1
- package/dist/_shared/scope-resolution/shadow/aggregate.js +0 -122
- package/dist/_shared/scope-resolution/shadow/aggregate.js.map +0 -1
- package/dist/_shared/scope-resolution/shadow/diff.d.ts +0 -59
- package/dist/_shared/scope-resolution/shadow/diff.d.ts.map +0 -1
- package/dist/_shared/scope-resolution/shadow/diff.js +0 -79
- package/dist/_shared/scope-resolution/shadow/diff.js.map +0 -1
- package/dist/core/ingestion/ast-cache.d.ts +0 -26
- package/dist/core/ingestion/ast-cache.js +0 -48
- package/dist/core/ingestion/heritage-extractors/configs/go.d.ts +0 -13
- package/dist/core/ingestion/heritage-extractors/configs/go.js +0 -20
- package/dist/core/ingestion/heritage-extractors/configs/ruby.d.ts +0 -18
- package/dist/core/ingestion/heritage-extractors/configs/ruby.js +0 -65
- package/dist/core/ingestion/heritage-extractors/generic.d.ts +0 -23
- package/dist/core/ingestion/heritage-extractors/generic.js +0 -47
- package/dist/core/ingestion/heritage-processor.d.ts +0 -54
- package/dist/core/ingestion/heritage-processor.js +0 -367
- package/dist/core/ingestion/heritage-types.d.ts +0 -73
- package/dist/core/ingestion/heritage-types.js +0 -2
- package/dist/core/ingestion/import-processor.d.ts +0 -23
- package/dist/core/ingestion/import-processor.js +0 -377
- package/dist/core/ingestion/model/heritage-map.d.ts +0 -105
- package/dist/core/ingestion/model/heritage-map.js +0 -294
- package/dist/core/ingestion/model/resolution-context.d.ts +0 -93
- package/dist/core/ingestion/model/resolution-context.js +0 -337
- package/dist/core/ingestion/named-bindings/csharp.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/csharp.js +0 -37
- package/dist/core/ingestion/named-bindings/java.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/java.js +0 -29
- package/dist/core/ingestion/named-bindings/kotlin.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/kotlin.js +0 -36
- package/dist/core/ingestion/named-bindings/php.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/php.js +0 -61
- package/dist/core/ingestion/named-bindings/python.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/python.js +0 -49
- package/dist/core/ingestion/named-bindings/rust.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/rust.js +0 -66
- package/dist/core/ingestion/named-bindings/types.d.ts +0 -16
- package/dist/core/ingestion/named-bindings/types.js +0 -6
- package/dist/core/ingestion/named-bindings/typescript.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/typescript.js +0 -58
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.d.ts +0 -17
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.js +0 -209
- package/dist/core/ingestion/pipeline-phases/orm-extraction.d.ts +0 -22
- package/dist/core/ingestion/pipeline-phases/orm-extraction.js +0 -92
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.d.ts +0 -70
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.js +0 -312
- package/dist/core/ingestion/registry-primary-flag.d.ts +0 -89
- package/dist/core/ingestion/registry-primary-flag.js +0 -122
- package/dist/core/ingestion/shadow-harness.d.ts +0 -113
- package/dist/core/ingestion/shadow-harness.js +0 -148
- package/dist/core/ingestion/utils/ruby-self-call.d.ts +0 -52
- package/dist/core/ingestion/utils/ruby-self-call.js +0 -59
- package/scripts/ci-list-migrated-languages.ts +0 -24
- package/scripts/run-parity.ts +0 -128
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dart built-in / framework names whose calls the legacy DAG suppresses
|
|
3
|
+
* (Flutter / Dart-SDK members not part of the indexed workspace). The
|
|
4
|
+
* registry-primary capture walk skips emitting call references for these so
|
|
5
|
+
* its CALLS graph matches the legacy DAG — which suppresses built-in-named
|
|
6
|
+
* calls via `isBuiltInName` BEFORE resolution, for both free and member calls.
|
|
7
|
+
*
|
|
8
|
+
* Leaf module: shared by the provider (`builtInNames`) and `captures.ts`
|
|
9
|
+
* without an import cycle (`dart.ts` → `dart/index.ts` → `captures.ts`).
|
|
10
|
+
*/
|
|
11
|
+
export const DART_BUILT_INS = new Set([
|
|
12
|
+
'setState',
|
|
13
|
+
'mounted',
|
|
14
|
+
'debugPrint',
|
|
15
|
+
'runApp',
|
|
16
|
+
'showDialog',
|
|
17
|
+
'showModalBottomSheet',
|
|
18
|
+
'Navigator',
|
|
19
|
+
'push',
|
|
20
|
+
'pushNamed',
|
|
21
|
+
'pushReplacement',
|
|
22
|
+
'pop',
|
|
23
|
+
'maybePop',
|
|
24
|
+
'ScaffoldMessenger',
|
|
25
|
+
'showSnackBar',
|
|
26
|
+
'deactivate',
|
|
27
|
+
'reassemble',
|
|
28
|
+
'debugDumpApp',
|
|
29
|
+
'debugDumpRenderTree',
|
|
30
|
+
'then',
|
|
31
|
+
'catchError',
|
|
32
|
+
'whenComplete',
|
|
33
|
+
'listen',
|
|
34
|
+
]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-mode (`PROF_SCOPE_RESOLUTION=1`) cache hit/miss counters for the
|
|
3
|
+
* cross-phase scope-captures parse cache. A module-level `PROF` const folds
|
|
4
|
+
* increments to dead code in production so `captures.ts` stays branch-free.
|
|
5
|
+
* Mirror of `languages/swift/cache-stats.ts`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function recordCacheHit(): void;
|
|
8
|
+
export declare function recordCacheMiss(): void;
|
|
9
|
+
export declare function getDartCaptureCacheStats(): {
|
|
10
|
+
hits: number;
|
|
11
|
+
misses: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function resetDartCaptureCacheStats(): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev-mode (`PROF_SCOPE_RESOLUTION=1`) cache hit/miss counters for the
|
|
3
|
+
* cross-phase scope-captures parse cache. A module-level `PROF` const folds
|
|
4
|
+
* increments to dead code in production so `captures.ts` stays branch-free.
|
|
5
|
+
* Mirror of `languages/swift/cache-stats.ts`.
|
|
6
|
+
*/
|
|
7
|
+
const PROF = process.env.PROF_SCOPE_RESOLUTION === '1';
|
|
8
|
+
let CACHE_HITS = 0;
|
|
9
|
+
let CACHE_MISSES = 0;
|
|
10
|
+
export function recordCacheHit() {
|
|
11
|
+
if (PROF)
|
|
12
|
+
CACHE_HITS++;
|
|
13
|
+
}
|
|
14
|
+
export function recordCacheMiss() {
|
|
15
|
+
if (PROF)
|
|
16
|
+
CACHE_MISSES++;
|
|
17
|
+
}
|
|
18
|
+
export function getDartCaptureCacheStats() {
|
|
19
|
+
return { hits: CACHE_HITS, misses: CACHE_MISSES };
|
|
20
|
+
}
|
|
21
|
+
export function resetDartCaptureCacheStats() {
|
|
22
|
+
CACHE_HITS = 0;
|
|
23
|
+
CACHE_MISSES = 0;
|
|
24
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `emitDartScopeCaptures` — the Dart scope-capture orchestrator (mirror of
|
|
3
|
+
* `languages/swift/captures.ts`, adapted for tree-sitter-dart's grammar).
|
|
4
|
+
*
|
|
5
|
+
* It runs `DART_SCOPE_QUERY` for the constructs that map cleanly to a single
|
|
6
|
+
* node (module/class scopes, type/method/field declarations, imports), then
|
|
7
|
+
* synthesizes the Dart-specific streams the grammar can't express as a single
|
|
8
|
+
* query node:
|
|
9
|
+
*
|
|
10
|
+
* 1. Function/method/constructor SCOPES — `function_signature`/`function_body`
|
|
11
|
+
* are SIBLINGS, so each Function scope is synthesized to span
|
|
12
|
+
* `signature.start .. body.end` (composed range); a constructor's body is
|
|
13
|
+
* a sibling of the wrapping `method_signature`.
|
|
14
|
+
* 2. Receiver (`this`/`super`) + parameter + return type bindings, anchored
|
|
15
|
+
* inside the body so they land in the Function scope.
|
|
16
|
+
* 3. Arity metadata on function-like declarations.
|
|
17
|
+
* 4. Field type bindings (for receiver-chain resolution).
|
|
18
|
+
* 5. References — calls (free/member/cascade) and member reads — from Dart's
|
|
19
|
+
* postfix `identifier (selector …)` chains, which have no
|
|
20
|
+
* `call_expression` node.
|
|
21
|
+
* 6. Local-variable constructor/call-result type inference.
|
|
22
|
+
* 7. Heritage — `extends` → `@reference.inherits` (the generic
|
|
23
|
+
* EXTENDS-by-target-kind pre-pass); `implements`/`with` → side-effect
|
|
24
|
+
* `__heritage__:` import markers consumed by `emitDartHeritageEdges`
|
|
25
|
+
* (Dart `implements <class>` must be IMPLEMENTS regardless of the
|
|
26
|
+
* target's symbol kind).
|
|
27
|
+
*/
|
|
28
|
+
import type { CaptureMatch } from '../../../../_shared/index.js';
|
|
29
|
+
export declare function emitDartScopeCaptures(sourceText: string, _filePath: string, cachedTree?: unknown): readonly CaptureMatch[];
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `emitDartScopeCaptures` — the Dart scope-capture orchestrator (mirror of
|
|
3
|
+
* `languages/swift/captures.ts`, adapted for tree-sitter-dart's grammar).
|
|
4
|
+
*
|
|
5
|
+
* It runs `DART_SCOPE_QUERY` for the constructs that map cleanly to a single
|
|
6
|
+
* node (module/class scopes, type/method/field declarations, imports), then
|
|
7
|
+
* synthesizes the Dart-specific streams the grammar can't express as a single
|
|
8
|
+
* query node:
|
|
9
|
+
*
|
|
10
|
+
* 1. Function/method/constructor SCOPES — `function_signature`/`function_body`
|
|
11
|
+
* are SIBLINGS, so each Function scope is synthesized to span
|
|
12
|
+
* `signature.start .. body.end` (composed range); a constructor's body is
|
|
13
|
+
* a sibling of the wrapping `method_signature`.
|
|
14
|
+
* 2. Receiver (`this`/`super`) + parameter + return type bindings, anchored
|
|
15
|
+
* inside the body so they land in the Function scope.
|
|
16
|
+
* 3. Arity metadata on function-like declarations.
|
|
17
|
+
* 4. Field type bindings (for receiver-chain resolution).
|
|
18
|
+
* 5. References — calls (free/member/cascade) and member reads — from Dart's
|
|
19
|
+
* postfix `identifier (selector …)` chains, which have no
|
|
20
|
+
* `call_expression` node.
|
|
21
|
+
* 6. Local-variable constructor/call-result type inference.
|
|
22
|
+
* 7. Heritage — `extends` → `@reference.inherits` (the generic
|
|
23
|
+
* EXTENDS-by-target-kind pre-pass); `implements`/`with` → side-effect
|
|
24
|
+
* `__heritage__:` import markers consumed by `emitDartHeritageEdges`
|
|
25
|
+
* (Dart `implements <class>` must be IMPLEMENTS regardless of the
|
|
26
|
+
* target's symbol kind).
|
|
27
|
+
*/
|
|
28
|
+
import { nodeToCapture, syntheticCapture, walkNamedTree, findChild, } from '../../utils/ast-helpers.js';
|
|
29
|
+
import { computeDartArityMetadata } from './arity-metadata.js';
|
|
30
|
+
import { synthesizeDartReceiverBinding } from './receiver-binding.js';
|
|
31
|
+
import { synthesizeDartSignatureBindings } from './signature-bindings.js';
|
|
32
|
+
import { getDartParser, getDartScopeQuery } from './query.js';
|
|
33
|
+
import { recordCacheHit, recordCacheMiss } from './cache-stats.js';
|
|
34
|
+
import { getTreeSitterBufferSize } from '../../constants.js';
|
|
35
|
+
import { parseSourceSafe } from '../../../tree-sitter/safe-parse.js';
|
|
36
|
+
import { encodeMarker } from '../../utils/heritage-marker.js';
|
|
37
|
+
import { DART_BUILT_INS } from './built-ins.js';
|
|
38
|
+
const FUNCTION_DECL_TAGS = [
|
|
39
|
+
'@declaration.function',
|
|
40
|
+
'@declaration.method',
|
|
41
|
+
'@declaration.constructor',
|
|
42
|
+
];
|
|
43
|
+
export function emitDartScopeCaptures(sourceText, _filePath, cachedTree) {
|
|
44
|
+
let tree;
|
|
45
|
+
if (cachedTree !== undefined && cachedTree !== null) {
|
|
46
|
+
tree = cachedTree;
|
|
47
|
+
recordCacheHit();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
tree = parseSourceSafe(getDartParser(), sourceText, undefined, {
|
|
51
|
+
bufferSize: getTreeSitterBufferSize(sourceText),
|
|
52
|
+
});
|
|
53
|
+
recordCacheMiss();
|
|
54
|
+
}
|
|
55
|
+
const root = tree.rootNode;
|
|
56
|
+
const out = [];
|
|
57
|
+
// A named constructor (`A.named()`) parses as ONE `constructor_signature`
|
|
58
|
+
// carrying multiple `name:` fields, so the `@declaration.constructor` query
|
|
59
|
+
// pattern matches it more than once. Each match would synthesize an
|
|
60
|
+
// identical-range `@scope.function`, producing duplicate scope ids that make
|
|
61
|
+
// `buildScopeTree` throw and the whole file get dropped. Dedup function-like
|
|
62
|
+
// declarations by their statement node so each is emitted exactly once.
|
|
63
|
+
const seenFnDeclNodes = new Set();
|
|
64
|
+
// ── Pass A: query-driven scopes / declarations / imports ────────────────
|
|
65
|
+
for (const match of getDartScopeQuery().matches(root)) {
|
|
66
|
+
const grouped = {};
|
|
67
|
+
const nodeMap = {};
|
|
68
|
+
for (const c of match.captures) {
|
|
69
|
+
const tag = '@' + c.name;
|
|
70
|
+
grouped[tag] = nodeToCapture(tag, c.node);
|
|
71
|
+
nodeMap[tag] = c.node;
|
|
72
|
+
}
|
|
73
|
+
if (Object.keys(grouped).length === 0)
|
|
74
|
+
continue;
|
|
75
|
+
const declTag = FUNCTION_DECL_TAGS.find((t) => grouped[t] !== undefined);
|
|
76
|
+
if (declTag !== undefined) {
|
|
77
|
+
const declNode = nodeMap[declTag];
|
|
78
|
+
const declKey = `${declNode.startIndex}:${declNode.endIndex}`;
|
|
79
|
+
if (seenFnDeclNodes.has(declKey))
|
|
80
|
+
continue; // dedup named-ctor double-match
|
|
81
|
+
seenFnDeclNodes.add(declKey);
|
|
82
|
+
const bodyNode = findFunctionBody(declNode);
|
|
83
|
+
attachArityMetadata(grouped, declNode);
|
|
84
|
+
out.push(grouped);
|
|
85
|
+
if (bodyNode !== null) {
|
|
86
|
+
out.push({ '@scope.function': spanCapture('@scope.function', declNode, bodyNode) });
|
|
87
|
+
for (const cm of synthesizeDartReceiverBinding(declNode, bodyNode))
|
|
88
|
+
out.push(cm);
|
|
89
|
+
}
|
|
90
|
+
for (const cm of synthesizeDartSignatureBindings(declNode, bodyNode))
|
|
91
|
+
out.push(cm);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
// Class fields: emit the Property declaration AND a class-scope type
|
|
95
|
+
// binding (so `receiver.field.method()` chains resolve the field type).
|
|
96
|
+
if (grouped['@declaration.property'] !== undefined &&
|
|
97
|
+
grouped['@declaration.name'] !== undefined) {
|
|
98
|
+
const propNode = nodeMap['@declaration.property'];
|
|
99
|
+
const fieldType = extractFieldType(propNode);
|
|
100
|
+
const fieldName = grouped['@declaration.name'].text;
|
|
101
|
+
if (fieldType !== null) {
|
|
102
|
+
grouped['@declaration.field-type'] = syntheticCapture('@declaration.field-type', propNode, fieldType);
|
|
103
|
+
}
|
|
104
|
+
out.push(grouped);
|
|
105
|
+
if (fieldType !== null) {
|
|
106
|
+
out.push({
|
|
107
|
+
'@type-binding.annotation': nodeToCapture('@type-binding.annotation', propNode),
|
|
108
|
+
'@type-binding.name': syntheticCapture('@type-binding.name', propNode, fieldName),
|
|
109
|
+
'@type-binding.type': syntheticCapture('@type-binding.type', propNode, fieldType),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
out.push(grouped);
|
|
115
|
+
}
|
|
116
|
+
// ── Pass B: tree-walked references, type inference, heritage ────────────
|
|
117
|
+
const seenReadSpans = new Set();
|
|
118
|
+
walkNamedTree(root, (node) => {
|
|
119
|
+
if (node.type === 'selector') {
|
|
120
|
+
emitSelectorReference(node, out, seenReadSpans);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (node.type === 'cascade_section') {
|
|
124
|
+
emitCascadeReference(node, out);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (node.type === 'initialized_variable_definition') {
|
|
128
|
+
emitVarTypeBinding(node, out);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (node.type === 'class_definition') {
|
|
132
|
+
emitHeritage(node, out);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
// ─── Function scope synthesis ───────────────────────────────────────────────
|
|
139
|
+
/**
|
|
140
|
+
* The sibling `function_body` of a declaration, or null (abstract/bodyless).
|
|
141
|
+
*
|
|
142
|
+
* The body is the next named sibling of the declaration's *statement-level*
|
|
143
|
+
* node. For methods/operators the `@declaration` anchor IS the `method_signature`
|
|
144
|
+
* (body is its sibling). For a constructor the anchor is the INNER
|
|
145
|
+
* `constructor_signature`, whose body is a sibling of the WRAPPING
|
|
146
|
+
* `method_signature` (AST: `class_body > method_signature > constructor_signature`,
|
|
147
|
+
* then `function_body`) — so walk up to the `method_signature` wrapper first.
|
|
148
|
+
* Top-level `function_signature` (parent `program`) and abstract `declaration`
|
|
149
|
+
* nodes are unaffected.
|
|
150
|
+
*/
|
|
151
|
+
function findFunctionBody(declNode) {
|
|
152
|
+
const node = declNode.parent !== null && declNode.parent.type === 'method_signature'
|
|
153
|
+
? declNode.parent
|
|
154
|
+
: declNode;
|
|
155
|
+
const next = node.nextNamedSibling;
|
|
156
|
+
return next !== null && next.type === 'function_body' ? next : null;
|
|
157
|
+
}
|
|
158
|
+
/** A capture whose range spans two nodes (Dart has no node wrapping both a
|
|
159
|
+
* signature and its sibling body). */
|
|
160
|
+
function spanCapture(name, startNode, endNode) {
|
|
161
|
+
return {
|
|
162
|
+
name,
|
|
163
|
+
range: {
|
|
164
|
+
startLine: startNode.startPosition.row + 1,
|
|
165
|
+
startCol: startNode.startPosition.column,
|
|
166
|
+
endLine: endNode.endPosition.row + 1,
|
|
167
|
+
endCol: endNode.endPosition.column,
|
|
168
|
+
},
|
|
169
|
+
text: '',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function attachArityMetadata(grouped, declNode) {
|
|
173
|
+
const meta = computeDartArityMetadata(declNode);
|
|
174
|
+
if (meta.parameterCount !== undefined) {
|
|
175
|
+
grouped['@declaration.parameter-count'] = syntheticCapture('@declaration.parameter-count', declNode, String(meta.parameterCount));
|
|
176
|
+
}
|
|
177
|
+
if (meta.requiredParameterCount !== undefined) {
|
|
178
|
+
grouped['@declaration.required-parameter-count'] = syntheticCapture('@declaration.required-parameter-count', declNode, String(meta.requiredParameterCount));
|
|
179
|
+
}
|
|
180
|
+
if (meta.parameterTypes !== undefined) {
|
|
181
|
+
grouped['@declaration.parameter-types'] = syntheticCapture('@declaration.parameter-types', declNode, JSON.stringify(meta.parameterTypes));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/** The declared type of a class field (`Address address = …` → `Address`). */
|
|
185
|
+
function extractFieldType(declNode) {
|
|
186
|
+
for (let i = 0; i < declNode.namedChildCount; i++) {
|
|
187
|
+
const c = declNode.namedChild(i);
|
|
188
|
+
if (c !== null && (c.type === 'type_identifier' || c.type === 'nullable_type')) {
|
|
189
|
+
return c.text.replace(/\?+$/, '');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
// ─── References: calls + member reads (postfix chains) ──────────────────────
|
|
195
|
+
const ASSIGNABLE_SELECTORS = new Set([
|
|
196
|
+
'unconditional_assignable_selector',
|
|
197
|
+
'conditional_assignable_selector',
|
|
198
|
+
]);
|
|
199
|
+
/** Last named `identifier` child of an assignable/cascade selector. */
|
|
200
|
+
function selectorName(inner) {
|
|
201
|
+
for (let i = inner.namedChildCount - 1; i >= 0; i--) {
|
|
202
|
+
const c = inner.namedChild(i);
|
|
203
|
+
if (c !== null && c.type === 'identifier')
|
|
204
|
+
return c;
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
/** Count call arguments under a `selector(argument_part(arguments(…)))`. */
|
|
209
|
+
function countArgs(argPart) {
|
|
210
|
+
const args = argPart.namedChild(0);
|
|
211
|
+
if (args === null)
|
|
212
|
+
return 0;
|
|
213
|
+
let n = 0;
|
|
214
|
+
for (let i = 0; i < args.namedChildCount; i++) {
|
|
215
|
+
const c = args.namedChild(i);
|
|
216
|
+
if (c !== null && (c.type === 'argument' || c.type === 'named_argument'))
|
|
217
|
+
n++;
|
|
218
|
+
}
|
|
219
|
+
return n;
|
|
220
|
+
}
|
|
221
|
+
/** Receiver text preceding a member-call/read selector (the postfix chain
|
|
222
|
+
* head plus any intermediate selectors): `user.address.save()` → `user.address`. */
|
|
223
|
+
function computeReceiverText(nameSelector) {
|
|
224
|
+
const selectors = [];
|
|
225
|
+
let cur = nameSelector.previousNamedSibling;
|
|
226
|
+
let head = null;
|
|
227
|
+
while (cur !== null) {
|
|
228
|
+
if (cur.type === 'selector') {
|
|
229
|
+
selectors.push(cur);
|
|
230
|
+
cur = cur.previousNamedSibling;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
head = cur;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
if (head === null)
|
|
237
|
+
return null;
|
|
238
|
+
if (head.type !== 'identifier' && head.type !== 'this' && head.type !== 'super')
|
|
239
|
+
return null;
|
|
240
|
+
selectors.reverse();
|
|
241
|
+
let text = head.text;
|
|
242
|
+
for (const s of selectors)
|
|
243
|
+
text += s.text;
|
|
244
|
+
return text;
|
|
245
|
+
}
|
|
246
|
+
function emitSelectorReference(selector, out, seenReadSpans) {
|
|
247
|
+
const inner = selector.namedChild(0);
|
|
248
|
+
if (inner === null)
|
|
249
|
+
return;
|
|
250
|
+
// A `selector(argument_part)` is the call marker; the callee is the
|
|
251
|
+
// immediately-preceding sibling.
|
|
252
|
+
if (inner.type === 'argument_part') {
|
|
253
|
+
const prev = selector.previousNamedSibling;
|
|
254
|
+
if (prev === null)
|
|
255
|
+
return;
|
|
256
|
+
const arity = countArgs(inner);
|
|
257
|
+
if (prev.type === 'identifier') {
|
|
258
|
+
const name = prev.text;
|
|
259
|
+
if (DART_BUILT_INS.has(name))
|
|
260
|
+
return; // legacy suppresses built-in-named calls
|
|
261
|
+
// Dart has no `new`: an UpperCamelCase callee is a constructor call by
|
|
262
|
+
// convention (types are UpperCamelCase) — tag it so `constructorCallTargetsClass`
|
|
263
|
+
// links `Foo()` to the Class node (the legacy DAG emits that edge even for an
|
|
264
|
+
// implicit constructor). A lowercase callee is an ordinary free function call.
|
|
265
|
+
const tag = /^[A-Z]/.test(name) ? '@reference.call.constructor' : '@reference.call.free';
|
|
266
|
+
out.push({
|
|
267
|
+
[tag]: nodeToCapture(tag, prev),
|
|
268
|
+
'@reference.name': nodeToCapture('@reference.name', prev),
|
|
269
|
+
'@reference.arity': syntheticCapture('@reference.arity', prev, String(arity)),
|
|
270
|
+
});
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (prev.type === 'selector') {
|
|
274
|
+
const prevInner = prev.namedChild(0);
|
|
275
|
+
if (prevInner === null)
|
|
276
|
+
return;
|
|
277
|
+
if (ASSIGNABLE_SELECTORS.has(prevInner.type)) {
|
|
278
|
+
const nameId = selectorName(prevInner);
|
|
279
|
+
if (nameId === null)
|
|
280
|
+
return;
|
|
281
|
+
if (DART_BUILT_INS.has(nameId.text))
|
|
282
|
+
return; // legacy suppresses built-in-named calls
|
|
283
|
+
const recv = computeReceiverText(prev);
|
|
284
|
+
const cm = {
|
|
285
|
+
'@reference.call.member': nodeToCapture('@reference.call.member', nameId),
|
|
286
|
+
'@reference.name': nodeToCapture('@reference.name', nameId),
|
|
287
|
+
'@reference.arity': syntheticCapture('@reference.arity', nameId, String(arity)),
|
|
288
|
+
...(recv !== null
|
|
289
|
+
? { '@reference.receiver': syntheticCapture('@reference.receiver', prev, recv) }
|
|
290
|
+
: {}),
|
|
291
|
+
};
|
|
292
|
+
out.push(cm);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
// A member access selector that is NOT immediately followed by a call is a
|
|
298
|
+
// field read (`user.address` in `user.address.save()`).
|
|
299
|
+
if (ASSIGNABLE_SELECTORS.has(inner.type)) {
|
|
300
|
+
const next = selector.nextNamedSibling;
|
|
301
|
+
const isCall = next !== null && next.type === 'selector' && next.namedChild(0)?.type === 'argument_part';
|
|
302
|
+
if (isCall)
|
|
303
|
+
return;
|
|
304
|
+
const nameId = selectorName(inner);
|
|
305
|
+
if (nameId === null)
|
|
306
|
+
return;
|
|
307
|
+
const recv = computeReceiverText(selector);
|
|
308
|
+
if (recv === null)
|
|
309
|
+
return;
|
|
310
|
+
const spanKey = `${nameId.startIndex}-${nameId.endIndex}`;
|
|
311
|
+
if (seenReadSpans.has(spanKey))
|
|
312
|
+
return;
|
|
313
|
+
seenReadSpans.add(spanKey);
|
|
314
|
+
out.push({
|
|
315
|
+
'@reference.read.member': nodeToCapture('@reference.read.member', nameId),
|
|
316
|
+
'@reference.name': nodeToCapture('@reference.name', nameId),
|
|
317
|
+
'@reference.receiver': syntheticCapture('@reference.receiver', selector, recv),
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Cascade call `receiver..method(args)` — Dart's `cascade_section` holds a
|
|
323
|
+
* `cascade_selector` + `argument_part` as DIRECT children (no `selector`
|
|
324
|
+
* wrapper, so `emitSelectorReference` never sees it). The legacy DAG matches
|
|
325
|
+
* `(cascade_section (cascade_selector (identifier)) (argument_part))` and
|
|
326
|
+
* classifies cascade calls as FREE calls — mirror that for parity. A property
|
|
327
|
+
* cascade (`..field = x`, no `argument_part`) is not a call and is skipped.
|
|
328
|
+
*/
|
|
329
|
+
function emitCascadeReference(cascade, out) {
|
|
330
|
+
let selectorNode = null;
|
|
331
|
+
let argPart = null;
|
|
332
|
+
for (let i = 0; i < cascade.namedChildCount; i++) {
|
|
333
|
+
const c = cascade.namedChild(i);
|
|
334
|
+
if (c === null)
|
|
335
|
+
continue;
|
|
336
|
+
if (c.type === 'cascade_selector')
|
|
337
|
+
selectorNode = c;
|
|
338
|
+
else if (c.type === 'argument_part')
|
|
339
|
+
argPart = c;
|
|
340
|
+
}
|
|
341
|
+
if (selectorNode === null || argPart === null)
|
|
342
|
+
return;
|
|
343
|
+
const nameId = selectorName(selectorNode);
|
|
344
|
+
if (nameId === null || DART_BUILT_INS.has(nameId.text))
|
|
345
|
+
return;
|
|
346
|
+
const arity = countArgs(argPart);
|
|
347
|
+
out.push({
|
|
348
|
+
'@reference.call.free': nodeToCapture('@reference.call.free', nameId),
|
|
349
|
+
'@reference.name': nodeToCapture('@reference.name', nameId),
|
|
350
|
+
'@reference.arity': syntheticCapture('@reference.arity', nameId, String(arity)),
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
// ─── Local-variable constructor / call-result type inference ────────────────
|
|
354
|
+
/** Find the callee identifier of a `var x = Callee(…)` / `await Callee(…)`
|
|
355
|
+
* initializer (a direct free-call / constructor); returns null for member
|
|
356
|
+
* calls or non-call values. */
|
|
357
|
+
function findDirectCallValue(initVarDef) {
|
|
358
|
+
const firstValue = initVarDef.childForFieldName('value');
|
|
359
|
+
if (firstValue === null)
|
|
360
|
+
return null;
|
|
361
|
+
if (firstValue.type === 'identifier') {
|
|
362
|
+
const next = firstValue.nextNamedSibling;
|
|
363
|
+
if (next !== null && next.type === 'selector' && next.namedChild(0)?.type === 'argument_part') {
|
|
364
|
+
return firstValue;
|
|
365
|
+
}
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
if (firstValue.type === 'unary_expression' || firstValue.type === 'await_expression') {
|
|
369
|
+
let aw = firstValue;
|
|
370
|
+
if (aw.type === 'unary_expression') {
|
|
371
|
+
const inner = aw.namedChild(0);
|
|
372
|
+
if (inner === null)
|
|
373
|
+
return null;
|
|
374
|
+
aw = inner;
|
|
375
|
+
}
|
|
376
|
+
if (aw.type === 'await_expression') {
|
|
377
|
+
const id = aw.namedChild(0);
|
|
378
|
+
const sel = aw.namedChild(1);
|
|
379
|
+
if (id !== null &&
|
|
380
|
+
id.type === 'identifier' &&
|
|
381
|
+
sel !== null &&
|
|
382
|
+
sel.type === 'selector' &&
|
|
383
|
+
sel.namedChild(0)?.type === 'argument_part') {
|
|
384
|
+
return id;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
function emitVarTypeBinding(initVarDef, out) {
|
|
391
|
+
const nameNode = initVarDef.childForFieldName('name');
|
|
392
|
+
if (nameNode === null)
|
|
393
|
+
return;
|
|
394
|
+
const calleeId = findDirectCallValue(initVarDef);
|
|
395
|
+
if (calleeId === null)
|
|
396
|
+
return;
|
|
397
|
+
out.push({
|
|
398
|
+
'@type-binding.constructor': nodeToCapture('@type-binding.constructor', initVarDef),
|
|
399
|
+
'@type-binding.name': syntheticCapture('@type-binding.name', initVarDef, nameNode.text),
|
|
400
|
+
'@type-binding.type': syntheticCapture('@type-binding.type', initVarDef, calleeId.text),
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
// ─── Heritage ───────────────────────────────────────────────────────────────
|
|
404
|
+
function emitHeritage(classNode, out) {
|
|
405
|
+
const nameNode = classNode.childForFieldName('name');
|
|
406
|
+
if (nameNode === null)
|
|
407
|
+
return;
|
|
408
|
+
const className = nameNode.text;
|
|
409
|
+
const superclass = classNode.childForFieldName('superclass');
|
|
410
|
+
if (superclass !== null) {
|
|
411
|
+
// `extends Base` — the direct `type_identifier` child of `superclass`
|
|
412
|
+
// (the `mixins` node, if present, nests separately). Routed through the
|
|
413
|
+
// generic inherits pre-pass → EXTENDS (the base resolves to a class).
|
|
414
|
+
for (let i = 0; i < superclass.namedChildCount; i++) {
|
|
415
|
+
const c = superclass.namedChild(i);
|
|
416
|
+
if (c !== null && c.type === 'type_identifier') {
|
|
417
|
+
out.push({
|
|
418
|
+
'@reference.inherits': nodeToCapture('@reference.inherits', c),
|
|
419
|
+
'@reference.name': nodeToCapture('@reference.name', c),
|
|
420
|
+
});
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
// `with M1, M2` — mixin application → IMPLEMENTS (Dart mixin dispatch).
|
|
425
|
+
const mixins = findChild(superclass, 'mixins');
|
|
426
|
+
if (mixins !== null) {
|
|
427
|
+
emitHeritageMarkers(mixins, 'with', className, out);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
// `implements I1, I2` — Dart `implements <class>` is IMPLEMENTS regardless
|
|
431
|
+
// of the target's symbol kind, so it cannot use the target-kind pre-pass.
|
|
432
|
+
const interfaces = classNode.childForFieldName('interfaces');
|
|
433
|
+
if (interfaces !== null) {
|
|
434
|
+
emitHeritageMarkers(interfaces, 'implements', className, out);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function emitHeritageMarkers(container, kind, className, out) {
|
|
438
|
+
for (let i = 0; i < container.namedChildCount; i++) {
|
|
439
|
+
const c = container.namedChild(i);
|
|
440
|
+
if (c === null || c.type !== 'type_identifier')
|
|
441
|
+
continue;
|
|
442
|
+
const payload = encodeMarker('heritage', [kind, c.text, className]);
|
|
443
|
+
out.push({ '@import.heritage': syntheticCapture('@import.heritage', c, payload) });
|
|
444
|
+
}
|
|
445
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumerate the names a Dart `import '...'` brings into scope — every PUBLIC
|
|
3
|
+
* top-level symbol of the target library. Dart imports are whole-library
|
|
4
|
+
* (wildcard) and library-private (leading-underscore) members are not
|
|
5
|
+
* exported, so they are filtered out. Mirror of Ruby's
|
|
6
|
+
* `expandRubyWildcardNames`.
|
|
7
|
+
*
|
|
8
|
+
* Without this hook the shared `propagateImportedReturnTypes` pass has no
|
|
9
|
+
* importer-scope binding to hang an imported function's return type on, so a
|
|
10
|
+
* cross-file `var u = getUser(); u.save()` never resolves `u`'s type.
|
|
11
|
+
*/
|
|
12
|
+
import type { ParsedFile, ScopeId } from '../../../../_shared/index.js';
|
|
13
|
+
export declare function expandDartWildcardNames(targetModuleScope: ScopeId, parsedFiles: readonly ParsedFile[]): readonly string[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumerate the names a Dart `import '...'` brings into scope — every PUBLIC
|
|
3
|
+
* top-level symbol of the target library. Dart imports are whole-library
|
|
4
|
+
* (wildcard) and library-private (leading-underscore) members are not
|
|
5
|
+
* exported, so they are filtered out. Mirror of Ruby's
|
|
6
|
+
* `expandRubyWildcardNames`.
|
|
7
|
+
*
|
|
8
|
+
* Without this hook the shared `propagateImportedReturnTypes` pass has no
|
|
9
|
+
* importer-scope binding to hang an imported function's return type on, so a
|
|
10
|
+
* cross-file `var u = getUser(); u.save()` never resolves `u`'s type.
|
|
11
|
+
*/
|
|
12
|
+
export function expandDartWildcardNames(targetModuleScope, parsedFiles) {
|
|
13
|
+
const target = parsedFiles.find((p) => p.moduleScope === targetModuleScope);
|
|
14
|
+
if (target === undefined)
|
|
15
|
+
return [];
|
|
16
|
+
const seen = new Set();
|
|
17
|
+
const names = [];
|
|
18
|
+
for (const def of target.localDefs) {
|
|
19
|
+
const qn = def.qualifiedName;
|
|
20
|
+
if (qn === undefined || qn.length === 0)
|
|
21
|
+
continue;
|
|
22
|
+
const name = qn.split('.').pop() ?? qn;
|
|
23
|
+
if (name === '' || name.startsWith('_'))
|
|
24
|
+
continue; // library-private
|
|
25
|
+
if (seen.has(name))
|
|
26
|
+
continue;
|
|
27
|
+
seen.add(name);
|
|
28
|
+
names.push(name);
|
|
29
|
+
}
|
|
30
|
+
return names;
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `resolveImportTarget` adapter for the Dart `ScopeResolver`. Ports the
|
|
3
|
+
* legacy-DAG Dart import logic (`import-resolvers/configs/dart.ts`):
|
|
4
|
+
*
|
|
5
|
+
* - `dart:` SDK imports → `null` (external, no edge)
|
|
6
|
+
* - `package:pkg/path` → `lib/path` (or bare `path`) matched
|
|
7
|
+
* against the workspace file set
|
|
8
|
+
* - relative `'foo/bar.dart'` → resolved against the importer's dir
|
|
9
|
+
* - `__heritage__:` markers → `null` (synthetic heritage carrier,
|
|
10
|
+
* consumed by `emitDartHeritageEdges`)
|
|
11
|
+
*
|
|
12
|
+
* The `ScopeResolver` hook signature is `(targetRaw, fromFile, allFilePaths)`;
|
|
13
|
+
* `targetRaw` arrives already quote-stripped from `interpretDartImport`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveDartImportTarget(targetRaw: string, fromFile: string, allFilePaths: ReadonlySet<string>): string | readonly string[] | null;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `resolveImportTarget` adapter for the Dart `ScopeResolver`. Ports the
|
|
3
|
+
* legacy-DAG Dart import logic (`import-resolvers/configs/dart.ts`):
|
|
4
|
+
*
|
|
5
|
+
* - `dart:` SDK imports → `null` (external, no edge)
|
|
6
|
+
* - `package:pkg/path` → `lib/path` (or bare `path`) matched
|
|
7
|
+
* against the workspace file set
|
|
8
|
+
* - relative `'foo/bar.dart'` → resolved against the importer's dir
|
|
9
|
+
* - `__heritage__:` markers → `null` (synthetic heritage carrier,
|
|
10
|
+
* consumed by `emitDartHeritageEdges`)
|
|
11
|
+
*
|
|
12
|
+
* The `ScopeResolver` hook signature is `(targetRaw, fromFile, allFilePaths)`;
|
|
13
|
+
* `targetRaw` arrives already quote-stripped from `interpretDartImport`.
|
|
14
|
+
*/
|
|
15
|
+
import { DART_HERITAGE_PREFIX } from './interpret.js';
|
|
16
|
+
/** Resolve a relative path against the importer's directory, normalizing
|
|
17
|
+
* `.`/`..` segments, then confirm it exists in the workspace file set. */
|
|
18
|
+
function resolveRelative(rel, fromFile, allFilePaths) {
|
|
19
|
+
const normFrom = fromFile.replace(/\\/g, '/');
|
|
20
|
+
const fromDir = normFrom.includes('/') ? normFrom.slice(0, normFrom.lastIndexOf('/')) : '';
|
|
21
|
+
const parts = fromDir.length > 0 ? fromDir.split('/') : [];
|
|
22
|
+
for (const seg of rel.replace(/\\/g, '/').split('/')) {
|
|
23
|
+
if (seg === '' || seg === '.')
|
|
24
|
+
continue;
|
|
25
|
+
if (seg === '..')
|
|
26
|
+
parts.pop();
|
|
27
|
+
else
|
|
28
|
+
parts.push(seg);
|
|
29
|
+
}
|
|
30
|
+
const target = parts.join('/');
|
|
31
|
+
if (allFilePaths.has(target))
|
|
32
|
+
return target;
|
|
33
|
+
// Suffix fallback for absolute/rooted workspace paths.
|
|
34
|
+
for (const fp of allFilePaths) {
|
|
35
|
+
if (fp === target || fp.endsWith('/' + target))
|
|
36
|
+
return fp;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
export function resolveDartImportTarget(targetRaw, fromFile, allFilePaths) {
|
|
41
|
+
if (targetRaw.startsWith(DART_HERITAGE_PREFIX))
|
|
42
|
+
return null;
|
|
43
|
+
// `targetRaw` already arrives quote-stripped from `interpretDartImport`.
|
|
44
|
+
if (targetRaw === '')
|
|
45
|
+
return null;
|
|
46
|
+
// Dart SDK imports never resolve to a repo file.
|
|
47
|
+
if (targetRaw.startsWith('dart:'))
|
|
48
|
+
return null;
|
|
49
|
+
// `package:pkg/path.dart` → `lib/path.dart` (or bare `path.dart`).
|
|
50
|
+
if (targetRaw.startsWith('package:')) {
|
|
51
|
+
const slash = targetRaw.indexOf('/');
|
|
52
|
+
if (slash === -1)
|
|
53
|
+
return null;
|
|
54
|
+
const relPath = targetRaw.slice(slash + 1);
|
|
55
|
+
for (const candidate of [`lib/${relPath}`, relPath]) {
|
|
56
|
+
for (const fp of allFilePaths) {
|
|
57
|
+
if (fp === candidate || fp.endsWith('/' + candidate))
|
|
58
|
+
return fp;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null; // external package
|
|
62
|
+
}
|
|
63
|
+
// Relative import.
|
|
64
|
+
return resolveRelative(targetRaw, fromFile, allFilePaths);
|
|
65
|
+
}
|