feat: pass world to linter (#1650)

This commit is contained in:
Myriad-Dreamin 2025-04-14 21:37:29 +08:00 committed by GitHub
parent 9c98876dfb
commit 3d6c712565
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 77 additions and 53 deletions

View file

@ -1,11 +1,10 @@
use std::borrow::Cow;
use tinymist_analysis::ty::TypeInfo;
use tinymist_project::LspWorld;
use tinymist_world::vfs::WorkspaceResolver;
use typst::{diag::SourceDiagnostic, syntax::Span};
use typst::syntax::Span;
use crate::{analysis::Analysis, prelude::*, syntax::ExprInfo, LspWorldExt};
use crate::{analysis::Analysis, prelude::*, LspWorldExt};
use regex::RegexSet;
@ -57,13 +56,9 @@ impl<'w> DiagWorker<'w> {
let Ok(source) = self.ctx.world.source(dep) else {
continue;
};
let expr = self.ctx.expr_stage(&source);
let ti = self.ctx.type_check(&source);
let res = lint_file(&expr, ti);
if !res.is_empty() {
for diag in res {
self.handle(&diag);
}
for diag in self.ctx.lint(&source) {
self.handle(&diag);
}
}
@ -246,8 +241,3 @@ impl DiagnosticRefiner for OutOfRootHintRefiner {
raw.with_hint("Cannot read file outside of project root.")
}
}
#[comemo::memoize]
fn lint_file(source: &ExprInfo, ti: Arc<TypeInfo>) -> EcoVec<SourceDiagnostic> {
tinymist_lint::lint_file(source, ti)
}