WithTextChange(Int32, Int32, String) Method

Definition

Assembly SharpYaml.dll

Replaces a source range and returns a newly parsed syntax tree, preserving all text outside the range.

public YamlSyntaxTree WithTextChange(int start, int length, string newText)

Parameters

start
Int32

The zero-based UTF-16 character index at which to apply the change.

length
Int32

The number of characters to replace. Use zero to insert text.

newText
String

The replacement YAML source text. Use an empty string to delete text.

Returns

YamlSyntaxTree
A new syntax tree with updated tokens and spans, using the same trivia option.

Remarks

The original tree is unchanged. Replacement text is raw YAML, not a CLR scalar value; callers must supply any required quoting, escaping, and indentation. The complete result is reparsed and validated. For successive edits, use offsets from the latest tree.