mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix(lsp): add code lens for tests just using named functions (#13218)
Fixes: #13216
This commit is contained in:
parent
b064794695
commit
27fa51d0d4
1 changed files with 61 additions and 3 deletions
|
@ -118,8 +118,10 @@ impl DenoTestCollector {
|
|||
for prop in &obj_lit.props {
|
||||
if let ast::PropOrSpread::Prop(prop) = prop {
|
||||
if let ast::Prop::KeyValue(key_value_prop) = prop.as_ref() {
|
||||
if let ast::PropName::Ident(ident) = &key_value_prop.key {
|
||||
if ident.sym.to_string() == "name" {
|
||||
if let ast::PropName::Ident(ast::Ident { sym, .. }) =
|
||||
&key_value_prop.key
|
||||
{
|
||||
if sym == "name" {
|
||||
if let ast::Expr::Lit(ast::Lit::Str(lit_str)) =
|
||||
key_value_prop.value.as_ref()
|
||||
{
|
||||
|
@ -132,6 +134,12 @@ impl DenoTestCollector {
|
|||
}
|
||||
}
|
||||
}
|
||||
ast::Expr::Fn(fn_expr) => {
|
||||
if let Some(ast::Ident { sym, .. }) = fn_expr.ident.as_ref() {
|
||||
let name = sym.to_string();
|
||||
self.add_code_lenses(name, span);
|
||||
}
|
||||
}
|
||||
ast::Expr::Lit(ast::Lit::Str(lit_str)) => {
|
||||
let name = lit_str.value.to_string();
|
||||
self.add_code_lenses(name, span);
|
||||
|
@ -563,6 +571,8 @@ mod tests {
|
|||
fn() {}
|
||||
});
|
||||
|
||||
Deno.test(function useFnName() {});
|
||||
|
||||
Deno.test("test b", function anotherTest() {});
|
||||
"#
|
||||
.to_string(),
|
||||
|
@ -646,7 +656,7 @@ mod tests {
|
|||
command: "deno.test".to_string(),
|
||||
arguments: Some(vec![
|
||||
json!("https://deno.land/x/mod.ts"),
|
||||
json!("test b"),
|
||||
json!("useFnName"),
|
||||
json!({
|
||||
"inspect": false,
|
||||
}),
|
||||
|
@ -665,6 +675,54 @@ mod tests {
|
|||
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!("useFnName"),
|
||||
json!({
|
||||
"inspect": true,
|
||||
}),
|
||||
])
|
||||
}),
|
||||
data: None,
|
||||
},
|
||||
lsp::CodeLens {
|
||||
range: lsp::Range {
|
||||
start: lsp::Position {
|
||||
line: 8,
|
||||
character: 11
|
||||
},
|
||||
end: lsp::Position {
|
||||
line: 8,
|
||||
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 b"),
|
||||
json!({
|
||||
"inspect": false,
|
||||
}),
|
||||
])
|
||||
}),
|
||||
data: None,
|
||||
},
|
||||
lsp::CodeLens {
|
||||
range: lsp::Range {
|
||||
start: lsp::Position {
|
||||
line: 8,
|
||||
character: 11
|
||||
},
|
||||
end: lsp::Position {
|
||||
line: 8,
|
||||
character: 15
|
||||
}
|
||||
},
|
||||
command: Some(lsp::Command {
|
||||
title: "Debug".to_string(),
|
||||
command: "deno.test".to_string(),
|
||||
|
|
Loading…
Reference in a new issue