diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-11-07 23:31:42 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-11-08 11:52:09 +0100 |
| commit | 75fffc1f9b6ef8bf258b2b1845a4ba74a0f5f2c1 (patch) | |
| tree | e8c841d9d9323fc3cff0f584f3267743e809dd25 /src/syntax/mod.rs | |
| parent | 95866d5fc9ae89a23c5754193c7de5d4fe4873b1 (diff) | |
Fine-grained capturing
Diffstat (limited to 'src/syntax/mod.rs')
| -rw-r--r-- | src/syntax/mod.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs index fc05ad50..0660d57b 100644 --- a/src/syntax/mod.rs +++ b/src/syntax/mod.rs @@ -187,11 +187,20 @@ pub struct RedNode { } impl RedNode { - /// Create a new root node from a [`GreenNode`]. - pub fn new_root(root: Rc<GreenNode>, id: SourceId) -> Self { + /// Create a new red node from a root [`GreenNode`]. + pub fn from_root(root: Rc<GreenNode>, id: SourceId) -> Self { Self { id, offset: 0, green: root.into() } } + /// Create a new red node from a node kind and a span. + pub fn from_data(kind: NodeKind, span: Span) -> Self { + Self { + id: span.source, + offset: span.start, + green: Green::Token(GreenData { kind, len: span.len() }), + } + } + /// Convert to a borrowed representation. pub fn as_ref(&self) -> RedRef<'_> { RedRef { @@ -540,7 +549,7 @@ pub enum NodeKind { /// A percentage: `50%`. /// /// _Note_: `50%` is stored as `50.0` here, as in the corresponding - /// [literal](ast::Lit::Percent). + /// [literal](ast::LitKind::Percent). Percentage(f64), /// A fraction unit: `3fr`. Fraction(f64), |
