mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-22 20:35:20 +00:00
dev: fix lint warnings introduced by #2062 (#2096)
Some checks failed
tinymist::auto_tag / auto-tag (push) Has been cancelled
tinymist::ci / Duplicate Actions Detection (push) Has been cancelled
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Has been cancelled
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Has been cancelled
tinymist::ci / prepare-build (push) Has been cancelled
tinymist::gh_pages / build-gh-pages (push) Has been cancelled
tinymist::ci / announce (push) Has been cancelled
tinymist::ci / build (push) Has been cancelled
Some checks failed
tinymist::auto_tag / auto-tag (push) Has been cancelled
tinymist::ci / Duplicate Actions Detection (push) Has been cancelled
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Has been cancelled
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Has been cancelled
tinymist::ci / prepare-build (push) Has been cancelled
tinymist::gh_pages / build-gh-pages (push) Has been cancelled
tinymist::ci / announce (push) Has been cancelled
tinymist::ci / build (push) Has been cancelled
> Hm. Sorry about the lint failures here, they slipped my attention locally since they show up as warnings, not errors, in my editor. I'm happy to put a PR fixing them later unless you get to it first. > > Not too sure how to deal with the unused DiagWorker::check method, since it is used, just in a test-only module. We can certainly mark it as #[cfg(test)] but that feels a little nasty. https://github.com/Myriad-Dreamin/tinymist/pull/2062#issuecomment-3237812684 I ended up inlining the logic of `DiagWorker::check` into the test.
This commit is contained in:
parent
4324f8fd70
commit
731cd23ec8
3 changed files with 14 additions and 16 deletions
|
|
@ -14,6 +14,6 @@ impl SemanticRequest for CheckRequest {
|
|||
|
||||
fn request(self, ctx: &mut LocalContext) -> Option<Self::Response> {
|
||||
let worker = DiagWorker::new(ctx);
|
||||
Some(worker.full_check().convert_all(self.snap.diagnostics()))
|
||||
Some(worker.check().convert_all(self.snap.diagnostics()))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,14 +126,20 @@ mod tests {
|
|||
source: &Source,
|
||||
request_range: &LspRange,
|
||||
) -> CodeActionContext {
|
||||
let Warned { output, warnings } = typst::compile::<PagedDocument>(&ctx.world);
|
||||
let errors = output.err().unwrap_or_default();
|
||||
let compiler_diagnostics = warnings.iter().chain(errors.iter());
|
||||
let Warned {
|
||||
output,
|
||||
warnings: compiler_warnings,
|
||||
} = typst::compile::<PagedDocument>(&ctx.world);
|
||||
let compiler_errors = output.err().unwrap_or_default();
|
||||
|
||||
// Run the linter for additional diagnostics as well.
|
||||
let lint_warnings = ctx.lint(source);
|
||||
let diagnostics = DiagWorker::new(ctx)
|
||||
.check(source)
|
||||
.convert_all(compiler_diagnostics)
|
||||
.convert_all(
|
||||
compiler_errors
|
||||
.iter()
|
||||
.chain(compiler_warnings.iter())
|
||||
.chain(lint_warnings.iter()),
|
||||
)
|
||||
.into_values()
|
||||
.flatten();
|
||||
|
||||
|
|
|
|||
|
|
@ -46,16 +46,8 @@ impl<'w> DiagWorker<'w> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Runs code check on the given document.
|
||||
pub fn check(mut self, source: &Source) -> Self {
|
||||
for diag in self.ctx.lint(&source) {
|
||||
self.handle(&diag);
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Runs code check on the main document and all its dependencies.
|
||||
pub fn full_check(mut self) -> Self {
|
||||
pub fn check(mut self) -> Self {
|
||||
for dep in self.ctx.world.depended_files() {
|
||||
if WorkspaceResolver::is_package_file(dep) {
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue