Skip to content

Commit 4f0f9a1

Browse files
committed
feat: implement resolution.rs utils
1 parent 0f853eb commit 4f0f9a1

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod named;
1212
pub mod num;
1313
pub mod parse;
1414
pub mod pattern;
15+
pub mod resolution;
1516
#[cfg(feature = "serde")]
1617
mod serde;
1718
pub mod str;

src/resolution.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use std::path::Path;
2+
use std::sync::Arc;
3+
4+
/// Powers error reporting by mapping compiler diagnostics to the specific file.
5+
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
6+
pub struct SourceFile {
7+
/// The name or path of the source file (e.g., "./simf/main.simf").
8+
name: Arc<Path>,
9+
/// The actual text content of the source file.
10+
content: Arc<str>,
11+
}
12+
13+
impl From<(&Path, &str)> for SourceFile {
14+
fn from((name, content): (&Path, &str)) -> Self {
15+
Self {
16+
name: Arc::from(name),
17+
content: Arc::from(content),
18+
}
19+
}
20+
}
21+
22+
impl SourceFile {
23+
pub fn new(name: &Path, content: Arc<str>) -> Self {
24+
Self { name: Arc::from(name), content }
25+
}
26+
27+
pub fn name(&self) -> &Path {
28+
self.name.as_ref()
29+
}
30+
31+
pub fn content(&self) -> Arc<str> {
32+
self.content.clone()
33+
}
34+
}

0 commit comments

Comments
 (0)