diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-05-25 11:46:51 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-05-25 11:51:28 +0200 |
| commit | 6935cf8dfefff3d6cf234f077a7d61661fd5ca57 (patch) | |
| tree | cf40e5c6eb99ff28c62edde75f0eab748672ba30 /src/source.rs | |
| parent | 3309ff9fe5ea36134e8ddf11ac2c84613b569856 (diff) | |
Virtual machine
Diffstat (limited to 'src/source.rs')
| -rw-r--r-- | src/source.rs | 9 |
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. |
