cotx-engine 0.1.0
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/LICENSE +94 -0
- package/README.md +103 -0
- package/dist/commands/compile.d.ts +3 -0
- package/dist/commands/compile.js +93 -0
- package/dist/commands/compile.js.map +1 -0
- package/dist/commands/context.d.ts +1 -0
- package/dist/commands/context.js +98 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/diff.d.ts +19 -0
- package/dist/commands/diff.js +127 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/impact.d.ts +3 -0
- package/dist/commands/impact.js +91 -0
- package/dist/commands/impact.js.map +1 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +13 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/lint.d.ts +13 -0
- package/dist/commands/lint.js +290 -0
- package/dist/commands/lint.js.map +1 -0
- package/dist/commands/map.d.ts +6 -0
- package/dist/commands/map.js +409 -0
- package/dist/commands/map.js.map +1 -0
- package/dist/commands/migrate.d.ts +16 -0
- package/dist/commands/migrate.js +150 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/query.d.ts +3 -0
- package/dist/commands/query.js +47 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/rename.d.ts +5 -0
- package/dist/commands/rename.js +163 -0
- package/dist/commands/rename.js.map +1 -0
- package/dist/commands/snapshot.d.ts +6 -0
- package/dist/commands/snapshot.js +48 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +72 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/update.d.ts +8 -0
- package/dist/commands/update.js +163 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/write.d.ts +6 -0
- package/dist/commands/write.js +221 -0
- package/dist/commands/write.js.map +1 -0
- package/dist/compiler/auto-describe.d.ts +13 -0
- package/dist/compiler/auto-describe.js +91 -0
- package/dist/compiler/auto-describe.js.map +1 -0
- package/dist/compiler/concept-compiler.d.ts +21 -0
- package/dist/compiler/concept-compiler.js +125 -0
- package/dist/compiler/concept-compiler.js.map +1 -0
- package/dist/compiler/contract-compiler.d.ts +16 -0
- package/dist/compiler/contract-compiler.js +90 -0
- package/dist/compiler/contract-compiler.js.map +1 -0
- package/dist/compiler/delta-detector.d.ts +8 -0
- package/dist/compiler/delta-detector.js +34 -0
- package/dist/compiler/delta-detector.js.map +1 -0
- package/dist/compiler/flow-compiler.d.ts +18 -0
- package/dist/compiler/flow-compiler.js +69 -0
- package/dist/compiler/flow-compiler.js.map +1 -0
- package/dist/compiler/module-compiler.d.ts +18 -0
- package/dist/compiler/module-compiler.js +420 -0
- package/dist/compiler/module-compiler.js.map +1 -0
- package/dist/compiler/stale-detector.d.ts +22 -0
- package/dist/compiler/stale-detector.js +79 -0
- package/dist/compiler/stale-detector.js.map +1 -0
- package/dist/config/ignore-service.d.ts +26 -0
- package/dist/config/ignore-service.js +366 -0
- package/dist/config/ignore-service.js.map +1 -0
- package/dist/core/analysis/cluster-enricher.d.ts +38 -0
- package/dist/core/analysis/cluster-enricher.js +169 -0
- package/dist/core/analysis/cluster-enricher.js.map +1 -0
- package/dist/core/analysis/community-processor.d.ts +39 -0
- package/dist/core/analysis/community-processor.js +319 -0
- package/dist/core/analysis/community-processor.js.map +1 -0
- package/dist/core/analysis/process-processor.d.ts +51 -0
- package/dist/core/analysis/process-processor.js +318 -0
- package/dist/core/analysis/process-processor.js.map +1 -0
- package/dist/core/bridge.d.ts +15 -0
- package/dist/core/bridge.js +63 -0
- package/dist/core/bridge.js.map +1 -0
- package/dist/core/export/json-exporter.d.ts +43 -0
- package/dist/core/export/json-exporter.js +13 -0
- package/dist/core/export/json-exporter.js.map +1 -0
- package/dist/core/graph/graph.d.ts +2 -0
- package/dist/core/graph/graph.js +79 -0
- package/dist/core/graph/graph.js.map +1 -0
- package/dist/core/graph/types.d.ts +25 -0
- package/dist/core/graph/types.js +2 -0
- package/dist/core/graph/types.js.map +1 -0
- package/dist/core/parser/ast-cache.d.ts +11 -0
- package/dist/core/parser/ast-cache.js +36 -0
- package/dist/core/parser/ast-cache.js.map +1 -0
- package/dist/core/parser/call-processor.d.ts +105 -0
- package/dist/core/parser/call-processor.js +1807 -0
- package/dist/core/parser/call-processor.js.map +1 -0
- package/dist/core/parser/call-routing.d.ts +55 -0
- package/dist/core/parser/call-routing.js +113 -0
- package/dist/core/parser/call-routing.js.map +1 -0
- package/dist/core/parser/call-sites/extract-language-call-site.d.ts +10 -0
- package/dist/core/parser/call-sites/extract-language-call-site.js +23 -0
- package/dist/core/parser/call-sites/extract-language-call-site.js.map +1 -0
- package/dist/core/parser/call-sites/java.d.ts +9 -0
- package/dist/core/parser/call-sites/java.js +31 -0
- package/dist/core/parser/call-sites/java.js.map +1 -0
- package/dist/core/parser/cluster-enricher.d.ts +38 -0
- package/dist/core/parser/cluster-enricher.js +169 -0
- package/dist/core/parser/cluster-enricher.js.map +1 -0
- package/dist/core/parser/community-processor.d.ts +39 -0
- package/dist/core/parser/community-processor.js +321 -0
- package/dist/core/parser/community-processor.js.map +1 -0
- package/dist/core/parser/constants.d.ts +16 -0
- package/dist/core/parser/constants.js +17 -0
- package/dist/core/parser/constants.js.map +1 -0
- package/dist/core/parser/entry-point-scoring.d.ts +57 -0
- package/dist/core/parser/entry-point-scoring.js +377 -0
- package/dist/core/parser/entry-point-scoring.js.map +1 -0
- package/dist/core/parser/export-detection.d.ts +57 -0
- package/dist/core/parser/export-detection.js +234 -0
- package/dist/core/parser/export-detection.js.map +1 -0
- package/dist/core/parser/field-extractor.d.ts +34 -0
- package/dist/core/parser/field-extractor.js +33 -0
- package/dist/core/parser/field-extractor.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/c-cpp.d.ts +16 -0
- package/dist/core/parser/field-extractors/configs/c-cpp.js +129 -0
- package/dist/core/parser/field-extractors/configs/c-cpp.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/csharp.d.ts +15 -0
- package/dist/core/parser/field-extractors/configs/csharp.js +129 -0
- package/dist/core/parser/field-extractors/configs/csharp.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/dart.d.ts +12 -0
- package/dist/core/parser/field-extractors/configs/dart.js +93 -0
- package/dist/core/parser/field-extractors/configs/dart.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/go.d.ts +12 -0
- package/dist/core/parser/field-extractors/configs/go.js +66 -0
- package/dist/core/parser/field-extractors/configs/go.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/helpers.d.ts +40 -0
- package/dist/core/parser/field-extractors/configs/helpers.js +118 -0
- package/dist/core/parser/field-extractors/configs/helpers.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/jvm.d.ts +17 -0
- package/dist/core/parser/field-extractors/configs/jvm.js +139 -0
- package/dist/core/parser/field-extractors/configs/jvm.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/php.d.ts +12 -0
- package/dist/core/parser/field-extractors/configs/php.js +69 -0
- package/dist/core/parser/field-extractors/configs/php.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/python.d.ts +15 -0
- package/dist/core/parser/field-extractors/configs/python.js +92 -0
- package/dist/core/parser/field-extractors/configs/python.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/ruby.d.ts +15 -0
- package/dist/core/parser/field-extractors/configs/ruby.js +68 -0
- package/dist/core/parser/field-extractors/configs/ruby.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/rust.d.ts +12 -0
- package/dist/core/parser/field-extractors/configs/rust.js +58 -0
- package/dist/core/parser/field-extractors/configs/rust.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/swift.d.ts +15 -0
- package/dist/core/parser/field-extractors/configs/swift.js +75 -0
- package/dist/core/parser/field-extractors/configs/swift.js.map +1 -0
- package/dist/core/parser/field-extractors/configs/typescript-javascript.d.ts +14 -0
- package/dist/core/parser/field-extractors/configs/typescript-javascript.js +72 -0
- package/dist/core/parser/field-extractors/configs/typescript-javascript.js.map +1 -0
- package/dist/core/parser/field-extractors/generic.d.ts +61 -0
- package/dist/core/parser/field-extractors/generic.js +170 -0
- package/dist/core/parser/field-extractors/generic.js.map +1 -0
- package/dist/core/parser/field-extractors/typescript.d.ts +16 -0
- package/dist/core/parser/field-extractors/typescript.js +167 -0
- package/dist/core/parser/field-extractors/typescript.js.map +1 -0
- package/dist/core/parser/field-types.d.ts +46 -0
- package/dist/core/parser/field-types.js +2 -0
- package/dist/core/parser/field-types.js.map +1 -0
- package/dist/core/parser/filesystem-walker.d.ts +28 -0
- package/dist/core/parser/filesystem-walker.js +82 -0
- package/dist/core/parser/filesystem-walker.js.map +1 -0
- package/dist/core/parser/framework-detection.d.ts +149 -0
- package/dist/core/parser/framework-detection.js +782 -0
- package/dist/core/parser/framework-detection.js.map +1 -0
- package/dist/core/parser/heritage-processor.d.ts +52 -0
- package/dist/core/parser/heritage-processor.js +339 -0
- package/dist/core/parser/heritage-processor.js.map +1 -0
- package/dist/core/parser/import-processor.d.ts +33 -0
- package/dist/core/parser/import-processor.js +382 -0
- package/dist/core/parser/import-processor.js.map +1 -0
- package/dist/core/parser/import-resolvers/csharp.d.ts +19 -0
- package/dist/core/parser/import-resolvers/csharp.js +132 -0
- package/dist/core/parser/import-resolvers/csharp.js.map +1 -0
- package/dist/core/parser/import-resolvers/dart.d.ts +7 -0
- package/dist/core/parser/import-resolvers/dart.js +45 -0
- package/dist/core/parser/import-resolvers/dart.js.map +1 -0
- package/dist/core/parser/import-resolvers/go.d.ts +18 -0
- package/dist/core/parser/import-resolvers/go.js +62 -0
- package/dist/core/parser/import-resolvers/go.js.map +1 -0
- package/dist/core/parser/import-resolvers/jvm.d.ts +32 -0
- package/dist/core/parser/import-resolvers/jvm.js +160 -0
- package/dist/core/parser/import-resolvers/jvm.js.map +1 -0
- package/dist/core/parser/import-resolvers/php.d.ts +25 -0
- package/dist/core/parser/import-resolvers/php.js +81 -0
- package/dist/core/parser/import-resolvers/php.js.map +1 -0
- package/dist/core/parser/import-resolvers/python.d.ts +25 -0
- package/dist/core/parser/import-resolvers/python.js +85 -0
- package/dist/core/parser/import-resolvers/python.js.map +1 -0
- package/dist/core/parser/import-resolvers/ruby.d.ts +15 -0
- package/dist/core/parser/import-resolvers/ruby.js +21 -0
- package/dist/core/parser/import-resolvers/ruby.js.map +1 -0
- package/dist/core/parser/import-resolvers/rust.d.ts +18 -0
- package/dist/core/parser/import-resolvers/rust.js +119 -0
- package/dist/core/parser/import-resolvers/rust.js.map +1 -0
- package/dist/core/parser/import-resolvers/standard.d.ts +36 -0
- package/dist/core/parser/import-resolvers/standard.js +144 -0
- package/dist/core/parser/import-resolvers/standard.js.map +1 -0
- package/dist/core/parser/import-resolvers/swift.d.ts +7 -0
- package/dist/core/parser/import-resolvers/swift.js +25 -0
- package/dist/core/parser/import-resolvers/swift.js.map +1 -0
- package/dist/core/parser/import-resolvers/types.d.ts +44 -0
- package/dist/core/parser/import-resolvers/types.js +7 -0
- package/dist/core/parser/import-resolvers/types.js.map +1 -0
- package/dist/core/parser/import-resolvers/utils.d.ts +35 -0
- package/dist/core/parser/import-resolvers/utils.js +150 -0
- package/dist/core/parser/import-resolvers/utils.js.map +1 -0
- package/dist/core/parser/import-resolvers/vue.d.ts +8 -0
- package/dist/core/parser/import-resolvers/vue.js +10 -0
- package/dist/core/parser/import-resolvers/vue.js.map +1 -0
- package/dist/core/parser/language-config.d.ts +52 -0
- package/dist/core/parser/language-config.js +182 -0
- package/dist/core/parser/language-config.js.map +1 -0
- package/dist/core/parser/language-provider.d.ts +126 -0
- package/dist/core/parser/language-provider.js +25 -0
- package/dist/core/parser/language-provider.js.map +1 -0
- package/dist/core/parser/languages/c-cpp.d.ts +12 -0
- package/dist/core/parser/languages/c-cpp.js +312 -0
- package/dist/core/parser/languages/c-cpp.js.map +1 -0
- package/dist/core/parser/languages/csharp.d.ts +8 -0
- package/dist/core/parser/languages/csharp.js +127 -0
- package/dist/core/parser/languages/csharp.js.map +1 -0
- package/dist/core/parser/languages/dart.d.ts +12 -0
- package/dist/core/parser/languages/dart.js +91 -0
- package/dist/core/parser/languages/dart.js.map +1 -0
- package/dist/core/parser/languages/go.d.ts +11 -0
- package/dist/core/parser/languages/go.js +32 -0
- package/dist/core/parser/languages/go.js.map +1 -0
- package/dist/core/parser/languages/index.d.ts +38 -0
- package/dist/core/parser/languages/index.js +63 -0
- package/dist/core/parser/languages/index.js.map +1 -0
- package/dist/core/parser/languages/java.d.ts +9 -0
- package/dist/core/parser/languages/java.js +33 -0
- package/dist/core/parser/languages/java.js.map +1 -0
- package/dist/core/parser/languages/kotlin.d.ts +9 -0
- package/dist/core/parser/languages/kotlin.js +112 -0
- package/dist/core/parser/languages/kotlin.js.map +1 -0
- package/dist/core/parser/languages/php.d.ts +8 -0
- package/dist/core/parser/languages/php.js +226 -0
- package/dist/core/parser/languages/php.js.map +1 -0
- package/dist/core/parser/languages/python.d.ts +12 -0
- package/dist/core/parser/languages/python.js +66 -0
- package/dist/core/parser/languages/python.js.map +1 -0
- package/dist/core/parser/languages/ruby.d.ts +9 -0
- package/dist/core/parser/languages/ruby.js +109 -0
- package/dist/core/parser/languages/ruby.js.map +1 -0
- package/dist/core/parser/languages/rust.d.ts +12 -0
- package/dist/core/parser/languages/rust.js +121 -0
- package/dist/core/parser/languages/rust.js.map +1 -0
- package/dist/core/parser/languages/swift.d.ts +12 -0
- package/dist/core/parser/languages/swift.js +233 -0
- package/dist/core/parser/languages/swift.js.map +1 -0
- package/dist/core/parser/languages/typescript.d.ts +11 -0
- package/dist/core/parser/languages/typescript.js +169 -0
- package/dist/core/parser/languages/typescript.js.map +1 -0
- package/dist/core/parser/languages/vue.d.ts +13 -0
- package/dist/core/parser/languages/vue.js +65 -0
- package/dist/core/parser/languages/vue.js.map +1 -0
- package/dist/core/parser/markdown-processor.d.ts +17 -0
- package/dist/core/parser/markdown-processor.js +125 -0
- package/dist/core/parser/markdown-processor.js.map +1 -0
- package/dist/core/parser/method-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/parser/method-extractors/configs/c-cpp.js +276 -0
- package/dist/core/parser/method-extractors/configs/c-cpp.js.map +1 -0
- package/dist/core/parser/method-extractors/configs/csharp.d.ts +2 -0
- package/dist/core/parser/method-extractors/configs/csharp.js +243 -0
- package/dist/core/parser/method-extractors/configs/csharp.js.map +1 -0
- package/dist/core/parser/method-extractors/configs/dart.d.ts +2 -0
- package/dist/core/parser/method-extractors/configs/dart.js +263 -0
- package/dist/core/parser/method-extractors/configs/dart.js.map +1 -0
- package/dist/core/parser/method-extractors/configs/go.d.ts +2 -0
- package/dist/core/parser/method-extractors/configs/go.js +120 -0
- package/dist/core/parser/method-extractors/configs/go.js.map +1 -0
- package/dist/core/parser/method-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/parser/method-extractors/configs/jvm.js +309 -0
- package/dist/core/parser/method-extractors/configs/jvm.js.map +1 -0
- package/dist/core/parser/method-extractors/configs/php.d.ts +2 -0
- package/dist/core/parser/method-extractors/configs/php.js +243 -0
- package/dist/core/parser/method-extractors/configs/php.js.map +1 -0
- package/dist/core/parser/method-extractors/configs/python.d.ts +2 -0
- package/dist/core/parser/method-extractors/configs/python.js +219 -0
- package/dist/core/parser/method-extractors/configs/python.js.map +1 -0
- package/dist/core/parser/method-extractors/configs/ruby.d.ts +2 -0
- package/dist/core/parser/method-extractors/configs/ruby.js +201 -0
- package/dist/core/parser/method-extractors/configs/ruby.js.map +1 -0
- package/dist/core/parser/method-extractors/configs/rust.d.ts +2 -0
- package/dist/core/parser/method-extractors/configs/rust.js +120 -0
- package/dist/core/parser/method-extractors/configs/rust.js.map +1 -0
- package/dist/core/parser/method-extractors/configs/swift.d.ts +2 -0
- package/dist/core/parser/method-extractors/configs/swift.js +191 -0
- package/dist/core/parser/method-extractors/configs/swift.js.map +1 -0
- package/dist/core/parser/method-extractors/configs/typescript-javascript.d.ts +3 -0
- package/dist/core/parser/method-extractors/configs/typescript-javascript.js +231 -0
- package/dist/core/parser/method-extractors/configs/typescript-javascript.js.map +1 -0
- package/dist/core/parser/method-extractors/generic.d.ts +11 -0
- package/dist/core/parser/method-extractors/generic.js +162 -0
- package/dist/core/parser/method-extractors/generic.js.map +1 -0
- package/dist/core/parser/method-types.d.ts +110 -0
- package/dist/core/parser/method-types.js +2 -0
- package/dist/core/parser/method-types.js.map +1 -0
- package/dist/core/parser/mro-processor.d.ts +46 -0
- package/dist/core/parser/mro-processor.js +677 -0
- package/dist/core/parser/mro-processor.js.map +1 -0
- package/dist/core/parser/named-binding-processor.d.ts +18 -0
- package/dist/core/parser/named-binding-processor.js +43 -0
- package/dist/core/parser/named-binding-processor.js.map +1 -0
- package/dist/core/parser/named-bindings/csharp.d.ts +3 -0
- package/dist/core/parser/named-bindings/csharp.js +38 -0
- package/dist/core/parser/named-bindings/csharp.js.map +1 -0
- package/dist/core/parser/named-bindings/java.d.ts +3 -0
- package/dist/core/parser/named-bindings/java.js +30 -0
- package/dist/core/parser/named-bindings/java.js.map +1 -0
- package/dist/core/parser/named-bindings/kotlin.d.ts +3 -0
- package/dist/core/parser/named-bindings/kotlin.js +37 -0
- package/dist/core/parser/named-bindings/kotlin.js.map +1 -0
- package/dist/core/parser/named-bindings/php.d.ts +3 -0
- package/dist/core/parser/named-bindings/php.js +62 -0
- package/dist/core/parser/named-bindings/php.js.map +1 -0
- package/dist/core/parser/named-bindings/python.d.ts +3 -0
- package/dist/core/parser/named-bindings/python.js +50 -0
- package/dist/core/parser/named-bindings/python.js.map +1 -0
- package/dist/core/parser/named-bindings/rust.d.ts +3 -0
- package/dist/core/parser/named-bindings/rust.js +67 -0
- package/dist/core/parser/named-bindings/rust.js.map +1 -0
- package/dist/core/parser/named-bindings/types.d.ts +16 -0
- package/dist/core/parser/named-bindings/types.js +7 -0
- package/dist/core/parser/named-bindings/types.js.map +1 -0
- package/dist/core/parser/named-bindings/typescript.d.ts +3 -0
- package/dist/core/parser/named-bindings/typescript.js +59 -0
- package/dist/core/parser/named-bindings/typescript.js.map +1 -0
- package/dist/core/parser/parsing-processor.d.ts +23 -0
- package/dist/core/parser/parsing-processor.js +464 -0
- package/dist/core/parser/parsing-processor.js.map +1 -0
- package/dist/core/parser/pipeline.d.ts +17 -0
- package/dist/core/parser/pipeline.js +1405 -0
- package/dist/core/parser/pipeline.js.map +1 -0
- package/dist/core/parser/process-processor.d.ts +51 -0
- package/dist/core/parser/process-processor.js +318 -0
- package/dist/core/parser/process-processor.js.map +1 -0
- package/dist/core/parser/resolution-context.d.ts +58 -0
- package/dist/core/parser/resolution-context.js +136 -0
- package/dist/core/parser/resolution-context.js.map +1 -0
- package/dist/core/parser/route-extractors/expo.d.ts +1 -0
- package/dist/core/parser/route-extractors/expo.js +37 -0
- package/dist/core/parser/route-extractors/expo.js.map +1 -0
- package/dist/core/parser/route-extractors/middleware.d.ts +47 -0
- package/dist/core/parser/route-extractors/middleware.js +168 -0
- package/dist/core/parser/route-extractors/middleware.js.map +1 -0
- package/dist/core/parser/route-extractors/nextjs.d.ts +3 -0
- package/dist/core/parser/route-extractors/nextjs.js +77 -0
- package/dist/core/parser/route-extractors/nextjs.js.map +1 -0
- package/dist/core/parser/route-extractors/php.d.ts +7 -0
- package/dist/core/parser/route-extractors/php.js +23 -0
- package/dist/core/parser/route-extractors/php.js.map +1 -0
- package/dist/core/parser/route-extractors/response-shapes.d.ts +20 -0
- package/dist/core/parser/route-extractors/response-shapes.js +295 -0
- package/dist/core/parser/route-extractors/response-shapes.js.map +1 -0
- package/dist/core/parser/structure-processor.d.ts +2 -0
- package/dist/core/parser/structure-processor.js +37 -0
- package/dist/core/parser/structure-processor.js.map +1 -0
- package/dist/core/parser/symbol-table.d.ts +79 -0
- package/dist/core/parser/symbol-table.js +116 -0
- package/dist/core/parser/symbol-table.js.map +1 -0
- package/dist/core/parser/tree-sitter-queries.d.ts +16 -0
- package/dist/core/parser/tree-sitter-queries.js +1180 -0
- package/dist/core/parser/tree-sitter-queries.js.map +1 -0
- package/dist/core/parser/type-env.d.ts +81 -0
- package/dist/core/parser/type-env.js +1048 -0
- package/dist/core/parser/type-env.js.map +1 -0
- package/dist/core/parser/type-extractors/c-cpp.d.ts +7 -0
- package/dist/core/parser/type-extractors/c-cpp.js +533 -0
- package/dist/core/parser/type-extractors/c-cpp.js.map +1 -0
- package/dist/core/parser/type-extractors/csharp.d.ts +2 -0
- package/dist/core/parser/type-extractors/csharp.js +584 -0
- package/dist/core/parser/type-extractors/csharp.js.map +1 -0
- package/dist/core/parser/type-extractors/dart.d.ts +15 -0
- package/dist/core/parser/type-extractors/dart.js +370 -0
- package/dist/core/parser/type-extractors/dart.js.map +1 -0
- package/dist/core/parser/type-extractors/go.d.ts +2 -0
- package/dist/core/parser/type-extractors/go.js +514 -0
- package/dist/core/parser/type-extractors/go.js.map +1 -0
- package/dist/core/parser/type-extractors/jvm.d.ts +3 -0
- package/dist/core/parser/type-extractors/jvm.js +857 -0
- package/dist/core/parser/type-extractors/jvm.js.map +1 -0
- package/dist/core/parser/type-extractors/php.d.ts +2 -0
- package/dist/core/parser/type-extractors/php.js +535 -0
- package/dist/core/parser/type-extractors/php.js.map +1 -0
- package/dist/core/parser/type-extractors/python.d.ts +2 -0
- package/dist/core/parser/type-extractors/python.js +475 -0
- package/dist/core/parser/type-extractors/python.js.map +1 -0
- package/dist/core/parser/type-extractors/ruby.d.ts +2 -0
- package/dist/core/parser/type-extractors/ruby.js +378 -0
- package/dist/core/parser/type-extractors/ruby.js.map +1 -0
- package/dist/core/parser/type-extractors/rust.d.ts +2 -0
- package/dist/core/parser/type-extractors/rust.js +516 -0
- package/dist/core/parser/type-extractors/rust.js.map +1 -0
- package/dist/core/parser/type-extractors/shared.d.ts +131 -0
- package/dist/core/parser/type-extractors/shared.js +797 -0
- package/dist/core/parser/type-extractors/shared.js.map +1 -0
- package/dist/core/parser/type-extractors/swift.d.ts +2 -0
- package/dist/core/parser/type-extractors/swift.js +485 -0
- package/dist/core/parser/type-extractors/swift.js.map +1 -0
- package/dist/core/parser/type-extractors/types.d.ts +172 -0
- package/dist/core/parser/type-extractors/types.js +2 -0
- package/dist/core/parser/type-extractors/types.js.map +1 -0
- package/dist/core/parser/type-extractors/typescript.d.ts +2 -0
- package/dist/core/parser/type-extractors/typescript.js +662 -0
- package/dist/core/parser/type-extractors/typescript.js.map +1 -0
- package/dist/core/parser/utils/ast-helpers.d.ts +73 -0
- package/dist/core/parser/utils/ast-helpers.js +415 -0
- package/dist/core/parser/utils/ast-helpers.js.map +1 -0
- package/dist/core/parser/utils/call-analysis.d.ts +75 -0
- package/dist/core/parser/utils/call-analysis.js +575 -0
- package/dist/core/parser/utils/call-analysis.js.map +1 -0
- package/dist/core/parser/utils/event-loop.d.ts +5 -0
- package/dist/core/parser/utils/event-loop.js +6 -0
- package/dist/core/parser/utils/event-loop.js.map +1 -0
- package/dist/core/parser/utils/method-props.d.ts +8 -0
- package/dist/core/parser/utils/method-props.js +39 -0
- package/dist/core/parser/utils/method-props.js.map +1 -0
- package/dist/core/parser/utils/verbose.d.ts +1 -0
- package/dist/core/parser/utils/verbose.js +8 -0
- package/dist/core/parser/utils/verbose.js.map +1 -0
- package/dist/core/parser/vue-sfc-extractor.d.ts +44 -0
- package/dist/core/parser/vue-sfc-extractor.js +95 -0
- package/dist/core/parser/vue-sfc-extractor.js.map +1 -0
- package/dist/core/parser/workers/parse-worker.d.ts +171 -0
- package/dist/core/parser/workers/parse-worker.js +1724 -0
- package/dist/core/parser/workers/parse-worker.js.map +1 -0
- package/dist/core/parser/workers/worker-pool.d.ts +16 -0
- package/dist/core/parser/workers/worker-pool.js +124 -0
- package/dist/core/parser/workers/worker-pool.js.map +1 -0
- package/dist/core/shared/graph-types.d.ts +61 -0
- package/dist/core/shared/graph-types.js +5 -0
- package/dist/core/shared/graph-types.js.map +1 -0
- package/dist/core/shared/index.d.ts +4 -0
- package/dist/core/shared/index.js +4 -0
- package/dist/core/shared/index.js.map +1 -0
- package/dist/core/shared/language-detection.d.ts +22 -0
- package/dist/core/shared/language-detection.js +137 -0
- package/dist/core/shared/language-detection.js.map +1 -0
- package/dist/core/shared/languages.d.ts +23 -0
- package/dist/core/shared/languages.js +25 -0
- package/dist/core/shared/languages.js.map +1 -0
- package/dist/core/shared/pipeline.d.ts +15 -0
- package/dist/core/shared/pipeline.js +5 -0
- package/dist/core/shared/pipeline.js.map +1 -0
- package/dist/core/tree-sitter/parser-loader.d.ts +5 -0
- package/dist/core/tree-sitter/parser-loader.js +71 -0
- package/dist/core/tree-sitter/parser-loader.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +132 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/hash.d.ts +1 -0
- package/dist/lib/hash.js +6 -0
- package/dist/lib/hash.js.map +1 -0
- package/dist/lib/naming.d.ts +12 -0
- package/dist/lib/naming.js +28 -0
- package/dist/lib/naming.js.map +1 -0
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +4 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/mcp/server.d.ts +26 -0
- package/dist/mcp/server.js +282 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +37 -0
- package/dist/mcp/tools.js +650 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/query/bm25.d.ts +19 -0
- package/dist/query/bm25.js +60 -0
- package/dist/query/bm25.js.map +1 -0
- package/dist/query/graph-index.d.ts +40 -0
- package/dist/query/graph-index.js +178 -0
- package/dist/query/graph-index.js.map +1 -0
- package/dist/store/derived-index.d.ts +4 -0
- package/dist/store/derived-index.js +68 -0
- package/dist/store/derived-index.js.map +1 -0
- package/dist/store/meta.d.ts +1 -0
- package/dist/store/meta.js +3 -0
- package/dist/store/meta.js.map +1 -0
- package/dist/store/schema.d.ts +135 -0
- package/dist/store/schema.js +2 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/store.d.ts +49 -0
- package/dist/store/store.js +254 -0
- package/dist/store/store.js.map +1 -0
- package/dist/types/pipeline.d.ts +12 -0
- package/dist/types/pipeline.js +2 -0
- package/dist/types/pipeline.js.map +1 -0
- package/package.json +69 -0
- package/skills/cotx-enrich/SKILL.md +59 -0
- package/vendor/leiden/index.cjs +355 -0
- package/vendor/leiden/utils.cjs +392 -0
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MRO (Method Resolution Order) Processor
|
|
3
|
+
*
|
|
4
|
+
* Walks the inheritance DAG (EXTENDS/IMPLEMENTS edges), collects methods from
|
|
5
|
+
* each ancestor via HAS_METHOD edges, detects method-name collisions across
|
|
6
|
+
* parents, and applies language-specific resolution rules to emit METHOD_OVERRIDES edges.
|
|
7
|
+
*
|
|
8
|
+
* Language-specific rules:
|
|
9
|
+
* - C++: leftmost base class in declaration order wins
|
|
10
|
+
* - C#/Java: class method wins over interface default; multiple interface
|
|
11
|
+
* methods with same name are ambiguous (null resolution)
|
|
12
|
+
* - Python: C3 linearization determines MRO; first in linearized order wins
|
|
13
|
+
* - Rust: no auto-resolution — requires qualified syntax, resolvedTo = null
|
|
14
|
+
* - Default: single inheritance — first definition wins
|
|
15
|
+
*
|
|
16
|
+
* METHOD_OVERRIDES edge direction: Class → Method (not Method → Method).
|
|
17
|
+
* The source is the child class that inherits conflicting methods,
|
|
18
|
+
* the target is the winning ancestor method node.
|
|
19
|
+
* Cypher: MATCH (c:Class)-[r:CodeRelation {type: 'METHOD_OVERRIDES'}]->(m:Method)
|
|
20
|
+
*/
|
|
21
|
+
import { generateId } from '../../lib/utils.js';
|
|
22
|
+
import { getProvider } from './languages/index.js';
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Internal helpers
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
/** Collect EXTENDS, IMPLEMENTS, and HAS_METHOD adjacency from the graph. */
|
|
27
|
+
function buildAdjacency(graph) {
|
|
28
|
+
// parentMap: childId → parentIds[] (in insertion / declaration order)
|
|
29
|
+
const parentMap = new Map();
|
|
30
|
+
// methodMap: classId → methodIds[]
|
|
31
|
+
const methodMap = new Map();
|
|
32
|
+
// Track which edge type each parent link came from
|
|
33
|
+
const parentEdgeType = new Map();
|
|
34
|
+
graph.forEachRelationship((rel) => {
|
|
35
|
+
if (rel.type === 'EXTENDS' || rel.type === 'IMPLEMENTS') {
|
|
36
|
+
let parents = parentMap.get(rel.sourceId);
|
|
37
|
+
if (!parents) {
|
|
38
|
+
parents = [];
|
|
39
|
+
parentMap.set(rel.sourceId, parents);
|
|
40
|
+
}
|
|
41
|
+
parents.push(rel.targetId);
|
|
42
|
+
let edgeTypes = parentEdgeType.get(rel.sourceId);
|
|
43
|
+
if (!edgeTypes) {
|
|
44
|
+
edgeTypes = new Map();
|
|
45
|
+
parentEdgeType.set(rel.sourceId, edgeTypes);
|
|
46
|
+
}
|
|
47
|
+
edgeTypes.set(rel.targetId, rel.type);
|
|
48
|
+
}
|
|
49
|
+
if (rel.type === 'HAS_METHOD') {
|
|
50
|
+
let methods = methodMap.get(rel.sourceId);
|
|
51
|
+
if (!methods) {
|
|
52
|
+
methods = [];
|
|
53
|
+
methodMap.set(rel.sourceId, methods);
|
|
54
|
+
}
|
|
55
|
+
methods.push(rel.targetId);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return { parentMap, methodMap, parentEdgeType };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gather all ancestor IDs in BFS / topological order.
|
|
62
|
+
* Returns the linearized list of ancestor IDs (excluding the class itself).
|
|
63
|
+
*/
|
|
64
|
+
function gatherAncestors(classId, parentMap) {
|
|
65
|
+
const visited = new Set();
|
|
66
|
+
const order = [];
|
|
67
|
+
const queue = [...(parentMap.get(classId) ?? [])];
|
|
68
|
+
while (queue.length > 0) {
|
|
69
|
+
const id = queue.shift();
|
|
70
|
+
if (visited.has(id))
|
|
71
|
+
continue;
|
|
72
|
+
visited.add(id);
|
|
73
|
+
order.push(id);
|
|
74
|
+
const grandparents = parentMap.get(id);
|
|
75
|
+
if (grandparents) {
|
|
76
|
+
for (const gp of grandparents) {
|
|
77
|
+
if (!visited.has(gp))
|
|
78
|
+
queue.push(gp);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return order;
|
|
83
|
+
}
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// C3 linearization (Python MRO)
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
/**
|
|
88
|
+
* Compute C3 linearization for a class given a parentMap.
|
|
89
|
+
* Returns an array of ancestor IDs in C3 order (excluding the class itself),
|
|
90
|
+
* or null if linearization fails (inconsistent or cyclic hierarchy).
|
|
91
|
+
*/
|
|
92
|
+
function c3Linearize(classId, parentMap, cache, inProgress) {
|
|
93
|
+
if (cache.has(classId))
|
|
94
|
+
return cache.get(classId);
|
|
95
|
+
// Cycle detection: if we're already computing this class, the hierarchy is cyclic
|
|
96
|
+
const visiting = inProgress ?? new Set();
|
|
97
|
+
if (visiting.has(classId)) {
|
|
98
|
+
cache.set(classId, null);
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
visiting.add(classId);
|
|
102
|
+
const directParents = parentMap.get(classId);
|
|
103
|
+
if (!directParents || directParents.length === 0) {
|
|
104
|
+
visiting.delete(classId);
|
|
105
|
+
cache.set(classId, []);
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
// Compute linearization for each parent first
|
|
109
|
+
const parentLinearizations = [];
|
|
110
|
+
for (const pid of directParents) {
|
|
111
|
+
const pLin = c3Linearize(pid, parentMap, cache, visiting);
|
|
112
|
+
if (pLin === null) {
|
|
113
|
+
visiting.delete(classId);
|
|
114
|
+
cache.set(classId, null);
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
parentLinearizations.push([pid, ...pLin]);
|
|
118
|
+
}
|
|
119
|
+
// Add the direct parents list as the final sequence
|
|
120
|
+
const sequences = [...parentLinearizations, [...directParents]];
|
|
121
|
+
const result = [];
|
|
122
|
+
while (sequences.some((s) => s.length > 0)) {
|
|
123
|
+
// Find a good head: one that doesn't appear in the tail of any other sequence
|
|
124
|
+
let head = null;
|
|
125
|
+
for (const seq of sequences) {
|
|
126
|
+
if (seq.length === 0)
|
|
127
|
+
continue;
|
|
128
|
+
const candidate = seq[0];
|
|
129
|
+
const inTail = sequences.some((other) => other.length > 1 && other.indexOf(candidate, 1) !== -1);
|
|
130
|
+
if (!inTail) {
|
|
131
|
+
head = candidate;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (head === null) {
|
|
136
|
+
// Inconsistent hierarchy
|
|
137
|
+
visiting.delete(classId);
|
|
138
|
+
cache.set(classId, null);
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
result.push(head);
|
|
142
|
+
// Remove the chosen head from all sequences
|
|
143
|
+
for (const seq of sequences) {
|
|
144
|
+
if (seq.length > 0 && seq[0] === head) {
|
|
145
|
+
seq.shift();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
visiting.delete(classId);
|
|
150
|
+
cache.set(classId, result);
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
/** Resolve by MRO order — first ancestor in linearized order wins. */
|
|
154
|
+
function resolveByMroOrder(methodName, defs, mroOrder, reasonPrefix) {
|
|
155
|
+
for (const ancestorId of mroOrder) {
|
|
156
|
+
const match = defs.find((d) => d.classId === ancestorId);
|
|
157
|
+
if (match) {
|
|
158
|
+
return {
|
|
159
|
+
resolvedTo: match.methodId,
|
|
160
|
+
reason: `${reasonPrefix}: ${match.className}::${methodName}`,
|
|
161
|
+
confidence: 0.9, // MRO-ordered resolution
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
resolvedTo: defs[0].methodId,
|
|
167
|
+
reason: `${reasonPrefix} fallback: first definition`,
|
|
168
|
+
confidence: 0.7,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function resolveCsharpJava(methodName, defs, parentEdgeTypes) {
|
|
172
|
+
const classDefs = [];
|
|
173
|
+
const interfaceDefs = [];
|
|
174
|
+
for (const def of defs) {
|
|
175
|
+
const edgeType = parentEdgeTypes?.get(def.classId);
|
|
176
|
+
if (edgeType === 'IMPLEMENTS') {
|
|
177
|
+
interfaceDefs.push(def);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
classDefs.push(def);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (classDefs.length > 0) {
|
|
184
|
+
return {
|
|
185
|
+
resolvedTo: classDefs[0].methodId,
|
|
186
|
+
reason: `class method wins: ${classDefs[0].className}::${methodName}`,
|
|
187
|
+
confidence: 0.95, // Class method is authoritative
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
if (interfaceDefs.length > 1) {
|
|
191
|
+
return {
|
|
192
|
+
resolvedTo: null,
|
|
193
|
+
reason: `ambiguous: ${methodName} defined in multiple interfaces: ${interfaceDefs.map((d) => d.className).join(', ')}`,
|
|
194
|
+
confidence: 0.5,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
if (interfaceDefs.length === 1) {
|
|
198
|
+
return {
|
|
199
|
+
resolvedTo: interfaceDefs[0].methodId,
|
|
200
|
+
reason: `single interface default: ${interfaceDefs[0].className}::${methodName}`,
|
|
201
|
+
confidence: 0.85, // Single interface, unambiguous
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return { resolvedTo: null, reason: 'no resolution found', confidence: 0.5 };
|
|
205
|
+
}
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
// Main entry point
|
|
208
|
+
// ---------------------------------------------------------------------------
|
|
209
|
+
export function computeMRO(graph) {
|
|
210
|
+
const { parentMap, methodMap, parentEdgeType } = buildAdjacency(graph);
|
|
211
|
+
const c3Cache = new Map();
|
|
212
|
+
const entries = [];
|
|
213
|
+
let overrideEdges = 0;
|
|
214
|
+
let ambiguityCount = 0;
|
|
215
|
+
// Pre-computed maps to avoid redundant BFS in emitMethodImplementsEdges
|
|
216
|
+
const ancestorsMap = new Map();
|
|
217
|
+
const edgeTypesMap = new Map();
|
|
218
|
+
// Process every class that has at least one parent
|
|
219
|
+
for (const [classId, directParents] of parentMap) {
|
|
220
|
+
if (directParents.length === 0)
|
|
221
|
+
continue;
|
|
222
|
+
const classNode = graph.getNode(classId);
|
|
223
|
+
if (!classNode)
|
|
224
|
+
continue;
|
|
225
|
+
const language = classNode.properties.language;
|
|
226
|
+
if (!language)
|
|
227
|
+
continue;
|
|
228
|
+
const className = classNode.properties.name;
|
|
229
|
+
// Compute linearized MRO depending on language strategy
|
|
230
|
+
const provider = getProvider(language);
|
|
231
|
+
const ancestors = gatherAncestors(classId, parentMap);
|
|
232
|
+
ancestorsMap.set(classId, ancestors);
|
|
233
|
+
edgeTypesMap.set(classId, buildTransitiveEdgeTypes(classId, parentMap, parentEdgeType));
|
|
234
|
+
let mroOrder;
|
|
235
|
+
if (provider.mroStrategy === 'c3') {
|
|
236
|
+
const c3Result = c3Linearize(classId, parentMap, c3Cache);
|
|
237
|
+
mroOrder = c3Result ?? ancestors;
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
mroOrder = ancestors;
|
|
241
|
+
}
|
|
242
|
+
// Get the parent names for the MRO entry
|
|
243
|
+
const mroNames = mroOrder
|
|
244
|
+
.map((id) => graph.getNode(id)?.properties.name)
|
|
245
|
+
.filter((n) => n !== undefined);
|
|
246
|
+
// Collect methods from all ancestors, grouped by method name
|
|
247
|
+
const methodsByName = new Map();
|
|
248
|
+
for (const ancestorId of mroOrder) {
|
|
249
|
+
const ancestorNode = graph.getNode(ancestorId);
|
|
250
|
+
if (!ancestorNode)
|
|
251
|
+
continue;
|
|
252
|
+
const methods = methodMap.get(ancestorId) ?? [];
|
|
253
|
+
for (const methodId of methods) {
|
|
254
|
+
const methodNode = graph.getNode(methodId);
|
|
255
|
+
if (!methodNode)
|
|
256
|
+
continue;
|
|
257
|
+
// Properties don't participate in method resolution order
|
|
258
|
+
if (methodNode.label === 'Property')
|
|
259
|
+
continue;
|
|
260
|
+
const methodName = methodNode.properties.name;
|
|
261
|
+
let defs = methodsByName.get(methodName);
|
|
262
|
+
if (!defs) {
|
|
263
|
+
defs = [];
|
|
264
|
+
methodsByName.set(methodName, defs);
|
|
265
|
+
}
|
|
266
|
+
// Avoid duplicates (same method seen via multiple paths)
|
|
267
|
+
if (!defs.some((d) => d.methodId === methodId)) {
|
|
268
|
+
defs.push({
|
|
269
|
+
classId: ancestorId,
|
|
270
|
+
className: ancestorNode.properties.name,
|
|
271
|
+
methodId,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// Detect collisions: methods defined in 2+ different ancestors
|
|
277
|
+
const ambiguities = [];
|
|
278
|
+
// Use pre-computed transitive edge types (only needed for implements-split languages)
|
|
279
|
+
const needsEdgeTypes = provider.mroStrategy === 'implements-split';
|
|
280
|
+
const classEdgeTypes = needsEdgeTypes ? edgeTypesMap.get(classId) : undefined;
|
|
281
|
+
for (const [methodName, defs] of methodsByName) {
|
|
282
|
+
if (defs.length < 2)
|
|
283
|
+
continue;
|
|
284
|
+
// Own method shadows inherited — no ambiguity
|
|
285
|
+
const ownMethods = methodMap.get(classId) ?? [];
|
|
286
|
+
const ownDefinesIt = ownMethods.some((mid) => {
|
|
287
|
+
const mn = graph.getNode(mid);
|
|
288
|
+
return mn?.properties.name === methodName;
|
|
289
|
+
});
|
|
290
|
+
if (ownDefinesIt)
|
|
291
|
+
continue;
|
|
292
|
+
let resolution;
|
|
293
|
+
switch (provider.mroStrategy) {
|
|
294
|
+
case 'leftmost-base':
|
|
295
|
+
resolution = resolveByMroOrder(methodName, defs, mroOrder, 'leftmost base');
|
|
296
|
+
break;
|
|
297
|
+
case 'implements-split':
|
|
298
|
+
resolution = resolveCsharpJava(methodName, defs, classEdgeTypes);
|
|
299
|
+
break;
|
|
300
|
+
case 'c3':
|
|
301
|
+
resolution = resolveByMroOrder(methodName, defs, mroOrder, 'C3 MRO');
|
|
302
|
+
break;
|
|
303
|
+
case 'qualified-syntax':
|
|
304
|
+
resolution = {
|
|
305
|
+
resolvedTo: null,
|
|
306
|
+
reason: `requires qualified syntax: <Type as Trait>::${methodName}()`,
|
|
307
|
+
confidence: 0.5,
|
|
308
|
+
};
|
|
309
|
+
break;
|
|
310
|
+
default:
|
|
311
|
+
resolution = resolveByMroOrder(methodName, defs, mroOrder, 'first definition');
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
const ambiguity = {
|
|
315
|
+
methodName,
|
|
316
|
+
definedIn: defs,
|
|
317
|
+
resolvedTo: resolution.resolvedTo,
|
|
318
|
+
reason: resolution.reason,
|
|
319
|
+
};
|
|
320
|
+
ambiguities.push(ambiguity);
|
|
321
|
+
if (resolution.resolvedTo === null) {
|
|
322
|
+
ambiguityCount++;
|
|
323
|
+
}
|
|
324
|
+
// Emit METHOD_OVERRIDES edge if resolution found
|
|
325
|
+
if (resolution.resolvedTo !== null) {
|
|
326
|
+
graph.addRelationship({
|
|
327
|
+
id: generateId('METHOD_OVERRIDES', `${classId}->${resolution.resolvedTo}`),
|
|
328
|
+
sourceId: classId,
|
|
329
|
+
targetId: resolution.resolvedTo,
|
|
330
|
+
type: 'METHOD_OVERRIDES',
|
|
331
|
+
confidence: resolution.confidence,
|
|
332
|
+
reason: resolution.reason,
|
|
333
|
+
});
|
|
334
|
+
overrideEdges++;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
entries.push({
|
|
338
|
+
classId,
|
|
339
|
+
className,
|
|
340
|
+
language,
|
|
341
|
+
mro: mroNames,
|
|
342
|
+
ambiguities,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
const methodImplementsEdges = emitMethodImplementsEdges(graph, parentMap, methodMap, parentEdgeType, ancestorsMap, edgeTypesMap);
|
|
346
|
+
return { entries, overrideEdges, ambiguityCount, methodImplementsEdges };
|
|
347
|
+
}
|
|
348
|
+
// ---------------------------------------------------------------------------
|
|
349
|
+
// METHOD_IMPLEMENTS edge emission
|
|
350
|
+
// ---------------------------------------------------------------------------
|
|
351
|
+
/**
|
|
352
|
+
* Check if two parameter type arrays match.
|
|
353
|
+
* When either side has no type info, fall back to parameterCount comparison
|
|
354
|
+
* (arity-compatible matching). If both have parameterCount and they differ,
|
|
355
|
+
* return no match. If counts match, return confident match. If either count
|
|
356
|
+
* is undefined, return lenient (non-confident) match.
|
|
357
|
+
*
|
|
358
|
+
* Returns `{ match, confident }`:
|
|
359
|
+
* - Exact type match → `{ match: true, confident: true }`
|
|
360
|
+
* - Arity match (both have parameterCount, counts equal) → `{ match: true, confident: true }`
|
|
361
|
+
* - Lenient (either side lacks types AND lacks parameterCount) → `{ match: true, confident: false }`
|
|
362
|
+
* - No match → `{ match: false, confident: false }`
|
|
363
|
+
*/
|
|
364
|
+
function parameterTypesMatch(a, b, aParamCount, bParamCount) {
|
|
365
|
+
// If one side is variadic and the other isn't, types may match superficially
|
|
366
|
+
// but the methods aren't guaranteed to be interchangeable
|
|
367
|
+
if ((aParamCount === undefined) !== (bParamCount === undefined)) {
|
|
368
|
+
return { match: true, confident: false };
|
|
369
|
+
}
|
|
370
|
+
if (a.length === 0 || b.length === 0) {
|
|
371
|
+
// Fall back to arity check when type info is missing
|
|
372
|
+
if (aParamCount !== undefined && bParamCount !== undefined) {
|
|
373
|
+
return { match: aParamCount === bParamCount, confident: aParamCount === bParamCount };
|
|
374
|
+
}
|
|
375
|
+
return { match: true, confident: false }; // lenient when either count is unknown
|
|
376
|
+
}
|
|
377
|
+
if (a.length !== b.length)
|
|
378
|
+
return { match: false, confident: false };
|
|
379
|
+
const exact = a.every((t, i) => t === b[i]);
|
|
380
|
+
return { match: exact, confident: exact };
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* For each concrete class that implements/extends an interface or trait,
|
|
384
|
+
* find methods in the class that implement methods defined in the interface
|
|
385
|
+
* and emit METHOD_IMPLEMENTS edges: ConcreteMethod → InterfaceMethod.
|
|
386
|
+
*
|
|
387
|
+
* Method node IDs include a `#<paramCount>` arity suffix, so overloaded
|
|
388
|
+
* methods with different parameter counts are distinct nodes in the graph.
|
|
389
|
+
*
|
|
390
|
+
* **Remaining limitation — same-arity overloads:** When two overloads share
|
|
391
|
+
* the same parameter count but differ only in types (e.g. `save(int)` vs
|
|
392
|
+
* `save(String)`), they still collapse to one node ID. This is rare in
|
|
393
|
+
* practice; a future enhancement may add type-hash disambiguation for
|
|
394
|
+
* languages with reliable type extraction (see issue #574).
|
|
395
|
+
*/
|
|
396
|
+
function emitMethodImplementsEdges(graph, parentMap, methodMap, parentEdgeType, ancestorsMap, edgeTypesMap) {
|
|
397
|
+
let edgeCount = 0;
|
|
398
|
+
for (const [classId, parentIds] of parentMap) {
|
|
399
|
+
const classNode = graph.getNode(classId);
|
|
400
|
+
if (!classNode)
|
|
401
|
+
continue;
|
|
402
|
+
// Interfaces and traits declare contracts — they don't implement them
|
|
403
|
+
if (classNode.label === 'Interface' || classNode.label === 'Trait')
|
|
404
|
+
continue;
|
|
405
|
+
// Get this class's own methods
|
|
406
|
+
const ownMethodIds = methodMap.get(classId) ?? [];
|
|
407
|
+
// Build a lookup: methodName → Array<{methodId, parameterTypes, parameterCount}> for own methods
|
|
408
|
+
const ownMethodsByName = new Map();
|
|
409
|
+
for (const methodId of ownMethodIds) {
|
|
410
|
+
const methodNode = graph.getNode(methodId);
|
|
411
|
+
if (!methodNode || methodNode.label === 'Property')
|
|
412
|
+
continue;
|
|
413
|
+
// Abstract methods don't satisfy interface contracts
|
|
414
|
+
if (methodNode.properties.isAbstract === true)
|
|
415
|
+
continue;
|
|
416
|
+
const name = methodNode.properties.name;
|
|
417
|
+
const parameterTypes = methodNode.properties.parameterTypes ?? [];
|
|
418
|
+
const parameterCount = methodNode.properties.parameterCount;
|
|
419
|
+
let bucket = ownMethodsByName.get(name);
|
|
420
|
+
if (!bucket) {
|
|
421
|
+
bucket = [];
|
|
422
|
+
ownMethodsByName.set(name, bucket);
|
|
423
|
+
}
|
|
424
|
+
bucket.push({ methodId, parameterTypes, parameterCount });
|
|
425
|
+
}
|
|
426
|
+
// Use pre-computed ancestors and edge types; fall back to computing if missing (safety)
|
|
427
|
+
const allAncestors = ancestorsMap.get(classId) ?? gatherAncestors(classId, parentMap);
|
|
428
|
+
const ancestorEdgeTypes = edgeTypesMap.get(classId) ?? buildTransitiveEdgeTypes(classId, parentMap, parentEdgeType);
|
|
429
|
+
// Dedup set: avoid duplicate edges from diamond paths
|
|
430
|
+
const emitted = new Set();
|
|
431
|
+
// For each ancestor, check if it's an interface/trait or classified as IMPLEMENTS
|
|
432
|
+
for (const ancestorId of allAncestors) {
|
|
433
|
+
const ancestorNode = graph.getNode(ancestorId);
|
|
434
|
+
if (!ancestorNode)
|
|
435
|
+
continue;
|
|
436
|
+
const isInterfaceLike = ancestorNode.label === 'Interface' || ancestorNode.label === 'Trait';
|
|
437
|
+
const classifiedEdgeType = ancestorEdgeTypes.get(ancestorId);
|
|
438
|
+
if (!isInterfaceLike && classifiedEdgeType !== 'IMPLEMENTS')
|
|
439
|
+
continue;
|
|
440
|
+
// Get ancestor's methods
|
|
441
|
+
const ancestorMethodIds = methodMap.get(ancestorId) ?? [];
|
|
442
|
+
for (const ancestorMethodId of ancestorMethodIds) {
|
|
443
|
+
const ancestorMethodNode = graph.getNode(ancestorMethodId);
|
|
444
|
+
if (!ancestorMethodNode || ancestorMethodNode.label === 'Property')
|
|
445
|
+
continue;
|
|
446
|
+
const ancestorName = ancestorMethodNode.properties.name;
|
|
447
|
+
const ancestorParamTypes = ancestorMethodNode.properties.parameterTypes ?? [];
|
|
448
|
+
const ancestorParamCount = ancestorMethodNode.properties.parameterCount;
|
|
449
|
+
// Find matching method in own class by name + parameterTypes/arity
|
|
450
|
+
const candidates = ownMethodsByName.get(ancestorName);
|
|
451
|
+
// Unit 3: If no own method matches, walk the EXTENDS chain to find inherited concrete method
|
|
452
|
+
if (!candidates || candidates.length === 0) {
|
|
453
|
+
const inherited = findInheritedMethod(classId, ancestorName, ancestorParamTypes, ancestorParamCount, graph, parentMap, methodMap, parentEdgeType, ancestorMethodId);
|
|
454
|
+
if (inherited) {
|
|
455
|
+
const edgeKey = `${inherited.methodId}->${ancestorMethodId}`;
|
|
456
|
+
if (!emitted.has(edgeKey)) {
|
|
457
|
+
emitted.add(edgeKey);
|
|
458
|
+
graph.addRelationship({
|
|
459
|
+
id: generateId('METHOD_IMPLEMENTS', edgeKey),
|
|
460
|
+
sourceId: inherited.methodId,
|
|
461
|
+
targetId: ancestorMethodId,
|
|
462
|
+
type: 'METHOD_IMPLEMENTS',
|
|
463
|
+
confidence: inherited.confident ? 1.0 : 0.7,
|
|
464
|
+
reason: '',
|
|
465
|
+
});
|
|
466
|
+
edgeCount++;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
// Unit 4: Filter candidates by type/arity match, then check for ambiguity
|
|
472
|
+
const matching = [];
|
|
473
|
+
for (const c of candidates) {
|
|
474
|
+
const result = parameterTypesMatch(c.parameterTypes, ancestorParamTypes, c.parameterCount, ancestorParamCount);
|
|
475
|
+
if (result.match) {
|
|
476
|
+
matching.push({ ...c, confident: result.confident });
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (matching.length === 0)
|
|
480
|
+
continue;
|
|
481
|
+
// If multiple candidates match at name+arity level, emit no edge (ambiguous)
|
|
482
|
+
if (matching.length > 1)
|
|
483
|
+
continue;
|
|
484
|
+
const winner = matching[0];
|
|
485
|
+
const edgeKey = `${winner.methodId}->${ancestorMethodId}`;
|
|
486
|
+
if (emitted.has(edgeKey))
|
|
487
|
+
continue;
|
|
488
|
+
emitted.add(edgeKey);
|
|
489
|
+
graph.addRelationship({
|
|
490
|
+
id: generateId('METHOD_IMPLEMENTS', edgeKey),
|
|
491
|
+
sourceId: winner.methodId,
|
|
492
|
+
targetId: ancestorMethodId,
|
|
493
|
+
type: 'METHOD_IMPLEMENTS',
|
|
494
|
+
confidence: winner.confident ? 1.0 : 0.7,
|
|
495
|
+
reason: '',
|
|
496
|
+
});
|
|
497
|
+
edgeCount++;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return edgeCount;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Walk the class's EXTENDS chain to find the nearest concrete method matching
|
|
505
|
+
* the given name and parameter signature. If the EXTENDS chain yields no match,
|
|
506
|
+
* fall back to IMPLEMENTS parents and check for non-abstract default methods
|
|
507
|
+
* (e.g. Java default interface methods, Kotlin interface defaults).
|
|
508
|
+
* Returns the first matching method found in BFS order, or null.
|
|
509
|
+
*/
|
|
510
|
+
function findInheritedMethod(classId, methodName, targetParamTypes, targetParamCount, graph, parentMap, methodMap, parentEdgeType,
|
|
511
|
+
/** Method ID to exclude from results (prevents self-edges when the ancestor
|
|
512
|
+
* method being matched lives on an IMPLEMENTS parent). */
|
|
513
|
+
excludeMethodId) {
|
|
514
|
+
const visited = new Set();
|
|
515
|
+
const queue = [];
|
|
516
|
+
// Seed with direct EXTENDS parents only
|
|
517
|
+
const directParents = parentMap.get(classId) ?? [];
|
|
518
|
+
const directEdges = parentEdgeType.get(classId);
|
|
519
|
+
for (const pid of directParents) {
|
|
520
|
+
const et = directEdges?.get(pid);
|
|
521
|
+
if (et === 'EXTENDS') {
|
|
522
|
+
// Also check that the parent is not an Interface/Trait
|
|
523
|
+
const parentNode = graph.getNode(pid);
|
|
524
|
+
if (parentNode && parentNode.label !== 'Interface' && parentNode.label !== 'Trait') {
|
|
525
|
+
queue.push(pid);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
// Level-order BFS: process all ancestors at the current depth before
|
|
530
|
+
// advancing. Once any match is found at depth D, finish that depth and stop.
|
|
531
|
+
// Diamond dedup: same methodId via two paths at the same depth = 1 match.
|
|
532
|
+
let currentLevel = [...queue];
|
|
533
|
+
while (currentLevel.length > 0) {
|
|
534
|
+
const matches = new Map();
|
|
535
|
+
const nextLevel = [];
|
|
536
|
+
for (const ancestorId of currentLevel) {
|
|
537
|
+
if (visited.has(ancestorId))
|
|
538
|
+
continue;
|
|
539
|
+
visited.add(ancestorId);
|
|
540
|
+
// Check this ancestor's methods
|
|
541
|
+
const methods = methodMap.get(ancestorId) ?? [];
|
|
542
|
+
for (const mid of methods) {
|
|
543
|
+
const mNode = graph.getNode(mid);
|
|
544
|
+
if (!mNode || mNode.label === 'Property')
|
|
545
|
+
continue;
|
|
546
|
+
// Abstract inherited methods don't count as concrete implementations
|
|
547
|
+
if (mNode.properties.isAbstract === true)
|
|
548
|
+
continue;
|
|
549
|
+
if (mNode.properties.name !== methodName)
|
|
550
|
+
continue;
|
|
551
|
+
const mParamTypes = mNode.properties.parameterTypes ?? [];
|
|
552
|
+
const mParamCount = mNode.properties.parameterCount;
|
|
553
|
+
const ptResult = parameterTypesMatch(mParamTypes, targetParamTypes, mParamCount, targetParamCount);
|
|
554
|
+
if (ptResult.match) {
|
|
555
|
+
matches.set(mid, {
|
|
556
|
+
methodId: mid,
|
|
557
|
+
parameterTypes: mParamTypes,
|
|
558
|
+
confident: ptResult.confident,
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
// Collect EXTENDS parents for the next depth level
|
|
563
|
+
const grandparents = parentMap.get(ancestorId) ?? [];
|
|
564
|
+
const ancestorEdges = parentEdgeType.get(ancestorId);
|
|
565
|
+
for (const gp of grandparents) {
|
|
566
|
+
if (visited.has(gp))
|
|
567
|
+
continue;
|
|
568
|
+
const gpEdge = ancestorEdges?.get(gp);
|
|
569
|
+
if (gpEdge === 'EXTENDS') {
|
|
570
|
+
const gpNode = graph.getNode(gp);
|
|
571
|
+
if (gpNode && gpNode.label !== 'Interface' && gpNode.label !== 'Trait') {
|
|
572
|
+
nextLevel.push(gp);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
// If any matches found at this depth, decide and stop
|
|
578
|
+
if (matches.size === 1)
|
|
579
|
+
return matches.values().next().value;
|
|
580
|
+
if (matches.size > 1)
|
|
581
|
+
return null; // ambiguous at same depth
|
|
582
|
+
currentLevel = nextLevel;
|
|
583
|
+
}
|
|
584
|
+
// ── Second pass: walk IMPLEMENTS parents AND their interface ancestry ──
|
|
585
|
+
// Only reached when the EXTENDS chain yielded no match.
|
|
586
|
+
// BFS through interface/trait hierarchy to find default (non-abstract) methods.
|
|
587
|
+
const implBfsQueue = [];
|
|
588
|
+
for (const pid of directParents) {
|
|
589
|
+
const et = directEdges?.get(pid);
|
|
590
|
+
if (et === 'IMPLEMENTS') {
|
|
591
|
+
implBfsQueue.push(pid);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
// Collect all matches from the IMPLEMENTS BFS — return null if ambiguous (>1 match)
|
|
595
|
+
const implMatches = [];
|
|
596
|
+
const implVisited = new Set();
|
|
597
|
+
while (implBfsQueue.length > 0) {
|
|
598
|
+
const ifaceId = implBfsQueue.shift();
|
|
599
|
+
if (implVisited.has(ifaceId))
|
|
600
|
+
continue;
|
|
601
|
+
implVisited.add(ifaceId);
|
|
602
|
+
// Only process Interface/Trait nodes — Dart `implements Class` does not
|
|
603
|
+
// inherit method bodies, so Class/Struct/Enum parents must be skipped.
|
|
604
|
+
const ifaceNode = graph.getNode(ifaceId);
|
|
605
|
+
if (!ifaceNode || (ifaceNode.label !== 'Interface' && ifaceNode.label !== 'Trait'))
|
|
606
|
+
continue;
|
|
607
|
+
// Check this interface/trait's methods for a non-abstract default
|
|
608
|
+
const methods = methodMap.get(ifaceId) ?? [];
|
|
609
|
+
for (const mid of methods) {
|
|
610
|
+
if (mid === excludeMethodId)
|
|
611
|
+
continue; // prevent self-edges
|
|
612
|
+
const mNode = graph.getNode(mid);
|
|
613
|
+
if (!mNode || mNode.label === 'Property')
|
|
614
|
+
continue;
|
|
615
|
+
if (mNode.properties.isAbstract === true)
|
|
616
|
+
continue;
|
|
617
|
+
if (mNode.properties.name !== methodName)
|
|
618
|
+
continue;
|
|
619
|
+
const mParamTypes = mNode.properties.parameterTypes ?? [];
|
|
620
|
+
const mParamCount = mNode.properties.parameterCount;
|
|
621
|
+
const ptResult = parameterTypesMatch(mParamTypes, targetParamTypes, mParamCount, targetParamCount);
|
|
622
|
+
if (ptResult.match) {
|
|
623
|
+
implMatches.push({
|
|
624
|
+
methodId: mid,
|
|
625
|
+
parameterTypes: mParamTypes,
|
|
626
|
+
confident: ptResult.confident,
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
// Walk this interface's parents (interface-extends-interface chains)
|
|
631
|
+
const ifaceParents = parentMap.get(ifaceId) ?? [];
|
|
632
|
+
for (const gp of ifaceParents) {
|
|
633
|
+
if (!implVisited.has(gp))
|
|
634
|
+
implBfsQueue.push(gp);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
// Ambiguous: multiple interfaces provide the same default method
|
|
638
|
+
if (implMatches.length === 1)
|
|
639
|
+
return implMatches[0];
|
|
640
|
+
return null; // 0 matches or ambiguous (>1)
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Build transitive edge types for a class using BFS from the class to all ancestors.
|
|
644
|
+
*
|
|
645
|
+
* Known limitation: BFS first-reach heuristic can misclassify an interface as
|
|
646
|
+
* EXTENDS if it's reachable via a class chain before being seen via IMPLEMENTS.
|
|
647
|
+
* E.g. if BaseClass also implements IFoo, IFoo may be classified as EXTENDS.
|
|
648
|
+
* This affects C#/Java/Kotlin conflict resolution in rare diamond hierarchies.
|
|
649
|
+
*/
|
|
650
|
+
function buildTransitiveEdgeTypes(classId, parentMap, parentEdgeType) {
|
|
651
|
+
const result = new Map();
|
|
652
|
+
const directEdges = parentEdgeType.get(classId);
|
|
653
|
+
if (!directEdges)
|
|
654
|
+
return result;
|
|
655
|
+
// BFS: propagate edge type from direct parents
|
|
656
|
+
const queue = [];
|
|
657
|
+
const directParents = parentMap.get(classId) ?? [];
|
|
658
|
+
for (const pid of directParents) {
|
|
659
|
+
const et = directEdges.get(pid) ?? 'EXTENDS';
|
|
660
|
+
if (!result.has(pid)) {
|
|
661
|
+
result.set(pid, et);
|
|
662
|
+
queue.push({ id: pid, edgeType: et });
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
while (queue.length > 0) {
|
|
666
|
+
const { id, edgeType } = queue.shift();
|
|
667
|
+
const grandparents = parentMap.get(id) ?? [];
|
|
668
|
+
for (const gp of grandparents) {
|
|
669
|
+
if (!result.has(gp)) {
|
|
670
|
+
result.set(gp, edgeType);
|
|
671
|
+
queue.push({ id: gp, edgeType });
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return result;
|
|
676
|
+
}
|
|
677
|
+
//# sourceMappingURL=mro-processor.js.map
|