]> git.lizzy.rs Git - rust.git/commitdiff
Fill code_description for rust_analyzer diagnostics
authorLukas Wirth <lukastw97@gmail.com>
Wed, 18 Nov 2020 07:54:52 +0000 (08:54 +0100)
committerLukas Wirth <lukastw97@gmail.com>
Wed, 18 Nov 2020 07:54:52 +0000 (08:54 +0100)
crates/rust-analyzer/src/handlers.rs

index 118e7276f2b2e700ceba5a2b3c60ffdd69a97e79..1cf4139d2bb30e1a31525f212518d5fd28c33593 100644 (file)
@@ -1129,7 +1129,14 @@ pub(crate) fn publish_diagnostics(
             range: to_proto::range(&line_index, d.range),
             severity: Some(to_proto::diagnostic_severity(d.severity)),
             code: d.code.map(|d| d.as_str().to_owned()).map(NumberOrString::String),
-            code_description: None,
+            code_description: d.code.and_then(|code| {
+                lsp_types::Url::parse(&format!(
+                    "https://rust-analyzer.github.io/manual.html#{}",
+                    code.as_str()
+                ))
+                .ok()
+                .map(|href| lsp_types::CodeDescription { href })
+            }),
             source: Some("rust-analyzer".to_string()),
             message: d.message,
             related_information: None,