Expand description
Pure CST→CST structural-edit transforms (E008 Phase 1a, ADR-0007).
This module gives ronin-core the named structural-edit vocabulary the
E008 tree/form and table surfaces build on — insert / remove / reorder a
struct field, map entry, or list/tuple element; set a value; rename a
field/key; swap an enum variant; and add a field across every record of a
list. Each op is a single, non-destructive apply_structural call that
returns a fresh CstDocument sharing every untouched green subtree with
the original (structural sharing), so every region the edit did not touch
prints byte-for-byte identically (FR-013) and adjacent trivia on
surviving siblings is preserved (FR-021).
§Placement (ADR-0007)
These are the pure CST→CST transform functions of the split decided by
ADR-0007: they live in ronin-core (reusable by a future LSP/web surface),
navigate the document only through the typed crate::syntax::ast accessors,
and compose over the existing non-destructive apply_edit primitive — they
introduce no parallel edit engine. The selection→target resolution and
the view/undo orchestration stay in ronin-app; selection, focus,
view-state, and undo wiring MUST NOT enter this module.
§WASM-clean (ADR-0007 / HINT-001 / project-instructions §II)
This module adds no filesystem / UI / async-runtime / native / time
dependency. It uses only std and ronin-core’s own CST types + apply_edit,
so the wasm32-unknown-unknown build of ronin-core stays green.
§Addressing scheme
Each StructuralOp carries its target as an ast-navigable address: a
parent collection node (ParentRef) plus, where a specific element is
addressed, a child index into that parent’s elements (fields / entries /
items, in source order). The caller (ronin-app, later) resolves a tree/table
selection to one of these addresses; this module then re-resolves the address
to a located CST node and composes the appropriate apply_edit call(s).
Addressing by index into the located parent (rather than by a raw
SyntaxNode handle) keeps a multi-step op (reorder, variant swap,
add-field-across-rows) re-resolvable against each intermediate green tree the
composition produces.
§Outcome
Every op returns a TransformOutcome: TransformOutcome::Applied with the
new document, or TransformOutcome::Blocked with a BlockedReason. A
Blocked outcome leaves the input CST unchanged and produces no edit (a
no-op never corrupts the document — project-instructions §I).
Enums§
- Blocked
Reason - Why a
StructuralOpwasTransformOutcome::Blocked. - Parent
Ref - Which collection a structural op targets, addressed by an
ast-navigable reference (parent kind + index into the document). - Structural
Op - A single named structural-edit operation (the E008 transform vocabulary).
- Transform
Outcome - The result of applying a
StructuralOp.
Functions§
- apply_
structural - Apply one named structural
StructuralOptodoc, returning aTransformOutcome.