Skip to content

Commit

Permalink
dev(compiler): eagle check syntax of the main file
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Sep 28, 2023
1 parent c4437ea commit ea08d02
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion compiler/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ use std::{

use crate::{vfs::notify::FilesystemEvent, ShadowApi};
use typst::{
diag::{At, FileResult, SourceDiagnostic, SourceResult},
diag::{At, FileResult, Hint, SourceDiagnostic, SourceResult},
doc::Document,
eval::Tracer,
model::Content,
syntax::Span,
World,
};
use typst_library::prelude::{eco_format, EcoString};
use typst_ts_core::{Bytes, ImmutPath, TypstFileId};

// todo: remove cfg feature here
Expand Down Expand Up @@ -69,6 +70,13 @@ pub trait Compiler {
fn pure_compile(&mut self) -> SourceResult<Arc<Document>> {
self.reset()?;

let main_id = self.main_id();

self.world_mut()
.source(main_id)
.hint(AtFile(main_id))
.at(Span::detached())?;

let mut tracer = Tracer::default();
// compile and export document
typst::compile(self.world(), &mut tracer).map(Arc::new)
Expand Down Expand Up @@ -370,3 +378,11 @@ where
}
}
}

struct AtFile(TypstFileId);

impl From<AtFile> for EcoString {
fn from(at: AtFile) -> Self {
eco_format!("at file {:?}", at.0)
}
}
2 changes: 2 additions & 0 deletions fuzzers/corpora/viewers/preview-watch-gbk.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

�����ĵ�

0 comments on commit ea08d02

Please sign in to comment.