summaryrefslogtreecommitdiff
path: root/src/source.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-31 10:40:30 +0200
committerLaurenz <laurmaedje@gmail.com>2022-05-31 10:40:30 +0200
commit08a6188123ad0806986fa4f5477b728a07d081cc (patch)
tree3338f1d64ebdd6df734bcc9ae0172bda2e075a2a /src/source.rs
parent665ed12825918bd02a6d6dbcb67860a83dd41600 (diff)
Remove green/red distinction
Diffstat (limited to 'src/source.rs')
-rw-r--r--src/source.rs20
1 files changed, 7 insertions, 13 deletions
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<Line>,
- root: Arc<GreenNode>,
+ 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<String>, 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<GreenNode> {
+ /// 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<Markup> {
- 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))
}