From 08a6188123ad0806986fa4f5477b728a07d081cc Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 31 May 2022 10:40:30 +0200 Subject: Remove green/red distinction --- src/source.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/source.rs') diff --git a/src/source.rs b/src/source.rs index 77a020cb..82b54550 100644 --- a/src/source.rs +++ b/src/source.rs @@ -12,7 +12,7 @@ use crate::diag::TypResult; use crate::loading::{FileHash, Loader}; use crate::parse::{is_newline, parse, reparse}; use crate::syntax::ast::Markup; -use crate::syntax::{GreenNode, RedNode, Span}; +use crate::syntax::{Span, SyntaxNode}; use crate::util::{PathExt, StrExt}; #[cfg(feature = "codespan-reporting")] @@ -151,7 +151,7 @@ pub struct SourceFile { path: PathBuf, src: String, lines: Vec, - root: Arc, + root: SyntaxNode, rev: usize, } @@ -178,27 +178,21 @@ impl SourceFile { /// Create a source file with the same synthetic span for all nodes. pub fn synthesized(src: impl Into, span: Span) -> Self { let mut file = Self::detached(src); - Arc::make_mut(&mut file.root).synthesize(Arc::new(span)); + file.root.synthesize(Arc::new(span)); file.id = span.source; file } - /// The root node of the file's untyped green tree. - pub fn root(&self) -> &Arc { + /// The root node of the file's untyped syntax tree. + pub fn root(&self) -> &SyntaxNode { &self.root } - /// The root red node of the file's untyped red tree. - pub fn red(&self) -> RedNode { - RedNode::from_root(self.root.clone(), self.id) - } - /// The root node of the file's typed abstract syntax tree. pub fn ast(&self) -> TypResult { - let red = self.red(); - let errors = red.errors(); + let errors = self.root.errors(); if errors.is_empty() { - Ok(red.cast().unwrap()) + Ok(self.root.cast().unwrap()) } else { Err(Box::new(errors)) } -- cgit v1.2.3