From f0c9635db5efd0c66e01bef1be0a8f140fdbdd84 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 4 Nov 2021 15:16:46 +0100 Subject: Notes --- src/syntax/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/syntax/mod.rs') diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs index d26c6484..112fc220 100644 --- a/src/syntax/mod.rs +++ b/src/syntax/mod.rs @@ -40,6 +40,15 @@ impl Green { self.data().kind() } + /// Set the type of the node. + pub fn set_kind(&mut self, kind: NodeKind) { + let data = match self { + Self::Node(node) => &mut Rc::make_mut(node).data, + Self::Token(data) => data, + }; + data.set_kind(kind); + } + /// The length of the node. pub fn len(&self) -> usize { self.data().len() @@ -141,6 +150,11 @@ impl GreenData { &self.kind } + /// Set the type of the node. + pub fn set_kind(&mut self, kind: NodeKind) { + self.kind = kind; + } + /// The length of the node. pub fn len(&self) -> usize { self.len -- cgit v1.2.3