summaryrefslogtreecommitdiff
path: root/src/source.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-25 11:46:51 +0200
committerLaurenz <laurmaedje@gmail.com>2022-05-25 11:51:28 +0200
commit6935cf8dfefff3d6cf234f077a7d61661fd5ca57 (patch)
treecf40e5c6eb99ff28c62edde75f0eab748672ba30 /src/source.rs
parent3309ff9fe5ea36134e8ddf11ac2c84613b569856 (diff)
Virtual machine
Diffstat (limited to 'src/source.rs')
-rw-r--r--src/source.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/source.rs b/src/source.rs
index cd5a453a..77a020cb 100644
--- a/src/source.rs
+++ b/src/source.rs
@@ -175,9 +175,12 @@ impl SourceFile {
Self::new(SourceId::detached(), Path::new(""), src.into())
}
- /// Set a synthetic span for all nodes in this file.
- pub fn synthesize(&mut self, span: Span) {
- Arc::make_mut(&mut self.root).synthesize(Arc::new(span));
+ /// 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.id = span.source;
+ file
}
/// The root node of the file's untyped green tree.