diff --git a/crates/tinymist-query/src/analysis.rs b/crates/tinymist-query/src/analysis.rs index 9e8cabc4f..9c04007a2 100644 --- a/crates/tinymist-query/src/analysis.rs +++ b/crates/tinymist-query/src/analysis.rs @@ -629,7 +629,11 @@ mod call_info_tests { mod lint_tests { use std::collections::BTreeMap; - use tinymist_lint::KnownIssues; + use tinymist_analysis::{ + adt::interner::Interned, + syntax::{Decl, Expr}, + }; + use tinymist_lint::{DeadCodeConfig, KnownIssues}; use crate::tests::*; @@ -662,4 +666,54 @@ mod lint_tests { assert_snapshot!(JsonRepr::new_redacted(result, &REDACT_LOC)); }); } + + #[test] + fn test_dead_code_exported() { + snapshot_testing("dead_code_exported", &|ctx, path| { + let source = ctx.source_by_path(&path).unwrap(); + let ei = ctx.expr_stage(&source); + let ti = ctx.type_check(&source); + + let has_references = |decl: &Interned| -> bool { + if matches!(decl.as_ref(), Decl::PathStem(_)) { + if ei.resolves.values().any(|r| { + matches!( + r.step.as_ref(), + Some(Expr::Decl(step_decl)) if step_decl == decl + ) + }) { + return true; + } + } else if ei + .get_refs(decl.clone()) + .any(|(_, r)| r.as_ref().decl != *decl) + { + return true; + } + + false + }; + + let dead_code_config = DeadCodeConfig { + check_exported: true, + ..DeadCodeConfig::default() + }; + let result = tinymist_lint::lint_file_with_dead_code_config( + ctx.world(), + &ei, + ti, + KnownIssues::default(), + has_references, + &dead_code_config, + ) + .diagnostics; + + let result = crate::diagnostics::DiagWorker::new(ctx).convert_all(result.iter()); + let result = result + .into_iter() + .map(|(k, v)| (file_uri_(&k), v)) + .collect::>(); + assert_snapshot!(JsonRepr::new_redacted(result, &REDACT_LOC)); + }); + } } diff --git a/crates/tinymist-query/src/analysis/code_action.rs b/crates/tinymist-query/src/analysis/code_action.rs index d538eec76..35c018728 100644 --- a/crates/tinymist-query/src/analysis/code_action.rs +++ b/crates/tinymist-query/src/analysis/code_action.rs @@ -15,6 +15,13 @@ use crate::analysis::LinkTarget; use crate::prelude::*; use crate::syntax::{InterpretMode, interpret_mode_at}; +const UNUSED_CODE_IMPORTED_ITEM: &str = "tinymist.unused.import"; +const UNUSED_CODE_MODULE_IMPORT: &str = "tinymist.unused.module_import"; +const UNUSED_CODE_MODULE: &str = "tinymist.unused.module"; +const UNUSED_CODE_SYMBOL: &str = "tinymist.unused.symbol"; +const UNUSED_CODE_EXPORTED_DOCUMENTED_FUNCTION: &str = + "tinymist.unused.exported_documented_function"; + /// Analyzes the document and provides code actions. pub struct CodeActionWorker<'a> { /// The local analysis context to work with. @@ -75,11 +82,32 @@ impl<'a> CodeActionWorker<'a> { } for diag in &context.diagnostics { - let Some(source) = diag.source.as_deref() else { + let Some(diag_range) = self.ctx.to_typst_range(diag.range, &self.source) else { continue; }; - let Some(diag_range) = self.ctx.to_typst_range(diag.range, &self.source) else { + if let Some(unused_code) = unused_code(diag) { + if unused_code == UNUSED_CODE_IMPORTED_ITEM { + self.autofix_remove_unused_import(root, &diag_range); + } else if unused_code == UNUSED_CODE_MODULE_IMPORT + || unused_code == UNUSED_CODE_MODULE + { + self.autofix_remove_declaration(root, &diag_range); + } else { + let Some(binding_range) = self.binding_range_for_diag(root, &diag_range, diag) + else { + continue; + }; + + self.autofix_unused_symbol(&binding_range); + self.autofix_replace_with_placeholder(root, &binding_range); + self.autofix_remove_declaration(root, &binding_range); + } + + continue; + } + + let Some(source) = diag.source.as_deref() else { continue; }; @@ -90,23 +118,6 @@ impl<'a> CodeActionWorker<'a> { Some(AutofixKind::FileNotFound) => { self.autofix_file_not_found(root, &diag_range); } - Some(AutofixKind::MarkUnusedSymbol) => { - if diag.message.starts_with("unused import:") { - self.autofix_remove_unused_import(root, &diag_range); - } else if diag.message.starts_with("unused module") { - self.autofix_remove_declaration(root, &diag_range); - } else { - let Some(binding_range) = - self.binding_range_for_diag(root, &diag_range, diag) - else { - continue; - }; - - self.autofix_unused_symbol(&binding_range); - self.autofix_replace_with_placeholder(root, &binding_range); - self.autofix_remove_declaration(root, &binding_range); - } - } _ => {} } } @@ -521,33 +532,12 @@ impl<'a> CodeActionWorker<'a> { diag_range: &Range, diag: &lsp_types::Diagnostic, ) -> Option> { + let _ = (root, diag); if diag_range.is_empty() { return None; } - if let Some(text) = self.source.text().get(diag_range.clone()) { - if is_plain_identifier(text) { - return Some(diag_range.clone()); - } - } - - let name = extract_backticked_name(&diag.message)?; - let cursor = (diag_range.start + 1).min(self.source.text().len()); - let node = root.leaf_at_compat(cursor)?; - let decl_node = self.find_declaration_ancestor(&node)?; - - if decl_node.kind() == SyntaxKind::LetBinding { - let let_binding = decl_node.cast::()?; - for binding in let_binding.kind().bindings() { - let binding_node = decl_node.find(binding.span())?; - let range = binding_node.range(); - if self.source.text().get(range.clone())? == name { - return Some(range); - } - } - } - - None + Some(diag_range.clone()) } fn expand_import_item_range(&self, mut range: Range) -> Range { @@ -1013,14 +1003,9 @@ impl<'a> CodeActionWorker<'a> { enum AutofixKind { UnknownVariable, FileNotFound, - MarkUnusedSymbol, } fn match_autofix_kind(source: &str, msg: &str) -> Option { - if msg.starts_with("unused ") { - return Some(AutofixKind::MarkUnusedSymbol); - } - if source == "typst" { static PATTERNS: &[(&str, AutofixKind)] = &[ ("unknown variable", AutofixKind::UnknownVariable), @@ -1037,15 +1022,8 @@ fn match_autofix_kind(source: &str, msg: &str) -> Option { None } -fn extract_backticked_name(message: &str) -> Option<&str> { - let start = message.find('`')?; - let rest = &message[start + 1..]; - let end = rest.find('`')?; - Some(&rest[..end]) -} - fn is_ascii_ident(ch: u8) -> bool { - matches!(ch, b'_' | b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9') + matches!(ch, b'_' | b'-' | b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9') } fn is_plain_identifier(name: &str) -> bool { @@ -1060,3 +1038,17 @@ fn is_plain_identifier(name: &str) -> bool { chars.all(|ch| ch == '_' || ch.is_ascii_alphanumeric()) } + +fn unused_code(diag: &lsp_types::Diagnostic) -> Option<&str> { + match diag.code.as_ref()? { + lsp_types::NumberOrString::String(s) => match s.as_str() { + UNUSED_CODE_IMPORTED_ITEM + | UNUSED_CODE_MODULE_IMPORT + | UNUSED_CODE_MODULE + | UNUSED_CODE_SYMBOL + | UNUSED_CODE_EXPORTED_DOCUMENTED_FUNCTION => Some(s.as_str()), + _ => None, + }, + _ => None, + } +} diff --git a/crates/tinymist-query/src/diagnostics.rs b/crates/tinymist-query/src/diagnostics.rs index b7b875926..e99c6a7c7 100644 --- a/crates/tinymist-query/src/diagnostics.rs +++ b/crates/tinymist-query/src/diagnostics.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use tinymist_lint::KnownIssues; +use tinymist_lint::{DOCUMENTED_EXPORTED_FUNCTION_HINT, KnownIssues}; use tinymist_world::vfs::WorkspaceResolver; use typst::syntax::Span; @@ -14,6 +14,13 @@ pub type DiagnosticsMap = HashMap>; type TypstDiagnostic = typst::diag::SourceDiagnostic; type TypstSeverity = typst::diag::Severity; +const UNUSED_CODE_IMPORTED_ITEM: &str = "tinymist.unused.import"; +const UNUSED_CODE_MODULE_IMPORT: &str = "tinymist.unused.module_import"; +const UNUSED_CODE_MODULE: &str = "tinymist.unused.module"; +const UNUSED_CODE_SYMBOL: &str = "tinymist.unused.symbol"; +const UNUSED_CODE_EXPORTED_DOCUMENTED_FUNCTION: &str = + "tinymist.unused.exported_documented_function"; + /// Converts a list of Typst diagnostics to LSP diagnostics, /// with potential refinements on the error messages. pub fn convert_diagnostics<'a>( @@ -122,13 +129,20 @@ impl<'w> DiagWorker<'w> { let lsp_severity = diagnostic_severity(&typst_diagnostic); let lsp_message = diagnostic_message(&typst_diagnostic); let is_unused = typst_diagnostic.message.starts_with("unused "); + let unused_code = is_unused + .then(|| self.unused_code(&typst_diagnostic)) + .flatten(); + let is_documented_exported_function = + unused_code.is_some_and(|code| code == UNUSED_CODE_EXPORTED_DOCUMENTED_FUNCTION); let diagnostic = Diagnostic { range: lsp_range, severity: Some(lsp_severity), message: lsp_message, source: Some(self.source.to_owned()), - tags: is_unused.then(|| vec![DiagnosticTag::UNNECESSARY]), + code: unused_code.map(|code| lsp_types::NumberOrString::String(code.to_string())), + tags: (is_unused && !is_documented_exported_function) + .then(|| vec![DiagnosticTag::UNNECESSARY]), related_information: (!typst_diagnostic.trace.is_empty()).then(|| { typst_diagnostic .trace @@ -182,6 +196,31 @@ impl<'w> DiagWorker<'w> { None => LspRange::new(LspPosition::new(0, 0), LspPosition::new(0, 0)), } } + + fn unused_code(&self, diag: &TypstDiagnostic) -> Option<&'static str> { + let msg = diag.message.as_str(); + if msg.starts_with("unused import:") { + return Some(UNUSED_CODE_IMPORTED_ITEM); + } + if msg.starts_with("unused module import") { + return Some(UNUSED_CODE_MODULE_IMPORT); + } + if msg.starts_with("unused module:") { + return Some(UNUSED_CODE_MODULE); + } + if msg.starts_with("unused function:") + && diag + .hints + .iter() + .any(|hint| hint.as_str() == DOCUMENTED_EXPORTED_FUNCTION_HINT) + { + return Some(UNUSED_CODE_EXPORTED_DOCUMENTED_FUNCTION); + } + if msg.starts_with("unused ") { + return Some(UNUSED_CODE_SYMBOL); + } + None + } } fn diagnostic_severity(typst_diagnostic: &TypstDiagnostic) -> DiagnosticSeverity { diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@array_dict_usage.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@array_dict_usage.typ.snap index 963f0ee84..283c1742e 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@array_dict_usage.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@array_dict_usage.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/array_dict_usage.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused`\nHint: consider removing this variable or prefixing with underscore: `_unused`", - "range": "3:1:3:15", + "range": "3:5:3:11", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@closure_capture.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@closure_capture.typ.snap index 9cb2c9bc8..cf13da9ef 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@closure_capture.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@closure_capture.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/closure_capture.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused_not_captured`\nHint: consider removing this variable or prefixing with underscore: `_unused_not_captured`", - "range": "2:1:2:30", + "range": "2:5:2:24", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@conditional_usage.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@conditional_usage.typ.snap index c85ef7d9e..cde9d8adf 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@conditional_usage.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@conditional_usage.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/conditional_usage.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused`\nHint: consider removing this variable or prefixing with underscore: `_unused`", - "range": "4:1:4:16", + "range": "4:5:4:11", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@contextual_usage.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@contextual_usage.typ.snap index dac6a637f..fd3c4c81c 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@contextual_usage.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@contextual_usage.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/contextual_usage.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused_ctx`\nHint: consider removing this variable or prefixing with underscore: `_unused_ctx`", - "range": "2:1:2:20", + "range": "2:5:2:15", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_array.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_array.typ.snap index 63f508539..31e3e9461 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_array.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_array.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_array.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused_x`\nHint: consider removing this variable or prefixing with underscore: `_unused_x`", - "range": "6:1:6:46", + "range": "6:15:6:23", "severity": 4, "source": "typst", "tags": [ @@ -15,8 +16,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_array.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused variable: `c2`\nHint: consider removing this variable or prefixing with underscore: `_c2`", - "range": "6:1:6:46", + "range": "6:31:6:33", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_dict.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_dict.typ.snap index aa09054b9..34d64d0e4 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_dict.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_dict.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_dict.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused_x`\nHint: consider removing this variable or prefixing with underscore: `_unused_x`", - "range": "6:1:6:52", + "range": "6:18:6:26", "severity": 4, "source": "typst", "tags": [ @@ -15,8 +16,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_dict.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused variable: `c2`\nHint: consider removing this variable or prefixing with underscore: `_c2`", - "range": "6:1:6:52", + "range": "6:37:6:39", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_spread.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_spread.typ.snap index 94c542a1c..cf092c689 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_spread.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@destructuring_spread.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_spread.ty { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused_rest`\nHint: consider removing this variable or prefixing with underscore: `_unused_rest`", - "range": "4:1:4:30", + "range": "4:11:4:22", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_alias_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_alias_unused.typ.snap index d590ef4ed..ce2457a7f 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_alias_unused.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_alias_unused.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_ { "main.typ": [ { + "code": "tinymist.unused.import", "message": "unused import: `b`\nHint: consider removing this unused import", "range": "3:19:3:20", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_alias_wildcard_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_alias_wildcard_unused.typ.snap index 921efa34d..144a058ae 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_alias_wildcard_unused.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_alias_wildcard_unused.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_ { "main.typ": [ { + "code": "tinymist.unused.import", "message": "unused import: `b`\nHint: consider removing this unused import", "range": "3:19:3:20", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_wildcard_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_wildcard_unused.typ.snap index 1ef3906c4..44113f5e8 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_wildcard_unused.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_wildcard_unused.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/duplicate_module_wildca { "main.typ": [ { + "code": "tinymist.unused.module_import", "message": "unused module import\nHint: imported modules should be used or the import should be removed", "range": "3:1:3:18", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@function_as_value.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@function_as_value.typ.snap index cfff5de8c..80f5c5083 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@function_as_value.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@function_as_value.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/function_as_value.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `unused_callback`\nHint: consider removing this function or prefixing with underscore: `_unused_callback`", "range": "6:5:6:20", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@import_module_alias_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@import_module_alias_unused.typ.snap index 3abaf867b..c333bbc66 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@import_module_alias_unused.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@import_module_alias_unused.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/import_module_alias_unu { "main.typ": [ { + "code": "tinymist.unused.import", "message": "unused import: `util`\nHint: consider removing this unused import", "range": "2:19:2:23", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@import_module_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@import_module_unused.typ.snap index 5b0b8909c..edc9d2ab3 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@import_module_unused.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@import_module_unused.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/import_module_unused.ty { "main.typ": [ { + "code": "tinymist.unused.module", "message": "unused module: `u`\nHint: imported modules should be used or the import should be removed", "range": "2:8:2:15", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@imported_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@imported_unused.typ.snap index dc784bcff..e2866010b 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@imported_unused.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@imported_unused.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/imported_unused.typ { "main.typ": [ { + "code": "tinymist.unused.import", "message": "unused import: `Bbar`\nHint: consider removing this unused import", "range": "2:24:2:28", "severity": 4, @@ -15,6 +16,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/imported_unused.typ ] }, { + "code": "tinymist.unused.import", "message": "unused import: `foo`\nHint: consider removing this unused import", "range": "2:30:2:33", "severity": 4, @@ -24,6 +26,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/imported_unused.typ ] }, { + "code": "tinymist.unused.module_import", "message": "unused module import\nHint: imported modules should be used or the import should be removed", "range": "2:1:2:33", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@imported_used.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@imported_used.typ.snap index 074ab38b0..04e3ba785 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@imported_used.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@imported_used.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/imported_used.typ { "main.typ": [ { + "code": "tinymist.unused.import", "message": "unused import: `foo`\nHint: consider removing this unused import", "range": "2:31:2:34", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@loop_variables.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@loop_variables.typ.snap index 3e4e40068..3697af109 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@loop_variables.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@loop_variables.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/loop_variables.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused_item`\nHint: consider removing this variable or prefixing with underscore: `_unused_item`", "range": "1:5:1:16", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@method_chain.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@method_chain.typ.snap index c4b419bdf..d127cf3e5 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@method_chain.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@method_chain.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/method_chain.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused_obj`\nHint: consider removing this variable or prefixing with underscore: `_unused_obj`", - "range": "8:1:8:24", + "range": "8:5:8:15", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@module_item_wildcard_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@module_item_wildcard_unused.typ.snap index b24e5dee6..2e66afd30 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@module_item_wildcard_unused.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@module_item_wildcard_unused.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/module_item_wildcard_un { "main.typ": [ { + "code": "tinymist.unused.module_import", "message": "unused module import\nHint: imported modules should be used or the import should be removed", "range": "2:1:2:18", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@multiple_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@multiple_unused.typ.snap index 77aa84a90..1c66995b0 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@multiple_unused.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@multiple_unused.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/multiple_unused.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused1`\nHint: consider removing this variable or prefixing with underscore: `_unused1`", - "range": "1:1:1:16", + "range": "1:5:1:12", "severity": 4, "source": "typst", "tags": [ @@ -15,8 +16,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/multiple_unused.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused2`\nHint: consider removing this variable or prefixing with underscore: `_unused2`", - "range": "2:1:2:16", + "range": "2:5:2:12", "severity": 4, "source": "typst", "tags": [ @@ -24,8 +26,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/multiple_unused.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused3`\nHint: consider removing this variable or prefixing with underscore: `_unused3`", - "range": "4:1:4:16", + "range": "4:5:4:12", "severity": 4, "source": "typst", "tags": [ @@ -33,6 +36,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/multiple_unused.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused function: `unused_func1`\nHint: consider removing this function or prefixing with underscore: `_unused_func1`", "range": "6:5:6:17", "severity": 4, @@ -42,6 +46,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/multiple_unused.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused function: `unused_func2`\nHint: consider removing this function or prefixing with underscore: `_unused_func2`", "range": "8:5:8:17", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@nested_scope.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@nested_scope.typ.snap index d70dc212e..e053c6aec 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@nested_scope.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@nested_scope.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/nested_scope.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `inner_unused`\nHint: consider removing this variable or prefixing with underscore: `_inner_unused`", - "range": "4:2:4:22", + "range": "4:6:4:18", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@pattern_destructure.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@pattern_destructure.typ.snap index 81e3b0a99..b46699054 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@pattern_destructure.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@pattern_destructure.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/pattern_destructure.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused_b`\nHint: consider removing this variable or prefixing with underscore: `_unused_b`", - "range": "1:1:1:43", + "range": "1:14:1:22", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@shadowing.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@shadowing.typ.snap index 8c43aedcc..f342a9efb 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@shadowing.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@shadowing.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/shadowing.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `x`\nHint: consider removing this variable or prefixing with underscore: `_x`", - "range": "1:1:1:10", + "range": "1:5:1:6", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@show_set_rules.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@show_set_rules.typ.snap index ffdaa27cf..4e809edac 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@show_set_rules.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@show_set_rules.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/show_set_rules.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused_style`\nHint: consider removing this variable or prefixing with underscore: `_unused_style`", - "range": "1:1:1:23", + "range": "1:5:1:17", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@underscore_prefix.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@underscore_prefix.typ.snap index 07c9cbf94..f638f9a60 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@underscore_prefix.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@underscore_prefix.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/underscore_prefix.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `normal_unused`\nHint: consider removing this variable or prefixing with underscore: `_normal_unused`", - "range": "4:1:4:24", + "range": "4:5:4:18", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_function.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_function.typ.snap index dabe45b11..cd65c4031 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_function.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_function.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/unused_function.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `unused_func`\nHint: consider removing this function or prefixing with underscore: `_unused_func`", "range": "1:5:1:16", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_parameter.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_parameter.typ.snap index b44b97295..f43322cbd 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_parameter.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_parameter.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/unused_parameter.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused_param`\nHint: if this parameter is intentionally unused, prefix it with underscore: `_unused_param`", "range": "1:22:1:34", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_variable.typ.snap b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_variable.typ.snap index edc73e355..10538e0c3 100644 --- a/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_variable.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@unused_variable.typ.snap @@ -6,8 +6,9 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/unused_variable.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `unused_var`\nHint: consider removing this variable or prefixing with underscore: `_unused_var`", - "range": "1:1:1:20", + "range": "1:5:1:15", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@array_dict_usage.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@array_dict_usage.typ.snap index 7dafe9a79..817fd3bf7 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@array_dict_usage.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@array_dict_usage.typ.snap @@ -54,6 +54,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/array_dict_usage.typ } ], "message": "unused variable: `unused`\nHint: consider removing this variable or prefixing with underscore: `_unused`", - "range": "3:1:3:15" + "range": "3:5:3:11" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@closure_capture.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@closure_capture.typ.snap index 49505986a..cc3811d8a 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@closure_capture.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@closure_capture.typ.snap @@ -54,6 +54,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/closure_capture.typ } ], "message": "unused variable: `unused_not_captured`\nHint: consider removing this variable or prefixing with underscore: `_unused_not_captured`", - "range": "2:1:2:30" + "range": "2:5:2:24" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@conditional_usage.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@conditional_usage.typ.snap index ec7f51507..2bff1c13f 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@conditional_usage.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@conditional_usage.typ.snap @@ -54,6 +54,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/conditional_usage.typ } ], "message": "unused variable: `unused`\nHint: consider removing this variable or prefixing with underscore: `_unused`", - "range": "4:1:4:16" + "range": "4:5:4:11" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@contextual_usage.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@contextual_usage.typ.snap index 30be61cf7..3f86b57b0 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@contextual_usage.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@contextual_usage.typ.snap @@ -54,6 +54,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/contextual_usage.typ } ], "message": "unused variable: `unused_ctx`\nHint: consider removing this variable or prefixing with underscore: `_unused_ctx`", - "range": "2:1:2:20" + "range": "2:5:2:15" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_array.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_array.typ.snap index f85d8bdd7..55a44b6ec 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_array.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_array.typ.snap @@ -39,7 +39,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_array.typ } ], "message": "unused variable: `unused_x`\nHint: consider removing this variable or prefixing with underscore: `_unused_x`", - "range": "6:1:6:46" + "range": "6:15:6:23" }, { "actions": [ @@ -75,6 +75,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_array.typ } ], "message": "unused variable: `c2`\nHint: consider removing this variable or prefixing with underscore: `_c2`", - "range": "6:1:6:46" + "range": "6:31:6:33" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_dict.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_dict.typ.snap index 654352e7e..b1b5faeef 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_dict.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_dict.typ.snap @@ -39,7 +39,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_dict.typ } ], "message": "unused variable: `unused_x`\nHint: consider removing this variable or prefixing with underscore: `_unused_x`", - "range": "6:1:6:52" + "range": "6:18:6:26" }, { "actions": [ @@ -75,6 +75,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_dict.typ } ], "message": "unused variable: `c2`\nHint: consider removing this variable or prefixing with underscore: `_c2`", - "range": "6:1:6:52" + "range": "6:37:6:39" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_spread.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_spread.typ.snap index 3b2b132a2..e663056ce 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_spread.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@destructuring_spread.typ.snap @@ -24,6 +24,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_spread.ty } ], "message": "unused variable: `unused_rest`\nHint: consider removing this variable or prefixing with underscore: `_unused_rest`", - "range": "4:1:4:30" + "range": "4:11:4:22" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@method_chain.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@method_chain.typ.snap index 6b07643e2..39e4c3e75 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@method_chain.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@method_chain.typ.snap @@ -54,6 +54,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/method_chain.typ } ], "message": "unused variable: `unused_obj`\nHint: consider removing this variable or prefixing with underscore: `_unused_obj`", - "range": "8:1:8:24" + "range": "8:5:8:15" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@multiple_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@multiple_unused.typ.snap index 67b185c80..8c4468217 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@multiple_unused.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@multiple_unused.typ.snap @@ -54,7 +54,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/multiple_unused.typ } ], "message": "unused variable: `unused1`\nHint: consider removing this variable or prefixing with underscore: `_unused1`", - "range": "1:1:1:16" + "range": "1:5:1:12" }, { "actions": [ @@ -105,7 +105,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/multiple_unused.typ } ], "message": "unused variable: `unused2`\nHint: consider removing this variable or prefixing with underscore: `_unused2`", - "range": "2:1:2:16" + "range": "2:5:2:12" }, { "actions": [ @@ -156,7 +156,7 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/multiple_unused.typ } ], "message": "unused variable: `unused3`\nHint: consider removing this variable or prefixing with underscore: `_unused3`", - "range": "4:1:4:16" + "range": "4:5:4:12" }, { "actions": [ diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@nested_scope.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@nested_scope.typ.snap index 84b96f559..8a3cc7fe5 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@nested_scope.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@nested_scope.typ.snap @@ -54,6 +54,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/nested_scope.typ } ], "message": "unused variable: `inner_unused`\nHint: consider removing this variable or prefixing with underscore: `_inner_unused`", - "range": "4:2:4:22" + "range": "4:6:4:18" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@pattern_destructure.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@pattern_destructure.typ.snap index 5e6f0d4d0..8af90eea7 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@pattern_destructure.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@pattern_destructure.typ.snap @@ -39,6 +39,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/pattern_destructure.typ } ], "message": "unused variable: `unused_b`\nHint: consider removing this variable or prefixing with underscore: `_unused_b`", - "range": "1:1:1:43" + "range": "1:14:1:22" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@shadowing.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@shadowing.typ.snap index bddef6046..c7fc4eeb0 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@shadowing.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@shadowing.typ.snap @@ -54,6 +54,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/shadowing.typ } ], "message": "unused variable: `x`\nHint: consider removing this variable or prefixing with underscore: `_x`", - "range": "1:1:1:10" + "range": "1:5:1:6" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@show_set_rules.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@show_set_rules.typ.snap index 3bb95b15f..4d5d182b8 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@show_set_rules.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@show_set_rules.typ.snap @@ -54,6 +54,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/show_set_rules.typ } ], "message": "unused variable: `unused_style`\nHint: consider removing this variable or prefixing with underscore: `_unused_style`", - "range": "1:1:1:23" + "range": "1:5:1:17" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@underscore_prefix.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@underscore_prefix.typ.snap index 9ab257a5f..f128cbdf1 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@underscore_prefix.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@underscore_prefix.typ.snap @@ -54,6 +54,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/underscore_prefix.typ } ], "message": "unused variable: `normal_unused`\nHint: consider removing this variable or prefixing with underscore: `_normal_unused`", - "range": "4:1:4:24" + "range": "4:5:4:18" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@unused_variable.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@unused_variable.typ.snap index 06f757273..9c800dd61 100644 --- a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@unused_variable.typ.snap +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@unused_variable.typ.snap @@ -54,6 +54,6 @@ input_file: crates/tinymist-query/src/fixtures/dead_code/unused_variable.typ } ], "message": "unused variable: `unused_var`\nHint: consider removing this variable or prefixing with underscore: `_unused_var`", - "range": "1:1:1:20" + "range": "1:5:1:15" } ] diff --git a/crates/tinymist-query/src/fixtures/dead_code_exported/exported_unused.typ b/crates/tinymist-query/src/fixtures/dead_code_exported/exported_unused.typ new file mode 100644 index 000000000..844124683 --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code_exported/exported_unused.typ @@ -0,0 +1,7 @@ +/// path: main.typ +/// compile: true + +#let api(x) = x + +#let value = 1 +#value diff --git a/crates/tinymist-query/src/fixtures/dead_code_exported/exported_unused_docstring.typ b/crates/tinymist-query/src/fixtures/dead_code_exported/exported_unused_docstring.typ new file mode 100644 index 000000000..9bbef2977 --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code_exported/exported_unused_docstring.typ @@ -0,0 +1,8 @@ +/// path: main.typ +/// compile: true + +/// Public API documentation. +#let api(x) = x + +#let value = 1 +#value diff --git a/crates/tinymist-query/src/fixtures/dead_code_exported/snaps/dead_code_exported@exported_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_exported/snaps/dead_code_exported@exported_unused.typ.snap new file mode 100644 index 000000000..949341e2a --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code_exported/snaps/dead_code_exported@exported_unused.typ.snap @@ -0,0 +1,19 @@ +--- +source: crates/tinymist-query/src/analysis.rs +expression: "JsonRepr::new_redacted(result, &REDACT_LOC)" +input_file: crates/tinymist-query/src/fixtures/dead_code_exported/exported_unused.typ +--- +{ + "main.typ": [ + { + "code": "tinymist.unused.symbol", + "message": "unused function: `api`\nHint: this function is exported but never used", + "range": "2:5:2:8", + "severity": 4, + "source": "typst", + "tags": [ + 1 + ] + } + ] +} diff --git a/crates/tinymist-query/src/fixtures/dead_code_exported/snaps/dead_code_exported@exported_unused_docstring.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_exported/snaps/dead_code_exported@exported_unused_docstring.typ.snap new file mode 100644 index 000000000..2a2866bd2 --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code_exported/snaps/dead_code_exported@exported_unused_docstring.typ.snap @@ -0,0 +1,16 @@ +--- +source: crates/tinymist-query/src/analysis.rs +expression: "JsonRepr::new_redacted(result, &REDACT_LOC)" +input_file: crates/tinymist-query/src/fixtures/dead_code_exported/exported_unused_docstring.typ +--- +{ + "main.typ": [ + { + "code": "tinymist.unused.exported_documented_function", + "message": "unused function: `api`\nHint: this function is exported but never used\nHint: this function is exported and documented; it may be part of the public API\nHint: if this is intended public API, you can ignore this diagnostic; otherwise consider removing it", + "range": "3:5:3:8", + "severity": 4, + "source": "typst" + } + ] +} diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@assign_ok.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@assign_ok.typ.snap index 467a5d294..fac3e34c4 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@assign_ok.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@assign_ok.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/assign_ok.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@binary.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@binary.typ.snap index 4b09a6d25..4df6567cb 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@binary.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@binary.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/binary.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str.typ.snap index e9b4d18a9..577ce7ce2 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/binary_type_compare_str.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str_input.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str_input.typ.snap index 116093218..d04cc9677 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str_input.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str_input.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/binary_type_compare_str_inpu { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str_let.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str_let.typ.snap index 6a6095416..d52ae641b 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str_let.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@binary_type_compare_str_let.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/binary_type_compare_str_let. { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@break_for.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@break_for.typ.snap index f150c1f06..a29e362e3 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@break_for.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@break_for.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/break_for.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused variable: `value`\nHint: consider removing this variable or prefixing with underscore: `_value`", "range": "0:5:0:10", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@break_func_for.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@break_func_for.typ.snap index b109b8d4f..73d5a66d8 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@break_func_for.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@break_func_for.typ.snap @@ -20,6 +20,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/break_func_for.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused variable: `value`\nHint: consider removing this variable or prefixing with underscore: `_value`", "range": "0:5:0:10", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_array.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_array.typ.snap index a022b6b8d..c7aab227d 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_array.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_array.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_array.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common.typ.snap index e9d4f484c..5ae41afbb 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common.typ.snap @@ -18,6 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_common.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common_break.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common_break.typ.snap index 2ebbc2d42..b8b5275e8 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common_break.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common_break.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_common_break.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common_break2.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common_break2.typ.snap index 092ffcce7..d419a02d7 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common_break2.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_common_break2.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_common_break2.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_equation.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_equation.typ.snap index df7032275..a493a8ed0 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_equation.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_equation.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_equation.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for.typ.snap index 3f72164e1..6ac71bda8 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_for.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, @@ -21,8 +22,9 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_for.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused variable: `i`\nHint: consider removing this variable or prefixing with underscore: `_i`", - "range": "0:1:3:1", + "range": "0:15:0:16", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for2.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for2.typ.snap index 6415cc892..657a0421e 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for2.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for2.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_for2.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, @@ -21,8 +22,9 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_for2.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused variable: `i`\nHint: consider removing this variable or prefixing with underscore: `_i`", - "range": "0:1:3:1", + "range": "0:15:0:16", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for3.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for3.typ.snap index 2a3f5923d..ab46bd0e4 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for3.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for3.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_for3.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, @@ -21,8 +22,9 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_for3.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused variable: `i`\nHint: consider removing this variable or prefixing with underscore: `_i`", - "range": "0:1:2:1", + "range": "0:15:0:16", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for4.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for4.typ.snap index de89600f9..617598990 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for4.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for4.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_for4.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, @@ -21,8 +22,9 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_for4.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused variable: `i`\nHint: consider removing this variable or prefixing with underscore: `_i`", - "range": "0:1:3:1", + "range": "0:15:0:16", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for5.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for5.typ.snap index d487c7027..9a2a5831e 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for5.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_for5.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_for5.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, @@ -21,8 +22,9 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_for5.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused variable: `i`\nHint: consider removing this variable or prefixing with underscore: `_i`", - "range": "0:1:3:1", + "range": "0:15:0:16", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_hello.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_hello.typ.snap index b908ddb41..c333b4f60 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_hello.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_hello.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_hello.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_if.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_if.typ.snap index 8137ce3a1..339c0c5c5 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_if.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_if.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_if.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_if2.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_if2.typ.snap index 3adef77ef..a1c456a9a 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_if2.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_if2.typ.snap @@ -18,6 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_if2.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join.typ.snap index d0d1d643e..23a05e777 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join.typ.snap @@ -18,6 +18,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_join.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join_partial.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join_partial.typ.snap index 0115108fe..5ff62a215 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join_partial.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join_partial.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_join_partial.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join_partial2.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join_partial2.typ.snap index 857355783..698050b33 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join_partial2.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_join_partial2.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_join_partial2.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_set.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_set.typ.snap index ee9373eeb..15985d044 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_set.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_set.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_set.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_show.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_show.typ.snap index 8b2ce826f..ecbc75aed 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_show.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_show.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_show.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_show_content.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_show_content.typ.snap index 7c6f695f2..f32ff1294 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_show_content.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@discard_show_content.typ.snap @@ -12,6 +12,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/discard_show_content.typ "source": "typst" }, { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_loop2.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_loop2.typ.snap index 52167c473..a9ef631ac 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_loop2.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_loop2.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/return_loop2.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_loop3.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_loop3.typ.snap index 01ecddd56..1715dd105 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_loop3.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_loop3.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/return_loop3.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `mul-mat`\nHint: consider removing this function or prefixing with underscore: `_mul-mat`", "range": "0:5:0:12", "severity": 4, @@ -15,8 +16,9 @@ input_file: crates/tinymist-query/src/fixtures/lint/return_loop3.typ ] }, { + "code": "tinymist.unused.symbol", "message": "unused variable: `matrix`\nHint: consider removing this variable or prefixing with underscore: `_matrix`", - "range": "0:1:9:1", + "range": "3:6:3:12", "severity": 4, "source": "typst", "tags": [ diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial.typ.snap index fac2d0e40..4eff67493 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/return_partial.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial2.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial2.typ.snap index d142cd4d5..e532834db 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial2.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial2.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/return_partial2.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `as-padding-dict`\nHint: consider removing this function or prefixing with underscore: `_as-padding-dict`", "range": "0:5:0:20", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial_if.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial_if.typ.snap index 85e657990..541746101 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial_if.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_partial_if.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/return_partial_if.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `get-op`\nHint: consider removing this function or prefixing with underscore: `_get-op`", "range": "0:5:0:11", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_regular.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_regular.typ.snap index bbb75c0cd..3aa052232 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@return_regular.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@return_regular.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/return_regular.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@show_good.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@show_good.typ.snap index d933d2cbc..796c197ac 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@show_good.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@show_good.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/show_good.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@show_good2.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@show_good2.typ.snap index da5f15c41..88cfbdc75 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@show_good2.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@show_good2.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/show_good2.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@while_good.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@while_good.typ.snap index a162f59b1..24a954b9d 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@while_good.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@while_good.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/while_good.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4, diff --git a/crates/tinymist-query/src/fixtures/lint/snaps/test@while_good2.typ.snap b/crates/tinymist-query/src/fixtures/lint/snaps/test@while_good2.typ.snap index 1a4fadf28..94aa1cfa8 100644 --- a/crates/tinymist-query/src/fixtures/lint/snaps/test@while_good2.typ.snap +++ b/crates/tinymist-query/src/fixtures/lint/snaps/test@while_good2.typ.snap @@ -6,6 +6,7 @@ input_file: crates/tinymist-query/src/fixtures/lint/while_good2.typ { "s0.typ": [ { + "code": "tinymist.unused.symbol", "message": "unused function: `f`\nHint: consider removing this function or prefixing with underscore: `_f`", "range": "0:5:0:6", "severity": 4,