diff --git a/crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_unused.typ b/crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_unused.typ new file mode 100644 index 000000000..4c768fa45 --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_unused.typ @@ -0,0 +1,13 @@ +/// path: u.typ + +#let foo() = "foo" + +----- +/// path: main.typ +/// compile: true + +#import "u.typ" as a +#import "u.typ" as b + +#let value = a.foo() +#value diff --git a/crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_wildcard_unused.typ b/crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_wildcard_unused.typ new file mode 100644 index 000000000..6c0b9bab5 --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_wildcard_unused.typ @@ -0,0 +1,13 @@ +/// path: u.typ + +#let foo() = "foo" + +----- +/// path: main.typ +/// compile: true + +#import "u.typ" as a: * +#import "u.typ" as b: * + +#let value = foo() +#value diff --git a/crates/tinymist-query/src/fixtures/dead_code/duplicate_module_wildcard_unused.typ b/crates/tinymist-query/src/fixtures/dead_code/duplicate_module_wildcard_unused.typ new file mode 100644 index 000000000..223fe703b --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code/duplicate_module_wildcard_unused.typ @@ -0,0 +1,13 @@ +/// path: u.typ + +#let foo() = "foo" + +----- +/// path: main.typ +/// compile: true + +#import "u.typ": * +#import "u.typ": * + +#let value = foo() +#value 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 new file mode 100644 index 000000000..d590ef4ed --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_alias_unused.typ.snap @@ -0,0 +1,18 @@ +--- +source: crates/tinymist-query/src/analysis.rs +expression: "JsonRepr::new_redacted(result, &REDACT_LOC)" +input_file: crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_unused.typ +--- +{ + "main.typ": [ + { + "message": "unused import: `b`\nHint: consider removing this unused import", + "range": "3:19:3:20", + "severity": 4, + "source": "typst", + "tags": [ + 1 + ] + } + ] +} 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 new file mode 100644 index 000000000..921efa34d --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_alias_wildcard_unused.typ.snap @@ -0,0 +1,18 @@ +--- +source: crates/tinymist-query/src/analysis.rs +expression: "JsonRepr::new_redacted(result, &REDACT_LOC)" +input_file: crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_wildcard_unused.typ +--- +{ + "main.typ": [ + { + "message": "unused import: `b`\nHint: consider removing this unused import", + "range": "3:19:3:20", + "severity": 4, + "source": "typst", + "tags": [ + 1 + ] + } + ] +} 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 new file mode 100644 index 000000000..1ef3906c4 --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code/snaps/dead_code@duplicate_module_wildcard_unused.typ.snap @@ -0,0 +1,18 @@ +--- +source: crates/tinymist-query/src/analysis.rs +expression: "JsonRepr::new_redacted(result, &REDACT_LOC)" +input_file: crates/tinymist-query/src/fixtures/dead_code/duplicate_module_wildcard_unused.typ +--- +{ + "main.typ": [ + { + "message": "unused module import\nHint: imported modules should be used or the import should be removed", + "range": "3:1:3:18", + "severity": 4, + "source": "typst", + "tags": [ + 1 + ] + } + ] +} diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@duplicate_module_alias_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@duplicate_module_alias_unused.typ.snap new file mode 100644 index 000000000..7e6be9868 --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@duplicate_module_alias_unused.typ.snap @@ -0,0 +1,29 @@ +--- +source: crates/tinymist-query/src/code_action.rs +description: Dead code code actions in /dummy-root/main.typ +expression: "JsonRepr::new_pure(ordered_entries)" +input_file: crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_unused.typ +--- +[ + { + "actions": [ + { + "edit": { + "changes": { + "main.typ": [ + { + "insertTextFormat": 1, + "newText": "", + "range": "3:15:3:20" + } + ] + } + }, + "kind": "quickfix", + "title": "Remove unused import" + } + ], + "message": "unused import: `b`\nHint: consider removing this unused import", + "range": "3:19:3:20" + } +] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@duplicate_module_alias_wildcard_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@duplicate_module_alias_wildcard_unused.typ.snap new file mode 100644 index 000000000..b602a2686 --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@duplicate_module_alias_wildcard_unused.typ.snap @@ -0,0 +1,29 @@ +--- +source: crates/tinymist-query/src/code_action.rs +description: Dead code code actions in /dummy-root/main.typ +expression: "JsonRepr::new_pure(ordered_entries)" +input_file: crates/tinymist-query/src/fixtures/dead_code/duplicate_module_alias_wildcard_unused.typ +--- +[ + { + "actions": [ + { + "edit": { + "changes": { + "main.typ": [ + { + "insertTextFormat": 1, + "newText": "", + "range": "3:15:3:20" + } + ] + } + }, + "kind": "quickfix", + "title": "Remove unused import" + } + ], + "message": "unused import: `b`\nHint: consider removing this unused import", + "range": "3:19:3:20" + } +] diff --git a/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@duplicate_module_wildcard_unused.typ.snap b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@duplicate_module_wildcard_unused.typ.snap new file mode 100644 index 000000000..72e3f207d --- /dev/null +++ b/crates/tinymist-query/src/fixtures/dead_code_code_action/snaps/run_dead_code_code_action_snapshots@duplicate_module_wildcard_unused.typ.snap @@ -0,0 +1,29 @@ +--- +source: crates/tinymist-query/src/code_action.rs +description: Dead code code actions in /dummy-root/main.typ +expression: "JsonRepr::new_pure(ordered_entries)" +input_file: crates/tinymist-query/src/fixtures/dead_code/duplicate_module_wildcard_unused.typ +--- +[ + { + "actions": [ + { + "edit": { + "changes": { + "main.typ": [ + { + "insertTextFormat": 1, + "newText": "", + "range": "3:0:4:0" + } + ] + } + }, + "kind": "quickfix", + "title": "Remove unused declaration" + } + ], + "message": "unused module import\nHint: imported modules should be used or the import should be removed", + "range": "3:1:3:18" + } +]