Expand description
CST mutation operations (add, remove, update fields). Edit engine for surgical CST mutations that preserve formatting.
Edits work by producing TextEdits (insertions/deletions at byte offsets)
that are collected in an EditBatch and applied atomically to the source
string. After applying, the caller re-parses from scratch to get a fresh
CST + AST.
The key challenge is list field editing: .cabal files use several different
formatting styles for list fields (single-line, leading-comma, trailing-comma,
no-comma), and the edit engine must detect and follow the existing style.
Structs§
Enums§
- List
Style - The detected formatting style of a list field.
Functions§
- add_
field_ to_ root - Add a new top-level metadata field to the root of the file.
- add_
field_ to_ section - Add a new field to a section at the end (before any conditionals).
- add_
list_ item - Add an item to a list field (e.g., add a dependency to build-depends).
- add_
section - Add a new top-level section to the end of the file.
- detect_
list_ style - Detect the list style of a field node.
- find_
field - Find a field node within a section (or the root) by field name.
- find_
section - Find a section node by keyword and optional name.
- remove_
list_ item - Remove an item from a list field by prefix match on the item name.
- set_
field_ value - Set a simple scalar field value. Replaces the current value text.