Add host-structured imports

This commit is contained in:
2026-08-11 18:33:49 +09:00
parent 46b2b3b1b6
commit 165daada23
12 changed files with 402 additions and 46 deletions
+5 -5
View File
@@ -5,8 +5,8 @@ use std::{
};
use decodal::{
Data, Diagnostic, DiagnosticKind, Engine, LoadedSource, SourceId, SourceLoader, Span,
format_diagnostic_with,
Data, Diagnostic, DiagnosticKind, Engine, ImportLoader, LoadedImport, LoadedSource, SourceId,
Span, format_diagnostic_with,
};
fn main() -> ExitCode {
@@ -95,12 +95,12 @@ fn read_root_source(path: &str) -> Result<LoadedSource, Diagnostic> {
#[derive(Debug, Clone, Copy)]
struct FsLoader;
impl SourceLoader for FsLoader {
impl ImportLoader for FsLoader {
fn load(
&mut self,
current_key: Option<&str>,
specifier: &str,
) -> Result<LoadedSource, Diagnostic> {
) -> Result<LoadedImport, Diagnostic> {
let path = Path::new(specifier);
let path = if path.is_absolute() {
PathBuf::from(path)
@@ -112,7 +112,7 @@ impl SourceLoader for FsLoader {
} else {
PathBuf::from(path)
};
load_path(&path)
load_path(&path).map(LoadedImport::Source)
}
}