Skip to content

Commit 5383d35

Browse files
committed
feat: implement resolution.rs utils
1 parent 0f853eb commit 5383d35

2 files changed

Lines changed: 38 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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 {
25+
name: Arc::from(name),
26+
content,
27+
}
28+
}
29+
30+
pub fn name(&self) -> &Path {
31+
self.name.as_ref()
32+
}
33+
34+
pub fn content(&self) -> Arc<str> {
35+
self.content.clone()
36+
}
37+
}

0 commit comments

Comments
 (0)