gitnexus 1.5.3 → 1.6.1
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 +10 -0
- package/dist/_shared/graph/types.d.ts +1 -1
- package/dist/_shared/graph/types.d.ts.map +1 -1
- package/dist/_shared/index.d.ts +1 -0
- package/dist/_shared/index.d.ts.map +1 -1
- package/dist/_shared/language-detection.d.ts.map +1 -1
- package/dist/_shared/language-detection.js +2 -0
- package/dist/_shared/language-detection.js.map +1 -1
- package/dist/_shared/languages.d.ts +1 -0
- package/dist/_shared/languages.d.ts.map +1 -1
- package/dist/_shared/languages.js +1 -0
- package/dist/_shared/languages.js.map +1 -1
- package/dist/_shared/lbug/schema-constants.d.ts +1 -1
- package/dist/_shared/lbug/schema-constants.d.ts.map +1 -1
- package/dist/_shared/lbug/schema-constants.js +3 -1
- package/dist/_shared/lbug/schema-constants.js.map +1 -1
- package/dist/_shared/mro-strategy.d.ts +19 -0
- package/dist/_shared/mro-strategy.d.ts.map +1 -0
- package/dist/_shared/mro-strategy.js +2 -0
- package/dist/_shared/mro-strategy.js.map +1 -0
- package/dist/cli/ai-context.d.ts +1 -0
- package/dist/cli/ai-context.js +28 -4
- package/dist/cli/analyze.d.ts +2 -0
- package/dist/cli/analyze.js +30 -4
- package/dist/cli/group.d.ts +2 -0
- package/dist/cli/group.js +233 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/serve.js +4 -1
- package/dist/cli/setup.js +34 -3
- package/dist/config/ignore-service.js +8 -3
- package/dist/core/augmentation/engine.js +1 -1
- package/dist/core/git-staleness.d.ts +13 -0
- package/dist/core/git-staleness.js +29 -0
- package/dist/core/group/bridge-db.d.ts +82 -0
- package/dist/core/group/bridge-db.js +460 -0
- package/dist/core/group/bridge-schema.d.ts +27 -0
- package/dist/core/group/bridge-schema.js +55 -0
- package/dist/core/group/config-parser.d.ts +3 -0
- package/dist/core/group/config-parser.js +83 -0
- package/dist/core/group/contract-extractor.d.ts +7 -0
- package/dist/core/group/contract-extractor.js +1 -0
- package/dist/core/group/extractors/fs-utils.d.ts +10 -0
- package/dist/core/group/extractors/fs-utils.js +24 -0
- package/dist/core/group/extractors/grpc-extractor.d.ts +25 -0
- package/dist/core/group/extractors/grpc-extractor.js +386 -0
- package/dist/core/group/extractors/grpc-patterns/go.d.ts +2 -0
- package/dist/core/group/extractors/grpc-patterns/go.js +97 -0
- package/dist/core/group/extractors/grpc-patterns/index.d.ts +19 -0
- package/dist/core/group/extractors/grpc-patterns/index.js +46 -0
- package/dist/core/group/extractors/grpc-patterns/java.d.ts +2 -0
- package/dist/core/group/extractors/grpc-patterns/java.js +173 -0
- package/dist/core/group/extractors/grpc-patterns/node.d.ts +4 -0
- package/dist/core/group/extractors/grpc-patterns/node.js +290 -0
- package/dist/core/group/extractors/grpc-patterns/proto.d.ts +9 -0
- package/dist/core/group/extractors/grpc-patterns/proto.js +134 -0
- package/dist/core/group/extractors/grpc-patterns/python.d.ts +2 -0
- package/dist/core/group/extractors/grpc-patterns/python.js +67 -0
- package/dist/core/group/extractors/grpc-patterns/types.d.ts +50 -0
- package/dist/core/group/extractors/grpc-patterns/types.js +1 -0
- package/dist/core/group/extractors/http-patterns/go.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/go.js +215 -0
- package/dist/core/group/extractors/http-patterns/index.d.ts +17 -0
- package/dist/core/group/extractors/http-patterns/index.js +44 -0
- package/dist/core/group/extractors/http-patterns/java.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/java.js +253 -0
- package/dist/core/group/extractors/http-patterns/node.d.ts +4 -0
- package/dist/core/group/extractors/http-patterns/node.js +354 -0
- package/dist/core/group/extractors/http-patterns/php.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/php.js +70 -0
- package/dist/core/group/extractors/http-patterns/python.d.ts +2 -0
- package/dist/core/group/extractors/http-patterns/python.js +133 -0
- package/dist/core/group/extractors/http-patterns/types.d.ts +61 -0
- package/dist/core/group/extractors/http-patterns/types.js +1 -0
- package/dist/core/group/extractors/http-route-extractor.d.ts +21 -0
- package/dist/core/group/extractors/http-route-extractor.js +391 -0
- package/dist/core/group/extractors/manifest-extractor.d.ts +54 -0
- package/dist/core/group/extractors/manifest-extractor.js +235 -0
- package/dist/core/group/extractors/topic-extractor.d.ts +8 -0
- package/dist/core/group/extractors/topic-extractor.js +97 -0
- package/dist/core/group/extractors/topic-patterns/go.d.ts +2 -0
- package/dist/core/group/extractors/topic-patterns/go.js +120 -0
- package/dist/core/group/extractors/topic-patterns/index.d.ts +14 -0
- package/dist/core/group/extractors/topic-patterns/index.js +38 -0
- package/dist/core/group/extractors/topic-patterns/java.d.ts +2 -0
- package/dist/core/group/extractors/topic-patterns/java.js +80 -0
- package/dist/core/group/extractors/topic-patterns/node.d.ts +4 -0
- package/dist/core/group/extractors/topic-patterns/node.js +155 -0
- package/dist/core/group/extractors/topic-patterns/python.d.ts +2 -0
- package/dist/core/group/extractors/topic-patterns/python.js +116 -0
- package/dist/core/group/extractors/topic-patterns/types.d.ts +25 -0
- package/dist/core/group/extractors/topic-patterns/types.js +10 -0
- package/dist/core/group/extractors/tree-sitter-scanner.d.ts +113 -0
- package/dist/core/group/extractors/tree-sitter-scanner.js +94 -0
- package/dist/core/group/matching.d.ts +13 -0
- package/dist/core/group/matching.js +198 -0
- package/dist/core/group/normalization.d.ts +3 -0
- package/dist/core/group/normalization.js +115 -0
- package/dist/core/group/service-boundary-detector.d.ts +8 -0
- package/dist/core/group/service-boundary-detector.js +155 -0
- package/dist/core/group/service.d.ts +46 -0
- package/dist/core/group/service.js +160 -0
- package/dist/core/group/storage.d.ts +9 -0
- package/dist/core/group/storage.js +91 -0
- package/dist/core/group/sync.d.ts +21 -0
- package/dist/core/group/sync.js +148 -0
- package/dist/core/group/types.d.ts +130 -0
- package/dist/core/group/types.js +1 -0
- package/dist/core/ingestion/binding-accumulator.d.ts +212 -0
- package/dist/core/ingestion/binding-accumulator.js +336 -0
- package/dist/core/ingestion/call-processor.d.ts +155 -24
- package/dist/core/ingestion/call-processor.js +1129 -247
- package/dist/core/ingestion/class-extractors/generic.d.ts +2 -0
- package/dist/core/ingestion/class-extractors/generic.js +135 -0
- package/dist/core/ingestion/class-types.d.ts +34 -0
- package/dist/core/ingestion/class-types.js +1 -0
- package/dist/core/ingestion/cobol-processor.d.ts +1 -1
- package/dist/core/ingestion/entry-point-scoring.d.ts +1 -0
- package/dist/core/ingestion/entry-point-scoring.js +1 -0
- package/dist/core/ingestion/field-types.d.ts +2 -2
- package/dist/core/ingestion/filesystem-walker.js +8 -0
- package/dist/core/ingestion/framework-detection.d.ts +1 -0
- package/dist/core/ingestion/framework-detection.js +1 -0
- package/dist/core/ingestion/heritage-processor.d.ts +8 -15
- package/dist/core/ingestion/heritage-processor.js +15 -28
- package/dist/core/ingestion/import-processor.d.ts +1 -11
- package/dist/core/ingestion/import-processor.js +1 -13
- package/dist/core/ingestion/import-resolvers/utils.js +1 -0
- package/dist/core/ingestion/import-resolvers/vue.d.ts +8 -0
- package/dist/core/ingestion/import-resolvers/vue.js +9 -0
- package/dist/core/ingestion/language-config.js +1 -1
- package/dist/core/ingestion/language-provider.d.ts +14 -3
- package/dist/core/ingestion/languages/c-cpp.js +168 -1
- package/dist/core/ingestion/languages/csharp.js +20 -0
- package/dist/core/ingestion/languages/dart.js +26 -4
- package/dist/core/ingestion/languages/go.js +22 -0
- package/dist/core/ingestion/languages/index.d.ts +1 -0
- package/dist/core/ingestion/languages/index.js +2 -0
- package/dist/core/ingestion/languages/java.js +17 -0
- package/dist/core/ingestion/languages/kotlin.js +24 -1
- package/dist/core/ingestion/languages/php.js +23 -11
- package/dist/core/ingestion/languages/python.js +9 -0
- package/dist/core/ingestion/languages/ruby.js +43 -0
- package/dist/core/ingestion/languages/rust.js +38 -0
- package/dist/core/ingestion/languages/swift.js +31 -0
- package/dist/core/ingestion/languages/typescript.d.ts +1 -0
- package/dist/core/ingestion/languages/typescript.js +52 -3
- package/dist/core/ingestion/languages/vue.d.ts +13 -0
- package/dist/core/ingestion/languages/vue.js +81 -0
- package/dist/core/ingestion/markdown-processor.d.ts +1 -1
- package/dist/core/ingestion/method-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/method-extractors/configs/c-cpp.js +387 -0
- package/dist/core/ingestion/method-extractors/configs/csharp.js +5 -1
- package/dist/core/ingestion/method-extractors/configs/dart.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/dart.js +376 -0
- package/dist/core/ingestion/method-extractors/configs/go.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/go.js +176 -0
- package/dist/core/ingestion/method-extractors/configs/jvm.js +14 -4
- package/dist/core/ingestion/method-extractors/configs/php.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/php.js +304 -0
- package/dist/core/ingestion/method-extractors/configs/python.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/python.js +309 -0
- package/dist/core/ingestion/method-extractors/configs/ruby.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/ruby.js +286 -0
- package/dist/core/ingestion/method-extractors/configs/rust.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/rust.js +195 -0
- package/dist/core/ingestion/method-extractors/configs/swift.d.ts +2 -0
- package/dist/core/ingestion/method-extractors/configs/swift.js +277 -0
- package/dist/core/ingestion/method-extractors/configs/typescript-javascript.js +85 -8
- package/dist/core/ingestion/method-extractors/generic.d.ts +6 -0
- package/dist/core/ingestion/method-extractors/generic.js +84 -17
- package/dist/core/ingestion/method-types.d.ts +29 -0
- package/dist/core/ingestion/model/field-registry.d.ts +18 -0
- package/dist/core/ingestion/model/field-registry.js +22 -0
- package/dist/core/ingestion/model/heritage-map.d.ts +70 -0
- package/dist/core/ingestion/model/heritage-map.js +159 -0
- package/dist/core/ingestion/model/index.d.ts +20 -0
- package/dist/core/ingestion/model/index.js +41 -0
- package/dist/core/ingestion/model/method-registry.d.ts +62 -0
- package/dist/core/ingestion/model/method-registry.js +130 -0
- package/dist/core/ingestion/model/registration-table.d.ts +139 -0
- package/dist/core/ingestion/model/registration-table.js +224 -0
- package/dist/core/ingestion/model/resolution-context.d.ts +93 -0
- package/dist/core/ingestion/model/resolution-context.js +337 -0
- package/dist/core/ingestion/model/resolve.d.ts +56 -0
- package/dist/core/ingestion/model/resolve.js +297 -0
- package/dist/core/ingestion/model/semantic-model.d.ts +86 -0
- package/dist/core/ingestion/model/semantic-model.js +120 -0
- package/dist/core/ingestion/model/symbol-table.d.ts +222 -0
- package/dist/core/ingestion/model/symbol-table.js +206 -0
- package/dist/core/ingestion/model/type-registry.d.ts +39 -0
- package/dist/core/ingestion/model/type-registry.js +62 -0
- package/dist/core/ingestion/mro-processor.d.ts +5 -4
- package/dist/core/ingestion/mro-processor.js +311 -107
- package/dist/core/ingestion/parsing-processor.d.ts +5 -4
- package/dist/core/ingestion/parsing-processor.js +224 -87
- package/dist/core/ingestion/pipeline-phases/cobol.d.ts +16 -0
- package/dist/core/ingestion/pipeline-phases/cobol.js +45 -0
- package/dist/core/ingestion/pipeline-phases/communities.d.ts +16 -0
- package/dist/core/ingestion/pipeline-phases/communities.js +62 -0
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.d.ts +17 -0
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.js +156 -0
- package/dist/core/ingestion/pipeline-phases/cross-file.d.ts +37 -0
- package/dist/core/ingestion/pipeline-phases/cross-file.js +63 -0
- package/dist/core/ingestion/pipeline-phases/index.d.ts +21 -0
- package/dist/core/ingestion/pipeline-phases/index.js +22 -0
- package/dist/core/ingestion/pipeline-phases/markdown.d.ts +17 -0
- package/dist/core/ingestion/pipeline-phases/markdown.js +33 -0
- package/dist/core/ingestion/pipeline-phases/mro.d.ts +18 -0
- package/dist/core/ingestion/pipeline-phases/mro.js +36 -0
- package/dist/core/ingestion/pipeline-phases/orm-extraction.d.ts +22 -0
- package/dist/core/ingestion/pipeline-phases/orm-extraction.js +92 -0
- package/dist/core/ingestion/pipeline-phases/orm.d.ts +15 -0
- package/dist/core/ingestion/pipeline-phases/orm.js +74 -0
- package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +47 -0
- package/dist/core/ingestion/pipeline-phases/parse-impl.js +437 -0
- package/dist/core/ingestion/pipeline-phases/parse.d.ts +49 -0
- package/dist/core/ingestion/pipeline-phases/parse.js +33 -0
- package/dist/core/ingestion/pipeline-phases/processes.d.ts +16 -0
- package/dist/core/ingestion/pipeline-phases/processes.js +143 -0
- package/dist/core/ingestion/pipeline-phases/routes.d.ts +21 -0
- package/dist/core/ingestion/pipeline-phases/routes.js +243 -0
- package/dist/core/ingestion/pipeline-phases/runner.d.ts +22 -0
- package/dist/core/ingestion/pipeline-phases/runner.js +203 -0
- package/dist/core/ingestion/pipeline-phases/scan.d.ts +21 -0
- package/dist/core/ingestion/pipeline-phases/scan.js +46 -0
- package/dist/core/ingestion/pipeline-phases/structure.d.ts +27 -0
- package/dist/core/ingestion/pipeline-phases/structure.js +35 -0
- package/dist/core/ingestion/pipeline-phases/tools.d.ts +20 -0
- package/dist/core/ingestion/pipeline-phases/tools.js +79 -0
- package/dist/core/ingestion/pipeline-phases/types.d.ts +79 -0
- package/dist/core/ingestion/pipeline-phases/types.js +37 -0
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.d.ts +35 -0
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.js +174 -0
- package/dist/core/ingestion/pipeline.d.ts +18 -10
- package/dist/core/ingestion/pipeline.js +66 -1410
- package/dist/core/ingestion/process-processor.js +1 -1
- package/dist/core/ingestion/tree-sitter-queries.d.ts +5 -5
- package/dist/core/ingestion/tree-sitter-queries.js +90 -0
- package/dist/core/ingestion/type-env.d.ts +15 -2
- package/dist/core/ingestion/type-env.js +163 -102
- package/dist/core/ingestion/type-extractors/csharp.js +17 -0
- package/dist/core/ingestion/type-extractors/jvm.js +11 -0
- package/dist/core/ingestion/type-extractors/php.js +0 -55
- package/dist/core/ingestion/type-extractors/ruby.js +0 -32
- package/dist/core/ingestion/type-extractors/swift.js +13 -0
- package/dist/core/ingestion/type-extractors/types.d.ts +8 -8
- package/dist/core/ingestion/type-extractors/typescript.js +66 -69
- package/dist/core/ingestion/utils/ast-helpers.d.ts +32 -44
- package/dist/core/ingestion/utils/ast-helpers.js +157 -573
- package/dist/core/ingestion/utils/env.d.ts +10 -0
- package/dist/core/ingestion/utils/env.js +10 -0
- package/dist/core/ingestion/utils/graph-sort.d.ts +58 -0
- package/dist/core/ingestion/utils/graph-sort.js +100 -0
- package/dist/core/ingestion/utils/method-props.d.ts +32 -0
- package/dist/core/ingestion/utils/method-props.js +147 -0
- package/dist/core/ingestion/vue-sfc-extractor.d.ts +44 -0
- package/dist/core/ingestion/vue-sfc-extractor.js +94 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +31 -19
- package/dist/core/ingestion/workers/parse-worker.js +469 -200
- package/dist/core/lbug/lbug-adapter.d.ts +6 -0
- package/dist/core/lbug/lbug-adapter.js +134 -27
- package/dist/core/lbug/pool-adapter.d.ts +76 -0
- package/dist/core/lbug/pool-adapter.js +522 -0
- package/dist/core/run-analyze.d.ts +2 -0
- package/dist/core/run-analyze.js +1 -1
- package/dist/core/search/bm25-index.js +1 -1
- package/dist/core/tree-sitter/parser-loader.js +1 -0
- package/dist/core/wiki/graph-queries.js +1 -1
- package/dist/mcp/core/embedder.js +6 -5
- package/dist/mcp/core/lbug-adapter.d.ts +3 -63
- package/dist/mcp/core/lbug-adapter.js +3 -484
- package/dist/mcp/local/local-backend.d.ts +31 -2
- package/dist/mcp/local/local-backend.js +255 -46
- package/dist/mcp/resources.js +5 -4
- package/dist/mcp/staleness.d.ts +3 -13
- package/dist/mcp/staleness.js +2 -31
- package/dist/mcp/tools.js +80 -4
- package/dist/server/analyze-job.d.ts +2 -0
- package/dist/server/analyze-job.js +4 -0
- package/dist/server/api.d.ts +20 -1
- package/dist/server/api.js +306 -71
- package/dist/server/git-clone.d.ts +2 -1
- package/dist/server/git-clone.js +98 -5
- package/dist/storage/git.d.ts +13 -0
- package/dist/storage/git.js +25 -0
- package/dist/storage/repo-manager.js +1 -1
- package/package.json +9 -3
- package/scripts/patch-tree-sitter-swift.cjs +78 -0
- package/vendor/tree-sitter-proto/binding.gyp +30 -0
- package/vendor/tree-sitter-proto/bindings/node/binding.cc +20 -0
- package/vendor/tree-sitter-proto/bindings/node/index.d.ts +28 -0
- package/vendor/tree-sitter-proto/bindings/node/index.js +7 -0
- package/vendor/tree-sitter-proto/package.json +18 -0
- package/vendor/tree-sitter-proto/src/node-types.json +1145 -0
- package/vendor/tree-sitter-proto/src/parser.c +10149 -0
- package/vendor/tree-sitter-proto/src/tree_sitter/alloc.h +54 -0
- package/vendor/tree-sitter-proto/src/tree_sitter/array.h +291 -0
- package/vendor/tree-sitter-proto/src/tree_sitter/parser.h +266 -0
- package/dist/core/ingestion/named-binding-processor.d.ts +0 -18
- package/dist/core/ingestion/named-binding-processor.js +0 -42
- package/dist/core/ingestion/resolution-context.d.ts +0 -58
- package/dist/core/ingestion/resolution-context.js +0 -135
- package/dist/core/ingestion/symbol-table.d.ts +0 -79
- package/dist/core/ingestion/symbol-table.js +0 -115
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Symbol Table — file-indexed + callable-name symbol storage.
|
|
3
|
+
*
|
|
4
|
+
* This module is a PURE LEAF in the ingestion dependency hierarchy. It owns
|
|
5
|
+
* two orthogonal O(1) indexes:
|
|
6
|
+
*
|
|
7
|
+
* 1. fileIndex — Map<filePath, Map<name, SymbolDefinition[]>>
|
|
8
|
+
* for same-file lookups (Tier 1 resolution)
|
|
9
|
+
* 2. callableByName — Map<name, SymbolDefinition[]>
|
|
10
|
+
* for name-keyed callable lookups (Tier 3 widen)
|
|
11
|
+
*
|
|
12
|
+
* SymbolTable deliberately knows NOTHING about the owner-scoped registries
|
|
13
|
+
* (types, methods, fields) that sit above it in the dependency graph. Those
|
|
14
|
+
* registries live in `model/` and depend on SymbolTable, not the other way
|
|
15
|
+
* around. {@link createSemanticModel} composes this pure SymbolTable with the
|
|
16
|
+
* registries and wraps `add()` to fan out registrations into both layers.
|
|
17
|
+
*
|
|
18
|
+
* Dependency direction (strictly enforced):
|
|
19
|
+
*
|
|
20
|
+
* gitnexus-shared (NodeLabel) — leaf type
|
|
21
|
+
* ↑
|
|
22
|
+
* symbol-table.ts — THIS FILE (pure storage)
|
|
23
|
+
* ↑
|
|
24
|
+
* model/type-registry.ts, method-registry.ts, field-registry.ts
|
|
25
|
+
* ↑
|
|
26
|
+
* model/registration-table.ts — dispatch table factory
|
|
27
|
+
* ↑
|
|
28
|
+
* model/semantic-model.ts — orchestrator, wraps add()
|
|
29
|
+
* ↑
|
|
30
|
+
* model/resolve.ts, call-processor.ts, resolution-context.ts, ...
|
|
31
|
+
*
|
|
32
|
+
* No arrow ever points downward from this file. If you are tempted to
|
|
33
|
+
* import from `./model/` here, you are going the wrong way — move the
|
|
34
|
+
* logic up the dependency chain instead.
|
|
35
|
+
*/
|
|
36
|
+
import type { NodeLabel } from '../../../_shared/index.js';
|
|
37
|
+
/**
|
|
38
|
+
* Class-like NodeLabels — used for qualifiedName fallback inside
|
|
39
|
+
* `SymbolTable.add()` and (via import into `model/registration-table.ts`)
|
|
40
|
+
* as the single source of truth for which labels route to classHook
|
|
41
|
+
* in the dispatch table.
|
|
42
|
+
*
|
|
43
|
+
* Exported as a `readonly` tuple so that `typeof CLASS_TYPES_TUPLE[number]`
|
|
44
|
+
* yields a precise literal union (`ClassLikeLabel`). The model layer
|
|
45
|
+
* imports this tuple and uses `Record<ClassLikeLabel, 'dispatch'>` in a
|
|
46
|
+
* `satisfies` intersection to enforce at COMPILE TIME that every label
|
|
47
|
+
* listed here is also classified as dispatch in `LABEL_BEHAVIOR`. Adding
|
|
48
|
+
* a new class-like label to this tuple without updating `LABEL_BEHAVIOR`
|
|
49
|
+
* fails TypeScript.
|
|
50
|
+
*
|
|
51
|
+
* Traits are class-like for heritage resolution: PHP `use Trait;`, Rust
|
|
52
|
+
* `impl Trait for Struct`, and Scala traits all contribute methods to the
|
|
53
|
+
* hierarchy of their using/implementing type.
|
|
54
|
+
*/
|
|
55
|
+
export declare const CLASS_TYPES_TUPLE: readonly ["Class", "Struct", "Interface", "Enum", "Record", "Trait"];
|
|
56
|
+
export type ClassLikeLabel = (typeof CLASS_TYPES_TUPLE)[number];
|
|
57
|
+
export declare const CLASS_TYPES: ReadonlySet<NodeLabel>;
|
|
58
|
+
/** Free-callable labels — single source of truth for "callables that have
|
|
59
|
+
* NO owner scope". Methods and constructors are owner-scoped and live in
|
|
60
|
+
* `MethodRegistry` — Tier 3 reaches them via
|
|
61
|
+
* `model.methods.lookupMethodByName`. See `resolution-context.ts` Tier 3
|
|
62
|
+
* for how both indexes are consulted together.
|
|
63
|
+
*
|
|
64
|
+
* Exported as a `readonly` tuple so that `typeof FREE_CALLABLE_TUPLE[number]`
|
|
65
|
+
* yields a precise literal union (`FreeCallableLabel`). `registration-table.ts`
|
|
66
|
+
* imports this type and uses `Record<FreeCallableLabel, 'callable-only'>` in
|
|
67
|
+
* a `satisfies` intersection to enforce at COMPILE TIME that every label
|
|
68
|
+
* listed here is also classified as `callable-only` in `LABEL_BEHAVIOR`.
|
|
69
|
+
* Adding a label to this tuple without updating `LABEL_BEHAVIOR` fails
|
|
70
|
+
* TypeScript.
|
|
71
|
+
*
|
|
72
|
+
* Partial-state caveat: Python/Rust/Kotlin class methods are emitted by
|
|
73
|
+
* the worker as `Function` + `ownerId` (not `Method`), so they still land
|
|
74
|
+
* here via the `Function` entry. Collapsing those three languages onto the
|
|
75
|
+
* `Method` label is pending a `def.type` preservation decision.
|
|
76
|
+
*/
|
|
77
|
+
export declare const FREE_CALLABLE_TUPLE: readonly ["Function", "Macro", "Delegate"];
|
|
78
|
+
export type FreeCallableLabel = (typeof FREE_CALLABLE_TUPLE)[number];
|
|
79
|
+
export declare const FREE_CALLABLE_TYPES: ReadonlySet<NodeLabel>;
|
|
80
|
+
/** Symbol types that can be the TARGET of a call in the resolver's kind
|
|
81
|
+
* filter — superset of {@link FREE_CALLABLE_TYPES} that also admits
|
|
82
|
+
* owner-scoped methods and constructors pulled in from `MethodRegistry`.
|
|
83
|
+
*
|
|
84
|
+
* Why the split: `FREE_CALLABLE_TYPES` now has a narrow meaning (free
|
|
85
|
+
* callables indexed in `callableByName`), but call resolution still
|
|
86
|
+
* needs to accept Method and Constructor candidates once they have been
|
|
87
|
+
* unioned in from `model.methods.lookupMethodByName`. The resolver uses
|
|
88
|
+
* this constant for kind filtering in
|
|
89
|
+
* `filterCallableCandidates` / `countCallableCandidates`.
|
|
90
|
+
*/
|
|
91
|
+
export declare const CALL_TARGET_TYPES: ReadonlySet<NodeLabel>;
|
|
92
|
+
export interface SymbolDefinition {
|
|
93
|
+
nodeId: string;
|
|
94
|
+
filePath: string;
|
|
95
|
+
type: NodeLabel;
|
|
96
|
+
/** Canonical dot-separated qualified type name for class-like symbols
|
|
97
|
+
* (e.g. `App.Models.User`). Falls back to the simple symbol name when no
|
|
98
|
+
* package/namespace/module scope exists or no explicit qualified metadata is provided. */
|
|
99
|
+
qualifiedName?: string;
|
|
100
|
+
parameterCount?: number;
|
|
101
|
+
/** Number of required (non-optional, non-default) parameters.
|
|
102
|
+
* Enables range-based arity filtering: argCount >= requiredParameterCount && argCount <= parameterCount. */
|
|
103
|
+
requiredParameterCount?: number;
|
|
104
|
+
/** Per-parameter type names for overload disambiguation (e.g. ['int', 'String']).
|
|
105
|
+
* Populated when parameter types are resolvable from AST (any typed language). */
|
|
106
|
+
parameterTypes?: string[];
|
|
107
|
+
/** Raw return type text extracted from AST (e.g. 'User', 'Promise<User>') */
|
|
108
|
+
returnType?: string;
|
|
109
|
+
/** Declared type for non-callable symbols — fields/properties (e.g. 'Address', 'List<User>') */
|
|
110
|
+
declaredType?: string;
|
|
111
|
+
/** Links Method/Constructor/Property to owning Class/Struct/Trait nodeId */
|
|
112
|
+
ownerId?: string;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Optional metadata accepted by {@link SymbolTable.add}. Kept as a separate
|
|
116
|
+
* type alias so callers and wrappers can share the same shape.
|
|
117
|
+
*/
|
|
118
|
+
export interface AddMetadata {
|
|
119
|
+
parameterCount?: number;
|
|
120
|
+
requiredParameterCount?: number;
|
|
121
|
+
parameterTypes?: string[];
|
|
122
|
+
returnType?: string;
|
|
123
|
+
declaredType?: string;
|
|
124
|
+
ownerId?: string;
|
|
125
|
+
qualifiedName?: string;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Pure read-only view over the file and callable indexes. Does NOT
|
|
129
|
+
* include `add()` or `clear()`.
|
|
130
|
+
*
|
|
131
|
+
* Used by consumers that only query symbols (resolvers, type-env, field
|
|
132
|
+
* extractors). The interface is strictly observational — holding a
|
|
133
|
+
* `SymbolTableReader` cannot mutate the table in any way.
|
|
134
|
+
*
|
|
135
|
+
* For consumers that also need to register symbols, use
|
|
136
|
+
* {@link SymbolTableWriter}, which extends this interface with `add()`.
|
|
137
|
+
* Neither interface exposes `clear()` — that capability lives on the
|
|
138
|
+
* internal factory return type and is reachable only inside
|
|
139
|
+
* `SemanticModel` via `rawSymbols`.
|
|
140
|
+
*
|
|
141
|
+
* Segregating the observer contract from the mutation contract means
|
|
142
|
+
* callers holding only a Reader can never desync the model.
|
|
143
|
+
*/
|
|
144
|
+
export interface SymbolTableReader {
|
|
145
|
+
/**
|
|
146
|
+
* High Confidence: Look for a symbol specifically inside a file.
|
|
147
|
+
* Returns the Node ID if found.
|
|
148
|
+
*/
|
|
149
|
+
lookupExact: (filePath: string, name: string) => string | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* High Confidence: Look for a symbol in a specific file, returning full definition.
|
|
152
|
+
* Returns first matching definition — use lookupExactAll for overloaded methods.
|
|
153
|
+
*/
|
|
154
|
+
lookupExactFull: (filePath: string, name: string) => SymbolDefinition | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* High Confidence: Look for ALL symbols with this name in a specific file.
|
|
157
|
+
* Returns all definitions, including overloaded methods with the same name.
|
|
158
|
+
* The returned array is a view into the live internal index — callers
|
|
159
|
+
* MUST NOT mutate it. Use `readonly` to enforce this at the type level.
|
|
160
|
+
*/
|
|
161
|
+
lookupExactAll: (filePath: string, name: string) => readonly SymbolDefinition[];
|
|
162
|
+
/**
|
|
163
|
+
* Look up callable symbols (Function, Macro, Delegate) by name.
|
|
164
|
+
* O(1) via dedicated eagerly-populated index keyed by symbol name.
|
|
165
|
+
* Returned array is a view into the live index — do not mutate.
|
|
166
|
+
*/
|
|
167
|
+
lookupCallableByName: (name: string) => readonly SymbolDefinition[];
|
|
168
|
+
/**
|
|
169
|
+
* Iterate all indexed file paths.
|
|
170
|
+
* Used by Tier 2b (package-scoped) resolution to walk files matching a
|
|
171
|
+
* package directory suffix without a global name scan.
|
|
172
|
+
*/
|
|
173
|
+
getFiles: () => IterableIterator<string>;
|
|
174
|
+
/**
|
|
175
|
+
* Debugging: See how many files are tracked.
|
|
176
|
+
*/
|
|
177
|
+
getStats: () => {
|
|
178
|
+
fileCount: number;
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Writer view — reads + symbol registration. Does NOT include `clear()`.
|
|
183
|
+
*
|
|
184
|
+
* `MutableSemanticModel.symbols` is typed as this interface, so the
|
|
185
|
+
* lifecycle owner can register symbols and query them. Full-model
|
|
186
|
+
* resets flow through `model.clear()`.
|
|
187
|
+
*
|
|
188
|
+
* The cascading `clear()` capability lives exclusively on the internal
|
|
189
|
+
* factory return type ({@link createSymbolTable}) — a private handle
|
|
190
|
+
* held only by `SemanticModel` via `rawSymbols`.
|
|
191
|
+
*/
|
|
192
|
+
export interface SymbolTableWriter extends SymbolTableReader {
|
|
193
|
+
/**
|
|
194
|
+
* Register a symbol in the file and (if callable) name-keyed indexes.
|
|
195
|
+
*
|
|
196
|
+
* Returns the constructed {@link SymbolDefinition} so higher-layer
|
|
197
|
+
* wrappers (e.g. `createSemanticModel`) can reuse it without rebuilding
|
|
198
|
+
* the def. This keeps the fan-out in one allocation.
|
|
199
|
+
*/
|
|
200
|
+
add: (filePath: string, name: string, nodeId: string, type: NodeLabel, metadata?: AddMetadata) => SymbolDefinition;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Internal return type for {@link createSymbolTable} — extends the
|
|
204
|
+
* writer with `clear()`. This capability is intentionally NOT exported
|
|
205
|
+
* as a named interface; consumers should hold a `SymbolTableReader` or
|
|
206
|
+
* `SymbolTableWriter` instead.
|
|
207
|
+
*
|
|
208
|
+
* `SemanticModel`'s constructor is the only caller of `createSymbolTable`,
|
|
209
|
+
* and it retains the returned handle as the private `rawSymbols`
|
|
210
|
+
* reference so `cascadeClear` can reach `clear()`. Every other consumer
|
|
211
|
+
* receives the narrower `SymbolTableWriter` facade on `model.symbols`.
|
|
212
|
+
*/
|
|
213
|
+
interface InternalSymbolTable extends SymbolTableWriter {
|
|
214
|
+
/**
|
|
215
|
+
* Cleanup memory. Clears only the file and callable indexes owned here —
|
|
216
|
+
* owner-scoped registries are cleared by their respective owners via
|
|
217
|
+
* `model.clear()`.
|
|
218
|
+
*/
|
|
219
|
+
clear: () => void;
|
|
220
|
+
}
|
|
221
|
+
export declare const createSymbolTable: () => InternalSymbolTable;
|
|
222
|
+
export {};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Symbol Table — file-indexed + callable-name symbol storage.
|
|
3
|
+
*
|
|
4
|
+
* This module is a PURE LEAF in the ingestion dependency hierarchy. It owns
|
|
5
|
+
* two orthogonal O(1) indexes:
|
|
6
|
+
*
|
|
7
|
+
* 1. fileIndex — Map<filePath, Map<name, SymbolDefinition[]>>
|
|
8
|
+
* for same-file lookups (Tier 1 resolution)
|
|
9
|
+
* 2. callableByName — Map<name, SymbolDefinition[]>
|
|
10
|
+
* for name-keyed callable lookups (Tier 3 widen)
|
|
11
|
+
*
|
|
12
|
+
* SymbolTable deliberately knows NOTHING about the owner-scoped registries
|
|
13
|
+
* (types, methods, fields) that sit above it in the dependency graph. Those
|
|
14
|
+
* registries live in `model/` and depend on SymbolTable, not the other way
|
|
15
|
+
* around. {@link createSemanticModel} composes this pure SymbolTable with the
|
|
16
|
+
* registries and wraps `add()` to fan out registrations into both layers.
|
|
17
|
+
*
|
|
18
|
+
* Dependency direction (strictly enforced):
|
|
19
|
+
*
|
|
20
|
+
* gitnexus-shared (NodeLabel) — leaf type
|
|
21
|
+
* ↑
|
|
22
|
+
* symbol-table.ts — THIS FILE (pure storage)
|
|
23
|
+
* ↑
|
|
24
|
+
* model/type-registry.ts, method-registry.ts, field-registry.ts
|
|
25
|
+
* ↑
|
|
26
|
+
* model/registration-table.ts — dispatch table factory
|
|
27
|
+
* ↑
|
|
28
|
+
* model/semantic-model.ts — orchestrator, wraps add()
|
|
29
|
+
* ↑
|
|
30
|
+
* model/resolve.ts, call-processor.ts, resolution-context.ts, ...
|
|
31
|
+
*
|
|
32
|
+
* No arrow ever points downward from this file. If you are tempted to
|
|
33
|
+
* import from `./model/` here, you are going the wrong way — move the
|
|
34
|
+
* logic up the dependency chain instead.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Class-like NodeLabels — used for qualifiedName fallback inside
|
|
38
|
+
* `SymbolTable.add()` and (via import into `model/registration-table.ts`)
|
|
39
|
+
* as the single source of truth for which labels route to classHook
|
|
40
|
+
* in the dispatch table.
|
|
41
|
+
*
|
|
42
|
+
* Exported as a `readonly` tuple so that `typeof CLASS_TYPES_TUPLE[number]`
|
|
43
|
+
* yields a precise literal union (`ClassLikeLabel`). The model layer
|
|
44
|
+
* imports this tuple and uses `Record<ClassLikeLabel, 'dispatch'>` in a
|
|
45
|
+
* `satisfies` intersection to enforce at COMPILE TIME that every label
|
|
46
|
+
* listed here is also classified as dispatch in `LABEL_BEHAVIOR`. Adding
|
|
47
|
+
* a new class-like label to this tuple without updating `LABEL_BEHAVIOR`
|
|
48
|
+
* fails TypeScript.
|
|
49
|
+
*
|
|
50
|
+
* Traits are class-like for heritage resolution: PHP `use Trait;`, Rust
|
|
51
|
+
* `impl Trait for Struct`, and Scala traits all contribute methods to the
|
|
52
|
+
* hierarchy of their using/implementing type.
|
|
53
|
+
*/
|
|
54
|
+
export const CLASS_TYPES_TUPLE = [
|
|
55
|
+
'Class',
|
|
56
|
+
'Struct',
|
|
57
|
+
'Interface',
|
|
58
|
+
'Enum',
|
|
59
|
+
'Record',
|
|
60
|
+
'Trait',
|
|
61
|
+
];
|
|
62
|
+
export const CLASS_TYPES = new Set(CLASS_TYPES_TUPLE);
|
|
63
|
+
/** Free-callable labels — single source of truth for "callables that have
|
|
64
|
+
* NO owner scope". Methods and constructors are owner-scoped and live in
|
|
65
|
+
* `MethodRegistry` — Tier 3 reaches them via
|
|
66
|
+
* `model.methods.lookupMethodByName`. See `resolution-context.ts` Tier 3
|
|
67
|
+
* for how both indexes are consulted together.
|
|
68
|
+
*
|
|
69
|
+
* Exported as a `readonly` tuple so that `typeof FREE_CALLABLE_TUPLE[number]`
|
|
70
|
+
* yields a precise literal union (`FreeCallableLabel`). `registration-table.ts`
|
|
71
|
+
* imports this type and uses `Record<FreeCallableLabel, 'callable-only'>` in
|
|
72
|
+
* a `satisfies` intersection to enforce at COMPILE TIME that every label
|
|
73
|
+
* listed here is also classified as `callable-only` in `LABEL_BEHAVIOR`.
|
|
74
|
+
* Adding a label to this tuple without updating `LABEL_BEHAVIOR` fails
|
|
75
|
+
* TypeScript.
|
|
76
|
+
*
|
|
77
|
+
* Partial-state caveat: Python/Rust/Kotlin class methods are emitted by
|
|
78
|
+
* the worker as `Function` + `ownerId` (not `Method`), so they still land
|
|
79
|
+
* here via the `Function` entry. Collapsing those three languages onto the
|
|
80
|
+
* `Method` label is pending a `def.type` preservation decision.
|
|
81
|
+
*/
|
|
82
|
+
export const FREE_CALLABLE_TUPLE = [
|
|
83
|
+
'Function',
|
|
84
|
+
'Macro', // C/C++
|
|
85
|
+
'Delegate', // C#
|
|
86
|
+
];
|
|
87
|
+
export const FREE_CALLABLE_TYPES = new Set(FREE_CALLABLE_TUPLE);
|
|
88
|
+
/** Symbol types that can be the TARGET of a call in the resolver's kind
|
|
89
|
+
* filter — superset of {@link FREE_CALLABLE_TYPES} that also admits
|
|
90
|
+
* owner-scoped methods and constructors pulled in from `MethodRegistry`.
|
|
91
|
+
*
|
|
92
|
+
* Why the split: `FREE_CALLABLE_TYPES` now has a narrow meaning (free
|
|
93
|
+
* callables indexed in `callableByName`), but call resolution still
|
|
94
|
+
* needs to accept Method and Constructor candidates once they have been
|
|
95
|
+
* unioned in from `model.methods.lookupMethodByName`. The resolver uses
|
|
96
|
+
* this constant for kind filtering in
|
|
97
|
+
* `filterCallableCandidates` / `countCallableCandidates`.
|
|
98
|
+
*/
|
|
99
|
+
export const CALL_TARGET_TYPES = new Set([
|
|
100
|
+
...FREE_CALLABLE_TYPES,
|
|
101
|
+
'Method',
|
|
102
|
+
'Constructor',
|
|
103
|
+
]);
|
|
104
|
+
export const createSymbolTable = () => {
|
|
105
|
+
// 1. File-Specific Index — stores full SymbolDefinition(s) for O(1) lookup.
|
|
106
|
+
// Structure: FilePath -> (SymbolName -> SymbolDefinition[])
|
|
107
|
+
// Array allows overloaded methods (same name, different signatures) to coexist.
|
|
108
|
+
const fileIndex = new Map();
|
|
109
|
+
// 2. Eagerly-populated Callable Index — maintained on add().
|
|
110
|
+
// Structure: SymbolName -> [Callable Definitions]
|
|
111
|
+
// Only Function, Method, Constructor, Macro, Delegate symbols are indexed.
|
|
112
|
+
const callableByName = new Map();
|
|
113
|
+
const add = (filePath, name, nodeId, type, metadata) => {
|
|
114
|
+
const qualifiedName = CLASS_TYPES.has(type)
|
|
115
|
+
? (metadata?.qualifiedName ?? name)
|
|
116
|
+
: metadata?.qualifiedName;
|
|
117
|
+
const def = {
|
|
118
|
+
nodeId,
|
|
119
|
+
filePath,
|
|
120
|
+
type,
|
|
121
|
+
...(qualifiedName !== undefined ? { qualifiedName } : {}),
|
|
122
|
+
...(metadata?.parameterCount !== undefined
|
|
123
|
+
? { parameterCount: metadata.parameterCount }
|
|
124
|
+
: {}),
|
|
125
|
+
...(metadata?.requiredParameterCount !== undefined
|
|
126
|
+
? { requiredParameterCount: metadata.requiredParameterCount }
|
|
127
|
+
: {}),
|
|
128
|
+
...(metadata?.parameterTypes !== undefined
|
|
129
|
+
? { parameterTypes: metadata.parameterTypes }
|
|
130
|
+
: {}),
|
|
131
|
+
...(metadata?.returnType !== undefined ? { returnType: metadata.returnType } : {}),
|
|
132
|
+
...(metadata?.declaredType !== undefined ? { declaredType: metadata.declaredType } : {}),
|
|
133
|
+
...(metadata?.ownerId !== undefined ? { ownerId: metadata.ownerId } : {}),
|
|
134
|
+
};
|
|
135
|
+
// A. File Index — unconditional.
|
|
136
|
+
if (!fileIndex.has(filePath)) {
|
|
137
|
+
fileIndex.set(filePath, new Map());
|
|
138
|
+
}
|
|
139
|
+
const fileMap = fileIndex.get(filePath);
|
|
140
|
+
if (!fileMap.has(name)) {
|
|
141
|
+
fileMap.set(name, [def]);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
fileMap.get(name).push(def);
|
|
145
|
+
}
|
|
146
|
+
// B. Callable Index — gated by FREE_CALLABLE_TYPES.
|
|
147
|
+
// Note: Property is NOT in FREE_CALLABLE_TYPES, so it never lands here.
|
|
148
|
+
// This is the single source of truth for callable-index membership;
|
|
149
|
+
// the higher-layer dispatch table only decides owner-scoped routing.
|
|
150
|
+
//
|
|
151
|
+
// Fallback: `Method` or `Constructor` without an `ownerId` is an
|
|
152
|
+
// extractor contract violation (AST-degraded parse, or a buggy
|
|
153
|
+
// language extractor). The owner-scoped dispatch hook silently
|
|
154
|
+
// skips such defs because it has no owner to key them under, so
|
|
155
|
+
// without this fallback they would be invisible at Tier 3 global
|
|
156
|
+
// resolution. Route them through `callableByName` so they remain
|
|
157
|
+
// reachable by name — matching pre-dispatch-table behavior.
|
|
158
|
+
const isOrphanedOwnerScoped = (type === 'Method' || type === 'Constructor') && metadata?.ownerId === undefined;
|
|
159
|
+
if (FREE_CALLABLE_TYPES.has(type) || isOrphanedOwnerScoped) {
|
|
160
|
+
const existing = callableByName.get(name);
|
|
161
|
+
if (existing) {
|
|
162
|
+
existing.push(def);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
callableByName.set(name, [def]);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return def;
|
|
169
|
+
};
|
|
170
|
+
const lookupExact = (filePath, name) => {
|
|
171
|
+
const defs = fileIndex.get(filePath)?.get(name);
|
|
172
|
+
return defs?.[0]?.nodeId;
|
|
173
|
+
};
|
|
174
|
+
const lookupExactFull = (filePath, name) => {
|
|
175
|
+
const defs = fileIndex.get(filePath)?.get(name);
|
|
176
|
+
return defs?.[0];
|
|
177
|
+
};
|
|
178
|
+
const lookupExactAll = (filePath, name) => {
|
|
179
|
+
return fileIndex.get(filePath)?.get(name) ?? [];
|
|
180
|
+
};
|
|
181
|
+
const lookupCallableByName = (name) => {
|
|
182
|
+
return callableByName.get(name) ?? [];
|
|
183
|
+
};
|
|
184
|
+
/** Returns a live iterator over all indexed file paths (fileIndex.keys()).
|
|
185
|
+
* The iterator is invalidated if add() changes fileIndex.size during
|
|
186
|
+
* iteration (ES2015 Map spec). Safe in the current pipeline because all
|
|
187
|
+
* symbols are added before resolution begins. */
|
|
188
|
+
const getFiles = () => fileIndex.keys();
|
|
189
|
+
const getStats = () => ({
|
|
190
|
+
fileCount: fileIndex.size,
|
|
191
|
+
});
|
|
192
|
+
const clear = () => {
|
|
193
|
+
fileIndex.clear();
|
|
194
|
+
callableByName.clear();
|
|
195
|
+
};
|
|
196
|
+
return {
|
|
197
|
+
add,
|
|
198
|
+
lookupExact,
|
|
199
|
+
lookupExactFull,
|
|
200
|
+
lookupExactAll,
|
|
201
|
+
lookupCallableByName,
|
|
202
|
+
getFiles,
|
|
203
|
+
getStats,
|
|
204
|
+
clear,
|
|
205
|
+
};
|
|
206
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Registry
|
|
3
|
+
*
|
|
4
|
+
* Class/struct/interface index extracted from SymbolTable.
|
|
5
|
+
* Eagerly-populated indexes keyed by symbol name and qualified name.
|
|
6
|
+
* Also includes a separate index for Rust Impl blocks.
|
|
7
|
+
*/
|
|
8
|
+
import type { SymbolDefinition } from './symbol-table.js';
|
|
9
|
+
export interface TypeRegistry {
|
|
10
|
+
/**
|
|
11
|
+
* Look up class-like definitions (Class, Struct, Interface, Enum, Record, Trait)
|
|
12
|
+
* by simple name. Returns all matching definitions across files
|
|
13
|
+
* (e.g. partial classes). Returned array is a view into the live
|
|
14
|
+
* internal index — do not mutate.
|
|
15
|
+
*/
|
|
16
|
+
lookupClassByName(name: string): readonly SymbolDefinition[];
|
|
17
|
+
/**
|
|
18
|
+
* Look up class-like definitions by canonical qualified name.
|
|
19
|
+
* Qualified names are normalized to dot-separated scope segments across languages,
|
|
20
|
+
* e.g. `App.Models.User`, `com.example.User`, or `Admin.User`.
|
|
21
|
+
* Returned array is a view into the live index — do not mutate.
|
|
22
|
+
*/
|
|
23
|
+
lookupClassByQualifiedName(qualifiedName: string): readonly SymbolDefinition[];
|
|
24
|
+
/**
|
|
25
|
+
* Look up Impl nodes by name. Used by Tier 3 resolution to include Rust
|
|
26
|
+
* impl blocks alongside class-like candidates.
|
|
27
|
+
* Returned array is a view into the live index — do not mutate.
|
|
28
|
+
*/
|
|
29
|
+
lookupImplByName(name: string): readonly SymbolDefinition[];
|
|
30
|
+
}
|
|
31
|
+
export interface MutableTypeRegistry extends TypeRegistry {
|
|
32
|
+
/** Register a class-like type by name and qualified name. */
|
|
33
|
+
registerClass(name: string, qualifiedName: string, def: SymbolDefinition): void;
|
|
34
|
+
/** Register a Rust Impl block by name. */
|
|
35
|
+
registerImpl(name: string, def: SymbolDefinition): void;
|
|
36
|
+
/** Clear all entries. */
|
|
37
|
+
clear(): void;
|
|
38
|
+
}
|
|
39
|
+
export declare const createTypeRegistry: () => MutableTypeRegistry;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Registry
|
|
3
|
+
*
|
|
4
|
+
* Class/struct/interface index extracted from SymbolTable.
|
|
5
|
+
* Eagerly-populated indexes keyed by symbol name and qualified name.
|
|
6
|
+
* Also includes a separate index for Rust Impl blocks.
|
|
7
|
+
*/
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Factory
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
export const createTypeRegistry = () => {
|
|
12
|
+
const classByName = new Map();
|
|
13
|
+
const classByQualifiedName = new Map();
|
|
14
|
+
const implByName = new Map();
|
|
15
|
+
const lookupClassByName = (name) => {
|
|
16
|
+
return classByName.get(name) ?? [];
|
|
17
|
+
};
|
|
18
|
+
const lookupClassByQualifiedName = (qualifiedName) => {
|
|
19
|
+
return classByQualifiedName.get(qualifiedName) ?? [];
|
|
20
|
+
};
|
|
21
|
+
const lookupImplByName = (name) => {
|
|
22
|
+
return implByName.get(name) ?? [];
|
|
23
|
+
};
|
|
24
|
+
const registerClass = (name, qualifiedName, def) => {
|
|
25
|
+
const existing = classByName.get(name);
|
|
26
|
+
if (existing) {
|
|
27
|
+
existing.push(def);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
classByName.set(name, [def]);
|
|
31
|
+
}
|
|
32
|
+
const qualifiedMatches = classByQualifiedName.get(qualifiedName);
|
|
33
|
+
if (qualifiedMatches) {
|
|
34
|
+
qualifiedMatches.push(def);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
classByQualifiedName.set(qualifiedName, [def]);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const registerImpl = (name, def) => {
|
|
41
|
+
const existing = implByName.get(name);
|
|
42
|
+
if (existing) {
|
|
43
|
+
existing.push(def);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
implByName.set(name, [def]);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const clear = () => {
|
|
50
|
+
classByName.clear();
|
|
51
|
+
classByQualifiedName.clear();
|
|
52
|
+
implByName.clear();
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
lookupClassByName,
|
|
56
|
+
lookupClassByQualifiedName,
|
|
57
|
+
lookupImplByName,
|
|
58
|
+
registerClass,
|
|
59
|
+
registerImpl,
|
|
60
|
+
clear,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MRO (Method Resolution Order) Processor
|
|
3
3
|
*
|
|
4
|
-
* Walks the inheritance
|
|
4
|
+
* Walks the inheritance graph (EXTENDS/IMPLEMENTS edges), collects methods from
|
|
5
5
|
* each ancestor via HAS_METHOD edges, detects method-name collisions across
|
|
6
|
-
* parents, and applies language-specific resolution rules to emit
|
|
6
|
+
* parents, and applies language-specific resolution rules to emit METHOD_OVERRIDES edges.
|
|
7
7
|
*
|
|
8
8
|
* Language-specific rules:
|
|
9
9
|
* - C++: leftmost base class in declaration order wins
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
* - Rust: no auto-resolution — requires qualified syntax, resolvedTo = null
|
|
14
14
|
* - Default: single inheritance — first definition wins
|
|
15
15
|
*
|
|
16
|
-
*
|
|
16
|
+
* METHOD_OVERRIDES edge direction: Class → Method (not Method → Method).
|
|
17
17
|
* The source is the child class that inherits conflicting methods,
|
|
18
18
|
* the target is the winning ancestor method node.
|
|
19
|
-
* Cypher: MATCH (c:Class)-[r:CodeRelation {type: '
|
|
19
|
+
* Cypher: MATCH (c:Class)-[r:CodeRelation {type: 'METHOD_OVERRIDES'}]->(m:Method)
|
|
20
20
|
*/
|
|
21
21
|
import { KnowledgeGraph } from '../graph/types.js';
|
|
22
22
|
import { SupportedLanguages } from '../../_shared/index.js';
|
|
@@ -41,5 +41,6 @@ export interface MROResult {
|
|
|
41
41
|
entries: MROEntry[];
|
|
42
42
|
overrideEdges: number;
|
|
43
43
|
ambiguityCount: number;
|
|
44
|
+
methodImplementsEdges: number;
|
|
44
45
|
}
|
|
45
46
|
export declare function computeMRO(graph: KnowledgeGraph): MROResult;
|