pub struct Document {
pub graph: Graph,
pub trivia: Trivia,
pub layout: Layout,
}Expand description
A graph together with everything keyed by the identities inside it.
The three tables have to move as one. They are keyed by the same node names and wires, so an edit that updated only some of them would leave the rest pointing at things that no longer exist — which, for the comment table, means deleting somebody’s writing on the next save.
Source spans deliberately do not live here. A span describes the text a file was parsed from, and the first edit makes every one of them stale, not merely the ones naming the edited node. Keeping them out means a stale span cannot be read by accident.
Fields§
§graph: Graph§trivia: Trivia§layout: LayoutImplementations§
Source§impl Document
impl Document
pub fn new(graph: Graph, trivia: Trivia, layout: Layout) -> Self
Sourcepub fn remove_node(&mut self, name: &str) -> Option<Node>
pub fn remove_node(&mut self, name: &str) -> Option<Node>
Removes a node together with every wire that touches it, its position, and the comments belonging to all of them.
Wires are not left dangling: a dangling wire is a state the compiler would have to consider on every check, and a later node reusing the freed name would silently inherit both the wires and the dead node’s comments.
Sourcepub fn remove_edge(&mut self, edge: &Edge) -> bool
pub fn remove_edge(&mut self, edge: &Edge) -> bool
Removes one wire and the comments attached to it.
Sourcepub fn rename_node(&mut self, from: &str, to: &str) -> Result<(), RenameError>
pub fn rename_node(&mut self, from: &str, to: &str) -> Result<(), RenameError>
Renames a node, rewriting every wire that mentions it and carrying its comments and its position across.
This is the price of letting a node’s name be its identity, and it is paid here rather than by each caller so that it is paid the same way every time.