New LSP quickfix for 'use let' warning.
This commit is contained in:
parent
e9e26b969a
commit
2070576e46
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
## v1.0.29-alpha - UNRELEASED
|
## v1.0.29-alpha - UNRELEASED
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **aiken-lang**: new LSP quickfix for 'use let' warning. @KtorZ
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- **aiken-lang**: the keyword `fail` on property-based test semantic has changed and now consider a test to succeed only if **every** execution of the test failed (instead of just one). The previous behavior can be recovered by adding the keyword `once` after `fail`. @KtorZ
|
- **aiken-lang**: the keyword `fail` on property-based test semantic has changed and now consider a test to succeed only if **every** execution of the test failed (instead of just one). The previous behavior can be recovered by adding the keyword `once` after `fail`. @KtorZ
|
||||||
|
|
|
@ -10,6 +10,7 @@ const UNKNOWN_CONSTRUCTOR: &str = "aiken::check::unknown::type_constructor";
|
||||||
const UNKNOWN_MODULE: &str = "aiken::check::unknown::module";
|
const UNKNOWN_MODULE: &str = "aiken::check::unknown::module";
|
||||||
const UNUSED_IMPORT_VALUE: &str = "aiken::check::unused:import::value";
|
const UNUSED_IMPORT_VALUE: &str = "aiken::check::unused:import::value";
|
||||||
const UNUSED_IMPORT_MODULE: &str = "aiken::check::unused::import::module";
|
const UNUSED_IMPORT_MODULE: &str = "aiken::check::unused::import::module";
|
||||||
|
const USE_LET: &str = "aiken::check::single_constructor_expect";
|
||||||
const UTF8_BYTE_ARRAY_IS_VALID_HEX_STRING: &str =
|
const UTF8_BYTE_ARRAY_IS_VALID_HEX_STRING: &str =
|
||||||
"aiken::check::syntax::bytearray_literal_is_hex_string";
|
"aiken::check::syntax::bytearray_literal_is_hex_string";
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@ pub enum Quickfix {
|
||||||
UnknownConstructor(lsp_types::Diagnostic),
|
UnknownConstructor(lsp_types::Diagnostic),
|
||||||
UnusedImports(Vec<lsp_types::Diagnostic>),
|
UnusedImports(Vec<lsp_types::Diagnostic>),
|
||||||
Utf8ByteArrayIsValidHexString(lsp_types::Diagnostic),
|
Utf8ByteArrayIsValidHexString(lsp_types::Diagnostic),
|
||||||
|
UseLet(lsp_types::Diagnostic),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_code(
|
fn match_code(
|
||||||
|
@ -65,6 +67,10 @@ pub fn assert(diagnostic: lsp_types::Diagnostic) -> Option<Quickfix> {
|
||||||
return Some(Quickfix::Utf8ByteArrayIsValidHexString(diagnostic));
|
return Some(Quickfix::Utf8ByteArrayIsValidHexString(diagnostic));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if match_code(&diagnostic, Severity::WARNING, USE_LET) {
|
||||||
|
return Some(Quickfix::UseLet(diagnostic));
|
||||||
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +122,12 @@ pub fn quickfix(
|
||||||
diagnostic,
|
diagnostic,
|
||||||
utf8_byte_array_is_hex_string(diagnostic),
|
utf8_byte_array_is_hex_string(diagnostic),
|
||||||
),
|
),
|
||||||
|
Quickfix::UseLet(diagnostic) => each_as_distinct_action(
|
||||||
|
&mut actions,
|
||||||
|
text_document,
|
||||||
|
diagnostic,
|
||||||
|
use_let(diagnostic),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,3 +297,13 @@ fn utf8_byte_array_is_hex_string(diagnostic: &lsp_types::Diagnostic) -> Vec<Anno
|
||||||
|
|
||||||
edits
|
edits
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn use_let(diagnostic: &lsp_types::Diagnostic) -> Vec<AnnotatedEdit> {
|
||||||
|
vec![(
|
||||||
|
"Use 'let' instead of 'expect'".to_string(),
|
||||||
|
lsp_types::TextEdit {
|
||||||
|
range: diagnostic.range,
|
||||||
|
new_text: "let".to_string(),
|
||||||
|
},
|
||||||
|
)]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue