mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(lsp): show test code lens for template literal names (#21798)
This commit is contained in:
parent
aadcd64065
commit
bac51f66aa
1 changed files with 64 additions and 5 deletions
|
@ -108,12 +108,17 @@ impl DenoTestCollector {
|
|||
&key_value_prop.key
|
||||
{
|
||||
if sym == "name" {
|
||||
if let ast::Expr::Lit(ast::Lit::Str(lit_str)) =
|
||||
key_value_prop.value.as_ref()
|
||||
{
|
||||
match key_value_prop.value.as_ref() {
|
||||
ast::Expr::Lit(ast::Lit::Str(lit_str)) => {
|
||||
let name = lit_str.value.to_string();
|
||||
self.add_code_lenses(name, range);
|
||||
}
|
||||
ast::Expr::Tpl(tpl) if tpl.quasis.len() == 1 => {
|
||||
let name = tpl.quasis.first().unwrap().raw.to_string();
|
||||
self.add_code_lenses(name, range);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,6 +135,10 @@ impl DenoTestCollector {
|
|||
let name = lit_str.value.to_string();
|
||||
self.add_code_lenses(name, range);
|
||||
}
|
||||
ast::Expr::Tpl(tpl) if tpl.quasis.len() == 1 => {
|
||||
let name = tpl.quasis.first().unwrap().raw.to_string();
|
||||
self.add_code_lenses(name, range);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -547,6 +556,8 @@ mod tests {
|
|||
Deno.test.ignore("test ignore", () => {});
|
||||
|
||||
Deno.test.only("test only", () => {});
|
||||
|
||||
Deno.test(`test template literal name`, () => {});
|
||||
"#;
|
||||
let parsed_module = deno_ast::parse_module(deno_ast::ParseParams {
|
||||
specifier: specifier.to_string(),
|
||||
|
@ -803,6 +814,54 @@ mod tests {
|
|||
}),
|
||||
data: None,
|
||||
},
|
||||
lsp::CodeLens {
|
||||
range: lsp::Range {
|
||||
start: lsp::Position {
|
||||
line: 14,
|
||||
character: 11,
|
||||
},
|
||||
end: lsp::Position {
|
||||
line: 14,
|
||||
character: 15,
|
||||
},
|
||||
},
|
||||
command: Some(lsp::Command {
|
||||
title: "▶\u{fe0e} Run Test".to_string(),
|
||||
command: "deno.test".to_string(),
|
||||
arguments: Some(vec![
|
||||
json!("https://deno.land/x/mod.ts"),
|
||||
json!("test template literal name"),
|
||||
json!({
|
||||
"inspect": false,
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
data: None,
|
||||
},
|
||||
lsp::CodeLens {
|
||||
range: lsp::Range {
|
||||
start: lsp::Position {
|
||||
line: 14,
|
||||
character: 11,
|
||||
},
|
||||
end: lsp::Position {
|
||||
line: 14,
|
||||
character: 15,
|
||||
},
|
||||
},
|
||||
command: Some(lsp::Command {
|
||||
title: "Debug".to_string(),
|
||||
command: "deno.test".to_string(),
|
||||
arguments: Some(vec![
|
||||
json!("https://deno.land/x/mod.ts"),
|
||||
json!("test template literal name"),
|
||||
json!({
|
||||
"inspect": true,
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
data: None,
|
||||
},
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue