summaryrefslogtreecommitdiff
path: root/cli/lsp/code_lens.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/lsp/code_lens.rs')
-rw-r--r--cli/lsp/code_lens.rs82
1 files changed, 77 insertions, 5 deletions
diff --git a/cli/lsp/code_lens.rs b/cli/lsp/code_lens.rs
index 635f34916..42c9123fb 100644
--- a/cli/lsp/code_lens.rs
+++ b/cli/lsp/code_lens.rs
@@ -80,14 +80,32 @@ impl DenoTestCollector {
}
}
- fn add_code_lens<N: AsRef<str>>(&mut self, name: N, span: &Span) {
+ fn add_code_lenses<N: AsRef<str>>(&mut self, name: N, span: &Span) {
let range = span_to_range(span, &self.parsed_source);
+ self.add_code_lens(&name, range, "▶\u{fe0e} Run Test", false);
+ self.add_code_lens(&name, range, "Debug", true);
+ }
+
+ fn add_code_lens<N: AsRef<str>>(
+ &mut self,
+ name: &N,
+ range: lsp::Range,
+ title: &str,
+ inspect: bool,
+ ) {
+ let options = json!({
+ "inspect": inspect,
+ });
self.code_lenses.push(lsp::CodeLens {
range,
command: Some(lsp::Command {
- title: "▶\u{fe0e} Run Test".to_string(),
+ title: title.to_string(),
command: "deno.test".to_string(),
- arguments: Some(vec![json!(self.specifier), json!(name.as_ref())]),
+ arguments: Some(vec![
+ json!(self.specifier),
+ json!(name.as_ref()),
+ options,
+ ]),
}),
data: None,
});
@@ -106,7 +124,7 @@ impl DenoTestCollector {
key_value_prop.value.as_ref()
{
let name = lit_str.value.to_string();
- self.add_code_lens(name, span);
+ self.add_code_lenses(name, span);
}
}
}
@@ -116,7 +134,7 @@ impl DenoTestCollector {
}
ast::Expr::Lit(ast::Lit::Str(lit_str)) => {
let name = lit_str.value.to_string();
- self.add_code_lens(name, span);
+ self.add_code_lenses(name, span);
}
_ => (),
}
@@ -581,6 +599,33 @@ mod tests {
arguments: Some(vec![
json!("https://deno.land/x/mod.ts"),
json!("test a"),
+ json!({
+ "inspect": false,
+ }),
+ ])
+ }),
+ data: None,
+ },
+ lsp::CodeLens {
+ range: lsp::Range {
+ start: lsp::Position {
+ line: 1,
+ character: 11
+ },
+ end: lsp::Position {
+ line: 1,
+ 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 a"),
+ json!({
+ "inspect": true,
+ }),
])
}),
data: None,
@@ -602,6 +647,33 @@ mod tests {
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: 6,
+ character: 11
+ },
+ end: lsp::Position {
+ line: 6,
+ 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 b"),
+ json!({
+ "inspect": true,
+ }),
])
}),
data: None,