Skip to content

rune-langium / core/src / preserveCstText

Function: preserveCstText() ​

ts
function preserveCstText(model): void;

Defined in: packages/core/src/serializer/preserve-cst-text.ts:21

Copy $cstNode.text -> $cstText for condition/expression-bearing AST parts BEFORE JsonSerializer.serialize, because $cstNode is non-serializable (circular) and the serializer drops it — yet the visual-editor's expression cells need the original source text after the JSON round-trip.

Walks Function shortcuts/conditions/operations/postConditions and Data/Choice conditions, copying both the part's and its expression's CST text. Single source of truth shared by the browser parse worker and the server parse function (previously duplicated, byte-identical, in both — V7).

Retained (Task 9 / CST-reuse eval): Though $cstRange is now stamped on all nodes during hydration, visual-editor expression consumers (FunctionForm, model-helpers, etc.) cannot access originalSourceByNamespace to slice via offsets— they are across a source-less boundary post-serialization. Keep preserveCstText.

Parameters ​

ParameterType
modelany

Returns ​

void

Core packages released under MIT. Studio app released under FSL-1.1-ALv2.