feat: add snapshot_testing_with_snapshots function for enhanced snapshot testing

This commit is contained in:
Hong Jiarong 2025-11-15 21:25:58 +08:00
parent 5ee652a0a6
commit ea1ec20253
42 changed files with 2130 additions and 4 deletions

View file

@ -0,0 +1,2 @@
/// fixture: code_action_dead_code
#let foo/* range -3..0 */ = 42

View file

@ -0,0 +1,39 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 135
description: "Code Action on t \"/base.t||yp\"/* rang"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/absolute_path_import.typ
---
[
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "0:1:0:19"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
},
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "\"base.typ\"",
"range": "0:8:0:19"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to relative path"
}
]

View file

@ -0,0 +1,54 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 135
description: "Code Action on code\n#let |foo|/* range -"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/dead_code.typ
---
[
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_foo",
"range": "1:5:1:8"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `foo`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "1:5:1:8"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "1:1:2:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
]

View file

@ -0,0 +1,79 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 135
description: "Code Action on rt \"base.t||yp\"/* rang"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/path_and_equation.typ
---
[
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "0:2:0:19"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
},
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "\"/base.typ\"",
"range": "0:9:0:19"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to absolute path"
},
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": " ",
"range": "0:1:0:1"
},
{
"insertTextFormat": 1,
"newText": " ",
"range": "0:38:0:38"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to block equation"
},
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "\n",
"range": "0:1:0:1"
},
{
"insertTextFormat": 1,
"newText": "\n",
"range": "0:38:0:38"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to multiple-line block equation"
}
]

View file

@ -0,0 +1,24 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 135
description: "Code Action on + \"base.t||yp\"/* rang"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/path_expression_import.typ
---
[
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "0:1:0:24"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
]

View file

@ -0,0 +1,39 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 135
description: "Code Action on rt \"base.t||yp\"/* rang"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/path_import.typ
---
[
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "0:1:0:18"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
},
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "\"/base.typ\"",
"range": "0:8:0:18"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to absolute path"
}
]

View file

@ -0,0 +1,24 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 135
description: "Code Action on (\"base.ty||p\")/* rang"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/path_import_paren.typ
---
[
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "0:1:0:20"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
]

View file

@ -0,0 +1,24 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 135
description: "Code Action on n(\"base.js||on\" /* ran"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/path_json.typ
---
[
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "\"/base.json\"",
"range": "0:6:0:17"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to absolute path"
}
]

View file

@ -0,0 +1,79 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 135
description: "Code Action on $xy||z/* range "
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/unknown_math_ident.typ
---
[
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 2,
"newText": "\n\nlet xyz",
"range": "0:0:0:0"
}
]
}
},
"kind": "quickfix",
"title": "Create missing variable"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 2,
"newText": "x y z",
"range": "0:1:0:4"
}
]
}
},
"kind": "quickfix",
"title": "Add spaces between letters"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": " ",
"range": "0:1:0:1"
},
{
"insertTextFormat": 1,
"newText": " ",
"range": "0:4:0:22"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to block equation"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "\n",
"range": "0:1:0:1"
},
{
"insertTextFormat": 1,
"newText": "\n",
"range": "0:4:0:22"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to multiple-line block equation"
}
]

View file

@ -0,0 +1,79 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 135
description: Code Action on $a||b/c/* rang
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/unknown_math_ident_frac.typ
---
[
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 2,
"newText": "\n\nlet ab",
"range": "0:0:0:0"
}
]
}
},
"kind": "quickfix",
"title": "Create missing variable"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 2,
"newText": "(a b)",
"range": "0:1:0:3"
}
]
}
},
"kind": "quickfix",
"title": "Add spaces between letters"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": " ",
"range": "0:1:0:1"
},
{
"insertTextFormat": 1,
"newText": " ",
"range": "0:5:0:23"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to block equation"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "\n",
"range": "0:1:0:1"
},
{
"insertTextFormat": 1,
"newText": "\n",
"range": "0:5:0:23"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to multiple-line block equation"
}
]

View file

@ -0,0 +1,79 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 135
description: "Code Action on $a_i||j/* range "
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/unknown_math_subscript.typ
---
[
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 2,
"newText": "\n\nlet ij",
"range": "0:0:0:0"
}
]
}
},
"kind": "quickfix",
"title": "Create missing variable"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 2,
"newText": "(i j)",
"range": "0:3:0:5"
}
]
}
},
"kind": "quickfix",
"title": "Add spaces between letters"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": " ",
"range": "0:1:0:1"
},
{
"insertTextFormat": 1,
"newText": " ",
"range": "0:5:0:23"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to block equation"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "\n",
"range": "0:1:0:1"
},
{
"insertTextFormat": 1,
"newText": "\n",
"range": "0:5:0:23"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to multiple-line block equation"
}
]

View file

@ -0,0 +1,79 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 135
description: Code Action on $a_(i||j)/* range
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/unknown_math_subscript_paren.typ
---
[
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 2,
"newText": "\n\nlet ij",
"range": "0:0:0:0"
}
]
}
},
"kind": "quickfix",
"title": "Create missing variable"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 2,
"newText": "i j",
"range": "0:4:0:6"
}
]
}
},
"kind": "quickfix",
"title": "Add spaces between letters"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": " ",
"range": "0:1:0:1"
},
{
"insertTextFormat": 1,
"newText": " ",
"range": "0:7:0:25"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to block equation"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "\n",
"range": "0:1:0:1"
},
{
"insertTextFormat": 1,
"newText": "\n",
"range": "0:7:0:25"
}
]
}
},
"kind": "refactor.rewrite",
"title": "Convert to multiple-line block equation"
}
]

View file

@ -1,10 +1,26 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 120
description: "Code Action on t \"/base.t||yp\"/* rang"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/absolute_path_import.typ
---
[
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "0:1:0:19"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
},
{
"edit": {
"changes": {

View file

@ -0,0 +1,54 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 120
description: "Code Action on code\n#let |foo|/* range -"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/dead_code.typ
---
[
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_foo",
"range": "1:5:1:8"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `foo`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "1:5:1:8"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "1:1:2:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
]

View file

@ -1,10 +1,26 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 120
description: "Code Action on rt \"base.t||yp\"/* rang"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/path_and_equation.typ
---
[
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "0:2:0:19"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
},
{
"edit": {
"changes": {

View file

@ -1,7 +1,23 @@
---
source: crates/tinymist-query/src/code_action.rs
description: "Code Action on + \"base.t||yp\"/* rang)"
description: "Code Action on + \"base.t||yp\"/* rang"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/path_expression_import.typ
---
null
[
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "0:1:0:24"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
]

View file

@ -5,6 +5,21 @@ expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/path_import.typ
---
[
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "0:1:0:18"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
},
{
"edit": {
"changes": {

View file

@ -1,7 +1,23 @@
---
source: crates/tinymist-query/src/code_action.rs
description: "Code Action on (\"base.ty||p\")/* rang)"
description: "Code Action on (\"base.ty||p\")/* rang"
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/code_action/path_import_paren.typ
---
null
[
{
"edit": {
"changes": {
"s1.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "0:1:0:20"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
]

View file

@ -0,0 +1,8 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/all_used.typ
---
[]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/array_dict_usage.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused",
"range": "3:5:3:11"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "3:5:3:11"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "3:1:4:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `unused`\nHint: consider removing this variable or prefixing with underscore: `_unused`",
"range": "3:5:3:11"
}
]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/closure_capture.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_not_captured",
"range": "2:5:2:24"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_not_captured`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "2:5:2:24"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "2:1:3:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `unused_not_captured`\nHint: consider removing this variable or prefixing with underscore: `_unused_not_captured`",
"range": "2:5:2:24"
}
]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/conditional_usage.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused",
"range": "4:5:4:11"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "4:5:4:11"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "4:1:5:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `unused`\nHint: consider removing this variable or prefixing with underscore: `_unused`",
"range": "4:5:4:11"
}
]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/contextual_usage.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_ctx",
"range": "2:5:2:15"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_ctx`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "2:5:2:15"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "2:1:3:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `unused_ctx`\nHint: consider removing this variable or prefixing with underscore: `_unused_ctx`",
"range": "2:5:2:15"
}
]

View file

@ -0,0 +1,8 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/ieee.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/cross_module_usage.typ
---
[]

View file

@ -0,0 +1,81 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_array.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_x",
"range": "6:15:6:23"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_x`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "6:15:6:23"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
}
],
"message": "unused variable: `unused_x`\nHint: consider removing this variable or prefixing with underscore: `_unused_x`",
"range": "6:15:6:23"
},
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_c2",
"range": "6:31:6:33"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `c2`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "6:31:6:33"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
}
],
"message": "unused variable: `c2`\nHint: consider removing this variable or prefixing with underscore: `_c2`",
"range": "6:31:6:33"
}
]

View file

@ -0,0 +1,81 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_dict.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_x",
"range": "6:18:6:26"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_x`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "6:18:6:26"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
}
],
"message": "unused variable: `unused_x`\nHint: consider removing this variable or prefixing with underscore: `_unused_x`",
"range": "6:18:6:26"
},
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_c2",
"range": "6:37:6:39"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `c2`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "6:37:6:39"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
}
],
"message": "unused variable: `c2`\nHint: consider removing this variable or prefixing with underscore: `_c2`",
"range": "6:37:6:39"
}
]

View file

@ -0,0 +1,45 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/destructuring_spread.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_rest",
"range": "4:11:4:22"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_rest`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "4:11:4:22"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
}
],
"message": "unused variable: `unused_rest`\nHint: consider removing this variable or prefixing with underscore: `_unused_rest`",
"range": "4:11:4:22"
}
]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/function_as_value.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_callback",
"range": "6:5:6:20"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_callback`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "6:5:6:20"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "6:1:7:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused function: `unused_callback`\nHint: consider removing this function or prefixing with underscore: `_unused_callback`",
"range": "6:5:6:20"
}
]

View file

@ -0,0 +1,45 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/loop_variables.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_item",
"range": "1:5:1:16"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_item`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "1:5:1:16"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
}
],
"message": "unused variable: `unused_item`\nHint: consider removing this variable or prefixing with underscore: `_unused_item`",
"range": "1:5:1:16"
}
]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/method_chain.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_obj",
"range": "8:5:8:15"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_obj`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "8:5:8:15"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "8:1:9:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `unused_obj`\nHint: consider removing this variable or prefixing with underscore: `_unused_obj`",
"range": "8:5:8:15"
}
]

View file

@ -0,0 +1,264 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/multiple_unused.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused1",
"range": "1:5:1:12"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused1`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "1:5:1:12"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "1:1:2:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `unused1`\nHint: consider removing this variable or prefixing with underscore: `_unused1`",
"range": "1:5:1:12"
},
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused2",
"range": "2:5:2:12"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused2`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "2:5:2:12"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "2:1:3:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `unused2`\nHint: consider removing this variable or prefixing with underscore: `_unused2`",
"range": "2:5:2:12"
},
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused3",
"range": "4:5:4:12"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused3`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "4:5:4:12"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "4:1:5:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `unused3`\nHint: consider removing this variable or prefixing with underscore: `_unused3`",
"range": "4:5:4:12"
},
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_func1",
"range": "6:5:6:17"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_func1`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "6:5:6:17"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "6:1:7:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused function: `unused_func1`\nHint: consider removing this function or prefixing with underscore: `_unused_func1`",
"range": "6:5:6:17"
},
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_func2",
"range": "8:5:8:17"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_func2`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "8:5:8:17"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "8:1:9:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused function: `unused_func2`\nHint: consider removing this function or prefixing with underscore: `_unused_func2`",
"range": "8:5:8:17"
}
]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/nested_scope.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_inner_unused",
"range": "4:6:4:18"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `inner_unused`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "4:6:4:18"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "4:2:5:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `inner_unused`\nHint: consider removing this variable or prefixing with underscore: `_inner_unused`",
"range": "4:6:4:18"
}
]

View file

@ -0,0 +1,45 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/pattern_destructure.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_b",
"range": "1:14:1:22"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_b`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "1:14:1:22"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
}
],
"message": "unused variable: `unused_b`\nHint: consider removing this variable or prefixing with underscore: `_unused_b`",
"range": "1:14:1:22"
}
]

View file

@ -0,0 +1,8 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/recursive_function.typ
---
[]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/shadowing.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_x",
"range": "1:5:1:6"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `x`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "1:5:1:6"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "1:1:1:10"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `x`\nHint: consider removing this variable or prefixing with underscore: `_x`",
"range": "1:5:1:6"
}
]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/show_set_rules.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_style",
"range": "1:5:1:17"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_style`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "1:5:1:17"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "1:1:2:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `unused_style`\nHint: consider removing this variable or prefixing with underscore: `_unused_style`",
"range": "1:5:1:17"
}
]

View file

@ -0,0 +1,8 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/spread_test.typ
---
[]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/underscore_prefix.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_normal_unused",
"range": "4:5:4:18"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `normal_unused`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "4:5:4:18"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "4:1:5:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `normal_unused`\nHint: consider removing this variable or prefixing with underscore: `_normal_unused`",
"range": "4:5:4:18"
}
]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/unused_function.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_func",
"range": "1:5:1:16"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_func`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "1:5:1:16"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "1:1:4:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused function: `unused_func`\nHint: consider removing this function or prefixing with underscore: `_unused_func`",
"range": "1:5:1:16"
}
]

View file

@ -0,0 +1,45 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/unused_parameter.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_param",
"range": "1:22:1:34"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_param`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "1:22:1:34"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
}
],
"message": "unused variable: `unused_param`\nHint: if this parameter is intentionally unused, prefix it with underscore: `_unused_param`",
"range": "1:22:1:34"
}
]

View file

@ -0,0 +1,60 @@
---
source: crates/tinymist-query/src/code_action.rs
assertion_line: 180
description: Dead code code actions in /dummy-root/s0.typ
expression: "JsonRepr::new_pure(ordered_entries)"
input_file: crates/tinymist-query/src/fixtures/dead_code/unused_variable.typ
---
[
{
"actions": [
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_unused_var",
"range": "1:5:1:15"
}
]
}
},
"kind": "quickfix",
"title": "Prefix `_` to `unused_var`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "_",
"range": "1:5:1:15"
}
]
}
},
"kind": "quickfix",
"title": "Replace with `_`"
},
{
"edit": {
"changes": {
"s0.typ": [
{
"insertTextFormat": 1,
"newText": "",
"range": "1:1:2:0"
}
]
}
},
"kind": "quickfix",
"title": "Remove unused declaration"
}
],
"message": "unused variable: `unused_var`\nHint: consider removing this variable or prefixing with underscore: `_unused_var`",
"range": "1:5:1:15"
}
]

View file

@ -50,6 +50,40 @@ pub fn snapshot_testing_with(name: &str, opts: Opts, f: &impl Fn(&mut LocalConte
});
}
pub fn snapshot_testing_with_snapshots(
fixture_name: &str,
snapshot_name: &str,
opts: Opts,
f: &impl Fn(&mut LocalContext, PathBuf),
) {
let fixture_name = if fixture_name.is_empty() {
"playground"
} else {
fixture_name
};
let snapshot_name = if snapshot_name.is_empty() {
fixture_name
} else {
snapshot_name
};
let mut settings = tinymist_tests::Settings::new();
settings.set_prepend_module_to_snapshot(false);
settings.set_snapshot_path(format!("fixtures/{snapshot_name}/snaps"));
settings.bind(|| {
let glob_path = format!("fixtures/{fixture_name}/*.typ");
tinymist_tests::glob!(&glob_path, |path| {
let contents = std::fs::read_to_string(path).unwrap();
#[cfg(windows)]
let contents = contents.replace("\r\n", "\n");
tinymist_tests::run_with_sources(&contents, |verse, path| {
run_with_ctx_(verse, path, opts, f);
});
});
});
}
pub fn run_with_ctx<T>(
verse: &mut LspUniverse,
path: PathBuf,