Skip to content

Commit e09a50d

Browse files
committed
feat: change warning diagnostics to window/showMessage
1 parent 16074f3 commit e09a50d

File tree

3 files changed

+11
-59
lines changed

3 files changed

+11
-59
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "testing-language-server"
3-
version = "0.1.6"
3+
version = "0.1.7"
44
edition = "2021"
55
description = "LSP server for testing"
66
license = "MIT"

src/server.rs

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -319,29 +319,17 @@ impl TestingLS {
319319
if !stderr.is_empty() {
320320
let message =
321321
"Cannot run test command: \n".to_string() + &String::from_utf8(stderr).unwrap();
322-
let placeholder_diagnostic = Diagnostic {
323-
range: Range {
324-
start: Position {
325-
line: 0,
326-
character: 0,
327-
},
328-
end: Position {
329-
line: 0,
330-
character: 0,
331-
},
332-
},
322+
let message_type = MessageType::ERROR;
323+
let params: ShowMessageParams = ShowMessageParams {
324+
typ: message_type,
333325
message,
334-
severity: Some(DiagnosticSeverity::WARNING),
335-
code_description: None,
336-
code: None,
337-
source: None,
338-
tags: None,
339-
related_information: None,
340-
data: None,
341326
};
342-
for path in paths {
343-
diagnostics.push((path.to_string(), vec![placeholder_diagnostic.clone()]));
344-
}
327+
send_stdout(&json!({
328+
"jsonrpc": "2.0",
329+
"method": "window/showMessage",
330+
"params": params,
331+
}))
332+
.unwrap();
345333
}
346334

347335
let adapter_result =
@@ -575,42 +563,6 @@ mod tests {
575563
assert_eq!(files, vec![test_file.to_str().unwrap()]);
576564
}
577565

578-
#[test]
579-
fn bubble_adapter_error() {
580-
let adapter_conf: AdapterConfiguration = AdapterConfiguration {
581-
path: std::env::current_dir()
582-
.unwrap()
583-
.join("target/debug/testing-ls-adapter")
584-
.to_str()
585-
.unwrap()
586-
.to_string(),
587-
extra_arg: vec!["--invalid-arg".to_string()],
588-
..Default::default()
589-
};
590-
let abs_path_of_demo = std::env::current_dir().unwrap().join("demo/rust");
591-
let files =
592-
TestingLS::project_files(&abs_path_of_demo.clone(), &["/**/*.rs".to_string()], &[]);
593-
594-
let server = TestingLS {
595-
workspace_folders: Some(vec![WorkspaceFolder {
596-
uri: Url::from_file_path(&abs_path_of_demo).unwrap(),
597-
name: "demo".to_string(),
598-
}]),
599-
options: InitializedOptions {
600-
adapter_command: HashMap::from([(String::from(".rs"), adapter_conf.clone())]),
601-
enable_workspace_diagnostics: Some(true),
602-
},
603-
workspaces_cache: Vec::new(),
604-
};
605-
let diagnostics = server
606-
.get_diagnostics(&adapter_conf, abs_path_of_demo.to_str().unwrap(), &files)
607-
.unwrap();
608-
assert_eq!(diagnostics.len(), 1);
609-
let diagnostic = diagnostics.first().unwrap().1.first().unwrap();
610-
assert_eq!(diagnostic.severity.unwrap(), DiagnosticSeverity::WARNING);
611-
assert!(diagnostic.message.contains("Cannot run test command:"));
612-
}
613-
614566
#[test]
615567
fn skip_workspace_diagnostics() {
616568
let mut server = TestingLS {

0 commit comments

Comments
 (0)