@hydranium/core 1.0.0-next.356 → 1.0.0-next.358

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.
@@ -12,8 +12,9 @@
12
12
  *
13
13
  * **These live beside the key provider because the constraint is the key
14
14
  * provider's.** `NameBasedKeyProvider` keys a node the `NameProvider` gives no
15
- * name from its position, as `` `${$containerProperty}@${$containerIndex}` ``,
16
- * so a node appended with a bare `array.push` carries neither and
15
+ * name from its position, as `` `${$containerProperty}@${$containerIndex}` ``
16
+ * (`` `${$containerProperty}@` `` in a single-valued property), so a node
17
+ * appended with a bare `array.push` carries neither and
17
18
  * `getElementKey` answers `undefined` — the element has no key at all, and the
18
19
  * GLSP index cannot address it. Deleting from the middle of such a list must
19
20
  * renumber the survivors, or an id derived later in the same command names the
@@ -1 +1 @@
1
- {"version":3,"file":"containment.d.ts","sourceRoot":"","sources":["../../../src/langium/keys/containment.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAS,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAOnI;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,SAAS,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAYhH"}
1
+ {"version":3,"file":"containment.d.ts","sourceRoot":"","sources":["../../../src/langium/keys/containment.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,O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O,EAAE,EAAE,CAAC;QAC/C,KAAyB,CAAC,eAAe,GAAG,KAAK,CAAC;QACnD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,OAAO,CAAC;AAClB,CAAC"}
@@ -42,20 +42,25 @@ import { type NameProvider } from '../naming/name-provider.js';
42
42
  * `NameProvider` gives no name. For grammars with unnamed element types the
43
43
  * reorder / insert / delete stability above does NOT apply to those nodes:
44
44
  * their keys move when their index moves, so a mid-array insert or delete
45
- * renumbers every later sibling.
45
+ * renumbers every later sibling. A node held in a single-valued property has
46
+ * no `$containerIndex` and falls back to `` `${$containerProperty}@` ``; the
47
+ * trailing `@` keeps its key apart from a sibling named after the property.
46
48
  *
47
49
  * Two consequences for a caller creating such nodes programmatically
48
50
  * (a GLSP operation handler is the usual case):
49
51
  *
50
- * - A node appended with a bare `array.push` has no `$containerProperty` /
51
- * `$containerIndex`, so `getElementKey` returns `undefined` and the node
52
- * has no key at all. The containment plumbing has to be stamped.
52
+ * - A node appended with a bare `array.push`, or assigned to a single-valued
53
+ * property without its `$containerProperty`, has no container position, so
54
+ * `getElementKey` returns `undefined` and the node has no key at all. The
55
+ * containment plumbing has to be stamped.
53
56
  * - After a removal, surviving siblings need their `$containerIndex`
54
57
  * renumbered, or a key derived afterwards addresses the wrong node.
55
58
  *
56
- * {@link appendChild} and {@link removeChildren} discharge both, and ship
57
- * beside this provider because the constraint is this provider's rather than
58
- * any caller's.
59
+ * {@link appendChild} and {@link removeChildren} discharge both for arrays,
60
+ * and ship beside this provider because the constraint is this provider's
61
+ * rather than any caller's. A single-valued property needs no helper: build
62
+ * the node with its `$container` and `$containerProperty`, which
63
+ * `buildAstNode` accepts.
59
64
  *
60
65
  * Adopters that need insert / delete stability for unnamed types should
61
66
  * give those types a name in the grammar, or bind a key provider whose
@@ -94,9 +99,11 @@ export declare class NameBasedKeyProvider implements ElementKeyProvider {
94
99
  */
95
100
  protected isSemanticRoot(node: AstNode): boolean;
96
101
  /**
97
- * Fallback segment for unnamed intermediate ancestors —
98
- * `containerProperty@containerIndex`. Returns `undefined` when the
99
- * node has no container position, which short-circuits the walk.
102
+ * Segment for a node the `NameProvider` gives no name —
103
+ * `containerProperty@containerIndex`, or `containerProperty@` when the
104
+ * container holds no array in that property, attached or not. Returns
105
+ * `undefined` when the node has no container position: the node itself
106
+ * then has no key, and an ancestor's level is left out of the key.
100
107
  */
101
108
  protected unidentifiedSegment(node: AstNode): string | undefined;
102
109
  }
@@ -1 +1 @@
1
- {"version":3,"file":"name-based-key-provider.d.ts","sourceRoot":"","sources":["../../../src/langium/keys/name-based-key-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,KAAK,kBAAkB,EAAwB,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,qBAAa,oBAAqB,YAAW,kBAAkB;IAKzD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,sBAAsB;IAJtD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAC9C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAElC,YACsB,QAAQ,EAAE,sBAAsB,EACnD,OAAO,GAAE,cAAmB,EAI9B;IAED,aAAa,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAqBhD;IAED;;;;;;;OAOG;IACH,cAAc,CAAC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G,OAAO,GAAG,SAAS,CAEjE;IAED;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAQ/C;IAED;;;;;;OAMG;IACH,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAU/D;CACH"}
@@ -37,20 +37,25 @@ import { resolveElementByScan } from './element-key-provider.js';
37
37
  * `NameProvider` gives no name. For grammars with unnamed element types the
38
38
  * reorder / insert / delete stability above does NOT apply to those nodes:
39
39
  * their keys move when their index moves, so a mid-array insert or delete
40
- * renumbers every later sibling.
40
+ * renumbers every later sibling. A node held in a single-valued property has
41
+ * no `$containerIndex` and falls back to `` `${$containerProperty}@` ``; the
42
+ * trailing `@` keeps its key apart from a sibling named after the property.
41
43
  *
42
44
  * Two consequences for a caller creating such nodes programmatically
43
45
  * (a GLSP operation handler is the usual case):
44
46
  *
45
- * - A node appended with a bare `array.push` has no `$containerProperty` /
46
- * `$containerIndex`, so `getElementKey` returns `undefined` and the node
47
- * has no key at all. The containment plumbing has to be stamped.
47
+ * - A node appended with a bare `array.push`, or assigned to a single-valued
48
+ * property without its `$containerProperty`, has no container position, so
49
+ * `getElementKey` returns `undefined` and the node has no key at all. The
50
+ * containment plumbing has to be stamped.
48
51
  * - After a removal, surviving siblings need their `$containerIndex`
49
52
  * renumbered, or a key derived afterwards addresses the wrong node.
50
53
  *
51
- * {@link appendChild} and {@link removeChildren} discharge both, and ship
52
- * beside this provider because the constraint is this provider's rather than
53
- * any caller's.
54
+ * {@link appendChild} and {@link removeChildren} discharge both for arrays,
55
+ * and ship beside this provider because the constraint is this provider's
56
+ * rather than any caller's. A single-valued property needs no helper: build
57
+ * the node with its `$container` and `$containerProperty`, which
58
+ * `buildAstNode` accepts.
54
59
  *
55
60
  * Adopters that need insert / delete stability for unnamed types should
56
61
  * give those types a name in the grammar, or bind a key provider whose
@@ -124,15 +129,22 @@ export class NameBasedKeyProvider {
124
129
  return false;
125
130
  }
126
131
  /**
127
- * Fallback segment for unnamed intermediate ancestors —
128
- * `containerProperty@containerIndex`. Returns `undefined` when the
129
- * node has no container position, which short-circuits the walk.
132
+ * Segment for a node the `NameProvider` gives no name —
133
+ * `containerProperty@containerIndex`, or `containerProperty@` when the
134
+ * container holds no array in that property, attached or not. Returns
135
+ * `undefined` when the node has no container position: the node itself
136
+ * then has no key, and an ancestor's level is left out of the key.
130
137
  */
131
138
  unidentifiedSegment(node) {
132
- if (node.$containerProperty === undefined || node.$containerIndex === undefined) {
139
+ const property = node.$containerProperty;
140
+ if (property === undefined) {
133
141
  return undefined;
134
142
  }
135
- return `${node.$containerProperty}@${node.$containerIndex}`;
143
+ if (node.$containerIndex !== undefined) {
144
+ return `${property}@${node.$containerIndex}`;
145
+ }
146
+ // An array member without its index stays keyless rather than share `property@` with its siblings.
147
+ return Array.isArray(node.$container?.[property]) ? undefined : `${property}@`;
136
148
  }
137
149
  }
138
150
  //# sourceMappingURL=name-based-key-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"name-based-key-provider.js","sourceRoot":"","sources":["../../../src/langium/keys/name-based-key-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAMlF,OAAO,EAA2B,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAG1F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,OAAO,oBAAoB;IAKR,QAAQ;IAJX,YAAY,CAAe;IAC3B,MAAM,CAAS;IAElC,YACsB,QAAgC,EACnD,OAAO,GAAmB,EAAE;wBADT,QAAQ;QAG3B,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC;QACrD,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAA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C,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,KAAK,CAAC;IAChB,CAAC;IAED;;;;;;OAMG;IACO,mBAAmB,CAAC,IAAa;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC;QACzC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,SAAS,CAAC;QACpB,CAAC;QACD,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YACtC,OAAO,GAAG,QAAQ,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QAChD,CAAC;QACD,mGAAmG;QACnG,OAAO,KAAK,CAAC,OAAO,CAAE,IAAI,CAAC,UAAkD,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC;IAC3H,CAAC;CACH"}
@@ -90,8 +90,9 @@ export declare function isCstShed(document: LangiumDocument): boolean;
90
90
  * the idle window of the documents in its batch; when a closed, sheddable
91
91
  * document's window elapses, every AST node's `$cstNode` and every reference's
92
92
  * `$refNode` are nulled, and the CST becomes unreachable with the `Range`s
93
- * and `Position`s only it holds. A description's segments and the reference
94
- * index's segments share the CST's `Range` objects, so those stay.
93
+ * and `Position`s only it holds. The reference index's segments, and a
94
+ * description's segments once read, share the CST's `Range` objects, so
95
+ * those stay.
95
96
  *
96
97
  * **Terminology.** *Residency* is the state axis (is the CST in memory? —
97
98
  * `resident` vs `shed`); *shed* is both the act and the policy vocabulary (drop
@@ -142,7 +143,8 @@ export interface CstResidencyService {
142
143
  /**
143
144
  * Node-level convenience over {@link rehydrate}, cheap enough for an
144
145
  * unconditional call: a node whose `$cstNode` is already set returns
145
- * without resolving its document.
146
+ * without resolving its document, and a node outside any document, such as
147
+ * a detached synthetic node, has nothing to restore and returns too.
146
148
  */
147
149
  rehydrateNode(node: AstNode): void;
148
150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,EAAE,OAAO,GAAG,IAAI,CAQjC;IAED;;;;;;;;OAQG;IACH,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,GAAG,IAAI,CAe7D;IAED;;;;;OAKG;IACH,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAQ7C;IAED;;;;;OAKG;IACH,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CASlC;IAED,+EAA+E;IAC/E,iBAAiB,IAAI,IAAI,CAKxB;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAExD;IAED;;;;OAIG;IACH,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CA8BhD;IAED;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAElD;CACH"}
@@ -191,7 +191,10 @@ export class DefaultCstResidencyService {
191
191
  if (node.$cstNode !== undefined) {
192
192
  return;
193
193
  }
194
- this.rehydrate(AstUtils.getDocument(node));
194
+ const document = AstUtils.findRootNode(node).$document;
195
+ if (document) {
196
+ this.rehydrate(document);
197
+ }
195
198
  }
196
199
  /**
197
200
  * After each build, refresh the idle timer of every document in the batch: an
@@ -1 +1 @@
1
- {"version":3,"file":"cst-residency-service.js","sourceRoot":"","sources":["../../../src/langium/residency/cst-residency-service.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,SAAS,EAAc,SAAS,EAAE,MAAM,EAAe,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAChH,OAAO,EAEJ,QAAQ,EACR,aAAa,EAIb,GAAG,EACL,MAAM,oBAAoB,CAAC;AAK5B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,CAAC;AAuCrD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,2B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C;YAClC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACrD,CAAC;QACD,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3C,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAChB,IAA+B,CAAC,QAAQ,GAAG,SAAS,CAAC;gBACtD,OAAO,EAAE,CAAC;YACb,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;YACjD,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;gBACrB,SAAoC,CAAC,QAAQ,GAAG,SAAS,CAAC;YAC9D,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,OAAO,SAAS,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAChH,CAAC;QACD,OAAO,OAAO,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACO,cAAc,CAAC,SAAiB;QACvC,OAAO,IAAI,CAAC,yBAAyB,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;IACrI,CAAC;CACH"}
1
+ {"version":3,"file":"cst-residency-service.js","sourceRoot":"","sources":["../../../src/langium/residency/cst-residency-service.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,SAAS,EAAc,SAAS,EAAE,MAAM,EAAe,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAChH,O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,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;IACrI,CAAC;CACH"}
@@ -7,7 +7,7 @@
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
9
  import { type Tracer } from '@hydranium/protocol';
10
- import { type AstNode, type AstNodeDescription, DefaultAstNodeDescriptionProvider, type LangiumDocument } from '@hydranium/langium';
10
+ import { type AstNode, DefaultAstNodeDescriptionProvider, type DocumentSegment, type LangiumDocument, type URI } from '@hydranium/langium';
11
11
  import type { LogNameOptions } from '../diagnostics/logger.js';
12
12
  import type { HydraniumLanguageServices } from '../language-module.js';
13
13
  import { type DescriptionTier, type TieredAstNodeDescription } from './scoped-ast-node-description.js';
@@ -30,6 +30,7 @@ import { type DescriptionTier, type TieredAstNodeDescription } from './scoped-as
30
30
  */
31
31
  export declare class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescriptionProvider {
32
32
  protected readonly tracer: Tracer;
33
+ protected readonly services: HydraniumLanguageServices;
33
34
  constructor(services: HydraniumLanguageServices, options?: LogNameOptions);
34
35
  /**
35
36
  * Overrides the Langium base to stamp `tier: 'local'` on every plain
@@ -37,11 +38,10 @@ export declare class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeD
37
38
  * filter pipeline. Callers that need a different tier must use
38
39
  * {@link createProject}, {@link createPublic}, or {@link createUniversal}.
39
40
  *
40
- * The named factory methods bypass this override by calling
41
- * `super.createDescription` to get a plain base before stamping the
42
- * correct tier — so there is no create-then-overwrite cost.
41
+ * Langium's own `createDescription` is not called: every factory builds
42
+ * through {@link createTiered}.
43
43
  */
44
- createDescription(node: AstNode, name: string, document: LangiumDocument): TieredAstNodeDescription;
44
+ createDescription(node: AstNode, name: string | undefined, document?: LangiumDocument): TieredAstNodeDescription;
45
45
  /**
46
46
  * Build a {@link TieredAstNodeDescription} for a symbol visible only
47
47
  * inside its document. Goes into the per-document local-symbols map
@@ -112,11 +112,47 @@ export declare class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeD
112
112
  readonly document: LangiumDocument;
113
113
  }): TieredAstNodeDescription;
114
114
  /**
115
- * Attach `tier` + `projectId` fields to a plain {@link AstNodeDescription}
116
- * in place, narrowing the static type to {@link TieredAstNodeDescription}.
117
- * Mutates `base` rather than copying — the input is treated as
118
- * just-constructed and not aliased elsewhere.
115
+ * Resolve the fields of the description every factory returns and build it
116
+ * through {@link newDescription}. Mirrors Langium's `createDescription`:
117
+ * the name defaults to the name provider's, and a node without one throws.
119
118
  */
120
- protected toTiered(base: AstNodeDescription, tier: DescriptionTier, projectId?: string): TieredAstNodeDescription;
119
+ protected createTiered(node: AstNode, name: string | undefined, document: LangiumDocument | undefined, tier: DescriptionTier, projectId?: string): TieredAstNodeDescription;
120
+ /** Construct the description from resolved fields; override to build a subclass of {@link DefaultTieredAstNodeDescription}. */
121
+ protected newDescription(node: AstNode, name: string, documentUri: URI, path: string, tier: DescriptionTier, projectId: string | undefined): TieredAstNodeDescription;
122
+ /**
123
+ * The segment of `node`'s name, or of the whole node when the name
124
+ * provider finds no name node, restoring a shed CST first: a name provider
125
+ * need not restore it, and an absent segment is not computed again.
126
+ */
127
+ nameSegmentOf(node: AstNode): DocumentSegment | undefined;
128
+ /** The segment of the whole node, restoring a shed CST first. */
129
+ selectionSegmentOf(node: AstNode): DocumentSegment | undefined;
130
+ }
131
+ /**
132
+ * The description {@link HydraniumAstNodeDescriptionProvider} builds. Every
133
+ * field is set in the constructor, so all descriptions share one V8 hidden
134
+ * class; Langium's object literal with a `nameSegment` accessor is kept in
135
+ * dictionary mode and carries two closures, several times the bytes.
136
+ *
137
+ * `nameSegment` and `selectionSegment` are prototype getters, not own
138
+ * properties: a spread, `Object.keys`, a JSON round trip or `structuredClone`
139
+ * of a description drops them. Each is computed on its first read, from the
140
+ * node the description was built for, restoring a shed CST first; an eager
141
+ * `selectionSegment` would keep a segment per description that nothing reads.
142
+ */
143
+ export declare class DefaultTieredAstNodeDescription implements TieredAstNodeDescription {
144
+ protected readonly provider: HydraniumAstNodeDescriptionProvider;
145
+ readonly node: AstNode;
146
+ readonly name: string;
147
+ readonly documentUri: URI;
148
+ readonly path: string;
149
+ readonly tier: DescriptionTier;
150
+ readonly projectId: string | undefined;
151
+ readonly type: string;
152
+ protected nameSegmentCache: DocumentSegment | null | undefined;
153
+ protected selectionSegmentCache: DocumentSegment | null | undefined;
154
+ constructor(provider: HydraniumAstNodeDescriptionProvider, node: AstNode, name: string, documentUri: URI, path: string, tier: DescriptionTier, projectId: string | undefined);
155
+ get nameSegment(): DocumentSegment | undefined;
156
+ get selectionSegment(): DocumentSegment | undefined;
121
157
  }
122
158
  //# sourceMappingURL=ast-node-description-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ast-node-description-provider.d.ts","sourceRoot":"","sources":["../../../src/langium/scope/ast-node-description-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAE,iCAAiC,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACpI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAEvG;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,mCAAoC,SAAQ,iCAAiC;IACvF,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAElC,YAAY,QAAQ,EAAE,yBAAyB,EAAE,OAAO,GAAE,cAAmB,EAG5E;IAED;;;;;;;;;OASG;IACM,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,wBAAwB,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CAAC,WAAW,EAAE,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAdzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAItB,SAAS,CAAC,gBAAgB,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/D,SAAS,CAAC,qBAAqB,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;IAEpE,YACsB,QAAQ,EAAE,mCAAmC,EACvD,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,GAAG,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,eAAe,EACrB,SAAS,EAAE,MAAM,GAAG,SAAS,EAGxC;IAED,IAAI,WAAW,IAAI,eAAe,GAAG,SAAS,CAK7C;IAED,IAAI,gBAAgB,IAAI,eAAe,GAAG,SAAS,CAKlD;CACH"}
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * SPDX-License-Identifier: MIT
8
8
  ********************************************************************************/
9
- import { DefaultAstNodeDescriptionProvider } from '@hydranium/langium';
9
+ import { AstUtils, CstUtils, DefaultAstNodeDescriptionProvider } from '@hydranium/langium';
10
10
  /**
11
11
  * Framework `AstNodeDescriptionProvider` extension. Adds four typed
12
12
  * factory methods aligned with the {@link TieredAstNodeDescription} four-
@@ -26,8 +26,10 @@ import { DefaultAstNodeDescriptionProvider } from '@hydranium/langium';
26
26
  */
27
27
  export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescriptionProvider {
28
28
  tracer;
29
+ services;
29
30
  constructor(services, options = {}) {
30
31
  super(services);
32
+ this.services = services;
31
33
  this.tracer = services.shared.Tracer.for(options.logName ?? 'AstNodeDescriptionProvider').trace('instantiated');
32
34
  }
33
35
  /**
@@ -36,12 +38,11 @@ export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescripti
36
38
  * filter pipeline. Callers that need a different tier must use
37
39
  * {@link createProject}, {@link createPublic}, or {@link createUniversal}.
38
40
  *
39
- * The named factory methods bypass this override by calling
40
- * `super.createDescription` to get a plain base before stamping the
41
- * correct tier — so there is no create-then-overwrite cost.
41
+ * Langium's own `createDescription` is not called: every factory builds
42
+ * through {@link createTiered}.
42
43
  */
43
44
  createDescription(node, name, document) {
44
- return this.toTiered(super.createDescription(node, name, document), 'local');
45
+ return this.createTiered(node, name, document, 'local');
45
46
  }
46
47
  /**
47
48
  * Build a {@link TieredAstNodeDescription} for a symbol visible only
@@ -53,7 +54,7 @@ export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescripti
53
54
  * never sees them, so a project tag would be unused.
54
55
  */
55
56
  createLocal(options) {
56
- return this.toTiered(super.createDescription(options.node, options.name, options.document), 'local');
57
+ return this.createTiered(options.node, options.name, options.document, 'local');
57
58
  }
58
59
  /**
59
60
  * Build a {@link TieredAstNodeDescription} for a symbol visible inside
@@ -69,7 +70,7 @@ export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescripti
69
70
  * `ProjectManager.getProject(document.uri)?.id` once per document.
70
71
  */
71
72
  createProject(options) {
72
- return this.toTiered(super.createDescription(options.node, options.name, options.document), 'project', options.projectId);
73
+ return this.createTiered(options.node, options.name, options.document, 'project', options.projectId);
73
74
  }
74
75
  /**
75
76
  * Build a {@link TieredAstNodeDescription} at `tier: 'public'` — the
@@ -87,7 +88,7 @@ export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescripti
87
88
  * one and a workspace-qualified one.
88
89
  */
89
90
  createPublic(options) {
90
- return this.toTiered(super.createDescription(options.node, options.name, options.document), 'public', options.projectId);
91
+ return this.createTiered(options.node, options.name, options.document, 'public', options.projectId);
91
92
  }
92
93
  /**
93
94
  * Build a {@link TieredAstNodeDescription} at `tier: 'universal'` —
@@ -100,16 +101,88 @@ export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescripti
100
101
  * {@link createPublic} instead.
101
102
  */
102
103
  createUniversal(options) {
103
- return this.toTiered(super.createDescription(options.node, options.name, options.document), 'universal');
104
+ return this.createTiered(options.node, options.name, options.document, 'universal');
104
105
  }
105
106
  /**
106
- * Attach `tier` + `projectId` fields to a plain {@link AstNodeDescription}
107
- * in place, narrowing the static type to {@link TieredAstNodeDescription}.
108
- * Mutates `base` rather than copying — the input is treated as
109
- * just-constructed and not aliased elsewhere.
107
+ * Resolve the fields of the description every factory returns and build it
108
+ * through {@link newDescription}. Mirrors Langium's `createDescription`:
109
+ * the name defaults to the name provider's, and a node without one throws.
110
110
  */
111
- toTiered(base, tier, projectId) {
112
- return Object.assign(base, { tier, projectId });
111
+ createTiered(node, name, document, tier, projectId) {
112
+ const path = this.astNodeLocator.getAstNodePath(node);
113
+ const resolvedName = name ?? this.nameProvider.getName(node);
114
+ if (!resolvedName) {
115
+ throw new Error(`Node at path ${path} has no name.`);
116
+ }
117
+ const documentUri = (document ?? AstUtils.getDocument(node)).uri;
118
+ return this.newDescription(node, resolvedName, documentUri, path, tier, projectId);
119
+ }
120
+ /** Construct the description from resolved fields; override to build a subclass of {@link DefaultTieredAstNodeDescription}. */
121
+ newDescription(node, name, documentUri, path, tier, projectId) {
122
+ return new DefaultTieredAstNodeDescription(this, node, name, documentUri, path, tier, projectId);
123
+ }
124
+ /**
125
+ * The segment of `node`'s name, or of the whole node when the name
126
+ * provider finds no name node, restoring a shed CST first: a name provider
127
+ * need not restore it, and an absent segment is not computed again.
128
+ */
129
+ nameSegmentOf(node) {
130
+ this.services.shared.workspace.CstResidencyService.rehydrateNode(node);
131
+ return CstUtils.toDocumentSegment(this.nameProvider.getNameNode(node) ?? node.$cstNode);
132
+ }
133
+ /** The segment of the whole node, restoring a shed CST first. */
134
+ selectionSegmentOf(node) {
135
+ this.services.shared.workspace.CstResidencyService.rehydrateNode(node);
136
+ return CstUtils.toDocumentSegment(node.$cstNode);
137
+ }
138
+ }
139
+ /**
140
+ * The description {@link HydraniumAstNodeDescriptionProvider} builds. Every
141
+ * field is set in the constructor, so all descriptions share one V8 hidden
142
+ * class; Langium's object literal with a `nameSegment` accessor is kept in
143
+ * dictionary mode and carries two closures, several times the bytes.
144
+ *
145
+ * `nameSegment` and `selectionSegment` are prototype getters, not own
146
+ * properties: a spread, `Object.keys`, a JSON round trip or `structuredClone`
147
+ * of a description drops them. Each is computed on its first read, from the
148
+ * node the description was built for, restoring a shed CST first; an eager
149
+ * `selectionSegment` would keep a segment per description that nothing reads.
150
+ */
151
+ export class DefaultTieredAstNodeDescription {
152
+ provider;
153
+ node;
154
+ name;
155
+ documentUri;
156
+ path;
157
+ tier;
158
+ projectId;
159
+ type;
160
+ // `null` records a segment computed while the node had no CST. It is
161
+ // recomputed only once the node has one again: retrying without one would
162
+ // attempt a restore, a re-parse, on every read.
163
+ nameSegmentCache;
164
+ selectionSegmentCache;
165
+ constructor(provider, node, name, documentUri, path, tier, projectId) {
166
+ this.provider = provider;
167
+ this.node = node;
168
+ this.name = name;
169
+ this.documentUri = documentUri;
170
+ this.path = path;
171
+ this.tier = tier;
172
+ this.projectId = projectId;
173
+ this.type = node.$type;
174
+ }
175
+ get nameSegment() {
176
+ if (this.nameSegmentCache === undefined || (this.nameSegmentCache === null && this.node.$cstNode !== undefined)) {
177
+ this.nameSegmentCache = this.provider.nameSegmentOf(this.node) ?? null;
178
+ }
179
+ return this.nameSegmentCache ?? undefined;
180
+ }
181
+ get selectionSegment() {
182
+ if (this.selectionSegmentCache === undefined || (this.selectionSegmentCache === null && this.node.$cstNode !== undefined)) {
183
+ this.selectionSegmentCache = this.provider.selectionSegmentOf(this.node) ?? null;
184
+ }
185
+ return this.selectionSegmentCache ?? undefined;
113
186
  }
114
187
  }
115
188
  //# sourceMappingURL=ast-node-description-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ast-node-description-provider.js","sourceRoot":"","sources":["../../../src/langium/scope/ast-node-description-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,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,SAA6B;wBANnB,QAAQ;oBAClB,IAAI;oBACJ,IAAI;2BACJ,WAAW;oBACX,IAAI;oBACJ,IAAI;yBACJ,SAAS;QAElB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,IAAI,WAAW;QACZ,IAAI,IAAI,CAAC,gBAAgB,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,gBAAgB,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,EAAE,CAAC;YAC/G,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;QAC1E,CAAC;QACD,OAAO,IAAI,CAAC,gBAAgB,IAAI,SAAS,CAAC;IAC7C,CAAC;IAED,IAAI,gBAAgB;QACjB,IAAI,IAAI,CAAC,qBAAqB,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,qBAAqB,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,EAAE,CAAC;YACzH,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;QACpF,CAAC;QACD,OAAO,IAAI,CAAC,qBAAqB,IAAI,SAAS,CAAC;IAClD,CAAC;CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hydranium/core",
3
- "version": "1.0.0-next.356",
3
+ "version": "1.0.0-next.358",
4
4
  "description": "Foundational runtime of the hydranium framework: AST coordination layer (services, integrity, AST extension, serialization, multi-client documents) plus the LSP textual head at the /lsp subpath. Consumed by protocol-head packages (@hydranium/data-server, @hydranium/glsp-server).",
5
5
  "keywords": [
6
6
  "ast",
@@ -87,8 +87,8 @@
87
87
  "diff": "^5.2.0"
88
88
  },
89
89
  "devDependencies": {
90
- "@hydranium/langium": "1.0.0-next.356",
91
- "@hydranium/protocol": "1.0.0-next.356",
90
+ "@hydranium/langium": "1.0.0-next.358",
91
+ "@hydranium/protocol": "1.0.0-next.358",
92
92
  "@playwright/test": "^1.55.0",
93
93
  "@types/diff": "^5.2.0",
94
94
  "fake-indexeddb": "^6.2.5",
@@ -101,8 +101,8 @@
101
101
  "vscode-languageserver-types": "3.18.0"
102
102
  },
103
103
  "peerDependencies": {
104
- "@hydranium/langium": "1.0.0-next.356",
105
- "@hydranium/protocol": "1.0.0-next.356",
104
+ "@hydranium/langium": "1.0.0-next.358",
105
+ "@hydranium/protocol": "1.0.0-next.358",
106
106
  "@playwright/test": "^1.40.0",
107
107
  "vscode-jsonrpc": "^9.0.0",
108
108
  "vscode-languageserver": "~10.0.1",
@@ -13,8 +13,9 @@
13
13
  *
14
14
  * **These live beside the key provider because the constraint is the key
15
15
  * provider's.** `NameBasedKeyProvider` keys a node the `NameProvider` gives no
16
- * name from its position, as `` `${$containerProperty}@${$containerIndex}` ``,
17
- * so a node appended with a bare `array.push` carries neither and
16
+ * name from its position, as `` `${$containerProperty}@${$containerIndex}` ``
17
+ * (`` `${$containerProperty}@` `` in a single-valued property), so a node
18
+ * appended with a bare `array.push` carries neither and
18
19
  * `getElementKey` answers `undefined` — the element has no key at all, and the
19
20
  * GLSP index cannot address it. Deleting from the middle of such a list must
20
21
  * renumber the survivors, or an id derived later in the same command names the
@@ -44,20 +44,25 @@ import { type NameProvider } from '../naming/name-provider.js';
44
44
  * `NameProvider` gives no name. For grammars with unnamed element types the
45
45
  * reorder / insert / delete stability above does NOT apply to those nodes:
46
46
  * their keys move when their index moves, so a mid-array insert or delete
47
- * renumbers every later sibling.
47
+ * renumbers every later sibling. A node held in a single-valued property has
48
+ * no `$containerIndex` and falls back to `` `${$containerProperty}@` ``; the
49
+ * trailing `@` keeps its key apart from a sibling named after the property.
48
50
  *
49
51
  * Two consequences for a caller creating such nodes programmatically
50
52
  * (a GLSP operation handler is the usual case):
51
53
  *
52
- * - A node appended with a bare `array.push` has no `$containerProperty` /
53
- * `$containerIndex`, so `getElementKey` returns `undefined` and the node
54
- * has no key at all. The containment plumbing has to be stamped.
54
+ * - A node appended with a bare `array.push`, or assigned to a single-valued
55
+ * property without its `$containerProperty`, has no container position, so
56
+ * `getElementKey` returns `undefined` and the node has no key at all. The
57
+ * containment plumbing has to be stamped.
55
58
  * - After a removal, surviving siblings need their `$containerIndex`
56
59
  * renumbered, or a key derived afterwards addresses the wrong node.
57
60
  *
58
- * {@link appendChild} and {@link removeChildren} discharge both, and ship
59
- * beside this provider because the constraint is this provider's rather than
60
- * any caller's.
61
+ * {@link appendChild} and {@link removeChildren} discharge both for arrays,
62
+ * and ship beside this provider because the constraint is this provider's
63
+ * rather than any caller's. A single-valued property needs no helper: build
64
+ * the node with its `$container` and `$containerProperty`, which
65
+ * `buildAstNode` accepts.
61
66
  *
62
67
  * Adopters that need insert / delete stability for unnamed types should
63
68
  * give those types a name in the grammar, or bind a key provider whose
@@ -137,14 +142,21 @@ export class NameBasedKeyProvider implements ElementKeyProvider {
137
142
  }
138
143
 
139
144
  /**
140
- * Fallback segment for unnamed intermediate ancestors —
141
- * `containerProperty@containerIndex`. Returns `undefined` when the
142
- * node has no container position, which short-circuits the walk.
145
+ * Segment for a node the `NameProvider` gives no name —
146
+ * `containerProperty@containerIndex`, or `containerProperty@` when the
147
+ * container holds no array in that property, attached or not. Returns
148
+ * `undefined` when the node has no container position: the node itself
149
+ * then has no key, and an ancestor's level is left out of the key.
143
150
  */
144
151
  protected unidentifiedSegment(node: AstNode): string | undefined {
145
- if (node.$containerProperty === undefined || node.$containerIndex === undefined) {
152
+ const property = node.$containerProperty;
153
+ if (property === undefined) {
146
154
  return undefined;
147
155
  }
148
- return `${node.$containerProperty}@${node.$containerIndex}`;
156
+ if (node.$containerIndex !== undefined) {
157
+ return `${property}@${node.$containerIndex}`;
158
+ }
159
+ // An array member without its index stays keyless rather than share `property@` with its siblings.
160
+ return Array.isArray((node.$container as Record<string, unknown> | undefined)?.[property]) ? undefined : `${property}@`;
149
161
  }
150
162
  }
@@ -195,8 +195,9 @@ function rehydrateCst(document: LangiumDocument, factory: LangiumDocumentFactory
195
195
  * the idle window of the documents in its batch; when a closed, sheddable
196
196
  * document's window elapses, every AST node's `$cstNode` and every reference's
197
197
  * `$refNode` are nulled, and the CST becomes unreachable with the `Range`s
198
- * and `Position`s only it holds. A description's segments and the reference
199
- * index's segments share the CST's `Range` objects, so those stay.
198
+ * and `Position`s only it holds. The reference index's segments, and a
199
+ * description's segments once read, share the CST's `Range` objects, so
200
+ * those stay.
200
201
  *
201
202
  * **Terminology.** *Residency* is the state axis (is the CST in memory? —
202
203
  * `resident` vs `shed`); *shed* is both the act and the policy vocabulary (drop
@@ -248,7 +249,8 @@ export interface CstResidencyService {
248
249
  /**
249
250
  * Node-level convenience over {@link rehydrate}, cheap enough for an
250
251
  * unconditional call: a node whose `$cstNode` is already set returns
251
- * without resolving its document.
252
+ * without resolving its document, and a node outside any document, such as
253
+ * a detached synthetic node, has nothing to restore and returns too.
252
254
  */
253
255
  rehydrateNode(node: AstNode): void;
254
256
  }
@@ -317,7 +319,10 @@ export class DefaultCstResidencyService implements CstResidencyService {
317
319
  if (node.$cstNode !== undefined) {
318
320
  return;
319
321
  }
320
- this.rehydrate(AstUtils.getDocument(node));
322
+ const document = AstUtils.findRootNode(node).$document;
323
+ if (document) {
324
+ this.rehydrate(document);
325
+ }
321
326
  }
322
327
 
323
328
  /**
@@ -8,7 +8,15 @@
8
8
  ********************************************************************************/
9
9
 
10
10
  import { type Tracer } from '@hydranium/protocol';
11
- import { type AstNode, type AstNodeDescription, DefaultAstNodeDescriptionProvider, type LangiumDocument } from '@hydranium/langium';
11
+ import {
12
+ type AstNode,
13
+ AstUtils,
14
+ CstUtils,
15
+ DefaultAstNodeDescriptionProvider,
16
+ type DocumentSegment,
17
+ type LangiumDocument,
18
+ type URI
19
+ } from '@hydranium/langium';
12
20
  import type { LogNameOptions } from '../diagnostics/logger.js';
13
21
  import type { HydraniumLanguageServices } from '../language-module.js';
14
22
  import { type DescriptionTier, type TieredAstNodeDescription } from './scoped-ast-node-description.js';
@@ -32,9 +40,11 @@ import { type DescriptionTier, type TieredAstNodeDescription } from './scoped-as
32
40
  */
33
41
  export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescriptionProvider {
34
42
  protected readonly tracer: Tracer;
43
+ protected readonly services: HydraniumLanguageServices;
35
44
 
36
45
  constructor(services: HydraniumLanguageServices, options: LogNameOptions = {}) {
37
46
  super(services);
47
+ this.services = services;
38
48
  this.tracer = services.shared.Tracer.for(options.logName ?? 'AstNodeDescriptionProvider').trace('instantiated');
39
49
  }
40
50
 
@@ -44,12 +54,11 @@ export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescripti
44
54
  * filter pipeline. Callers that need a different tier must use
45
55
  * {@link createProject}, {@link createPublic}, or {@link createUniversal}.
46
56
  *
47
- * The named factory methods bypass this override by calling
48
- * `super.createDescription` to get a plain base before stamping the
49
- * correct tier — so there is no create-then-overwrite cost.
57
+ * Langium's own `createDescription` is not called: every factory builds
58
+ * through {@link createTiered}.
50
59
  */
51
- override createDescription(node: AstNode, name: string, document: LangiumDocument): TieredAstNodeDescription {
52
- return this.toTiered(super.createDescription(node, name, document), 'local');
60
+ override createDescription(node: AstNode, name: string | undefined, document?: LangiumDocument): TieredAstNodeDescription {
61
+ return this.createTiered(node, name, document, 'local');
53
62
  }
54
63
 
55
64
  /**
@@ -62,7 +71,7 @@ export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescripti
62
71
  * never sees them, so a project tag would be unused.
63
72
  */
64
73
  createLocal(options: { readonly node: AstNode; readonly name: string; readonly document: LangiumDocument }): TieredAstNodeDescription {
65
- return this.toTiered(super.createDescription(options.node, options.name, options.document), 'local');
74
+ return this.createTiered(options.node, options.name, options.document, 'local');
66
75
  }
67
76
 
68
77
  /**
@@ -84,7 +93,7 @@ export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescripti
84
93
  readonly document: LangiumDocument;
85
94
  readonly projectId: string;
86
95
  }): TieredAstNodeDescription {
87
- return this.toTiered(super.createDescription(options.node, options.name, options.document), 'project', options.projectId);
96
+ return this.createTiered(options.node, options.name, options.document, 'project', options.projectId);
88
97
  }
89
98
 
90
99
  /**
@@ -108,7 +117,7 @@ export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescripti
108
117
  readonly document: LangiumDocument;
109
118
  readonly projectId: string;
110
119
  }): TieredAstNodeDescription {
111
- return this.toTiered(super.createDescription(options.node, options.name, options.document), 'public', options.projectId);
120
+ return this.createTiered(options.node, options.name, options.document, 'public', options.projectId);
112
121
  }
113
122
 
114
123
  /**
@@ -126,16 +135,102 @@ export class HydraniumAstNodeDescriptionProvider extends DefaultAstNodeDescripti
126
135
  readonly name: string;
127
136
  readonly document: LangiumDocument;
128
137
  }): TieredAstNodeDescription {
129
- return this.toTiered(super.createDescription(options.node, options.name, options.document), 'universal');
138
+ return this.createTiered(options.node, options.name, options.document, 'universal');
130
139
  }
131
140
 
132
141
  /**
133
- * Attach `tier` + `projectId` fields to a plain {@link AstNodeDescription}
134
- * in place, narrowing the static type to {@link TieredAstNodeDescription}.
135
- * Mutates `base` rather than copying — the input is treated as
136
- * just-constructed and not aliased elsewhere.
142
+ * Resolve the fields of the description every factory returns and build it
143
+ * through {@link newDescription}. Mirrors Langium's `createDescription`:
144
+ * the name defaults to the name provider's, and a node without one throws.
137
145
  */
138
- protected toTiered(base: AstNodeDescription, tier: DescriptionTier, projectId?: string): TieredAstNodeDescription {
139
- return Object.assign(base, { tier, projectId }) as TieredAstNodeDescription;
146
+ protected createTiered(
147
+ node: AstNode,
148
+ name: string | undefined,
149
+ document: LangiumDocument | undefined,
150
+ tier: DescriptionTier,
151
+ projectId?: string
152
+ ): TieredAstNodeDescription {
153
+ const path = this.astNodeLocator.getAstNodePath(node);
154
+ const resolvedName = name ?? this.nameProvider.getName(node);
155
+ if (!resolvedName) {
156
+ throw new Error(`Node at path ${path} has no name.`);
157
+ }
158
+ const documentUri = (document ?? AstUtils.getDocument(node)).uri;
159
+ return this.newDescription(node, resolvedName, documentUri, path, tier, projectId);
160
+ }
161
+
162
+ /** Construct the description from resolved fields; override to build a subclass of {@link DefaultTieredAstNodeDescription}. */
163
+ protected newDescription(
164
+ node: AstNode,
165
+ name: string,
166
+ documentUri: URI,
167
+ path: string,
168
+ tier: DescriptionTier,
169
+ projectId: string | undefined
170
+ ): TieredAstNodeDescription {
171
+ return new DefaultTieredAstNodeDescription(this, node, name, documentUri, path, tier, projectId);
172
+ }
173
+
174
+ /**
175
+ * The segment of `node`'s name, or of the whole node when the name
176
+ * provider finds no name node, restoring a shed CST first: a name provider
177
+ * need not restore it, and an absent segment is not computed again.
178
+ */
179
+ nameSegmentOf(node: AstNode): DocumentSegment | undefined {
180
+ this.services.shared.workspace.CstResidencyService.rehydrateNode(node);
181
+ return CstUtils.toDocumentSegment(this.nameProvider.getNameNode(node) ?? node.$cstNode);
182
+ }
183
+
184
+ /** The segment of the whole node, restoring a shed CST first. */
185
+ selectionSegmentOf(node: AstNode): DocumentSegment | undefined {
186
+ this.services.shared.workspace.CstResidencyService.rehydrateNode(node);
187
+ return CstUtils.toDocumentSegment(node.$cstNode);
188
+ }
189
+ }
190
+
191
+ /**
192
+ * The description {@link HydraniumAstNodeDescriptionProvider} builds. Every
193
+ * field is set in the constructor, so all descriptions share one V8 hidden
194
+ * class; Langium's object literal with a `nameSegment` accessor is kept in
195
+ * dictionary mode and carries two closures, several times the bytes.
196
+ *
197
+ * `nameSegment` and `selectionSegment` are prototype getters, not own
198
+ * properties: a spread, `Object.keys`, a JSON round trip or `structuredClone`
199
+ * of a description drops them. Each is computed on its first read, from the
200
+ * node the description was built for, restoring a shed CST first; an eager
201
+ * `selectionSegment` would keep a segment per description that nothing reads.
202
+ */
203
+ export class DefaultTieredAstNodeDescription implements TieredAstNodeDescription {
204
+ readonly type: string;
205
+ // `null` records a segment computed while the node had no CST. It is
206
+ // recomputed only once the node has one again: retrying without one would
207
+ // attempt a restore, a re-parse, on every read.
208
+ protected nameSegmentCache: DocumentSegment | null | undefined;
209
+ protected selectionSegmentCache: DocumentSegment | null | undefined;
210
+
211
+ constructor(
212
+ protected readonly provider: HydraniumAstNodeDescriptionProvider,
213
+ readonly node: AstNode,
214
+ readonly name: string,
215
+ readonly documentUri: URI,
216
+ readonly path: string,
217
+ readonly tier: DescriptionTier,
218
+ readonly projectId: string | undefined
219
+ ) {
220
+ this.type = node.$type;
221
+ }
222
+
223
+ get nameSegment(): DocumentSegment | undefined {
224
+ if (this.nameSegmentCache === undefined || (this.nameSegmentCache === null && this.node.$cstNode !== undefined)) {
225
+ this.nameSegmentCache = this.provider.nameSegmentOf(this.node) ?? null;
226
+ }
227
+ return this.nameSegmentCache ?? undefined;
228
+ }
229
+
230
+ get selectionSegment(): DocumentSegment | undefined {
231
+ if (this.selectionSegmentCache === undefined || (this.selectionSegmentCache === null && this.node.$cstNode !== undefined)) {
232
+ this.selectionSegmentCache = this.provider.selectionSegmentOf(this.node) ?? null;
233
+ }
234
+ return this.selectionSegmentCache ?? undefined;
140
235
  }
141
236
  }