Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions crates/ty_server/src/server/api/requests/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use lsp_types::request::DocumentDiagnosticRequest;
use lsp_types::{
Diagnostic, DiagnosticSeverity, DiagnosticTag, DocumentDiagnosticParams,
DocumentDiagnosticReport, DocumentDiagnosticReportResult, FullDocumentDiagnosticReport,
NumberOrString, Range, RelatedFullDocumentDiagnosticReport, Url,
NumberOrString, Range, RelatedFullDocumentDiagnosticReport,
};

use crate::document::ToRangeExt;
Expand All @@ -22,7 +22,7 @@ impl RequestHandler for DocumentDiagnosticRequestHandler {
}

impl BackgroundDocumentRequestHandler for DocumentDiagnosticRequestHandler {
fn document_url(params: &DocumentDiagnosticParams) -> Cow<Url> {
fn document_url(params: &DocumentDiagnosticParams) -> Cow<lsp_types::Url> {
Cow::Borrowed(&params.text_document.uri)
}

Expand Down Expand Up @@ -105,12 +105,23 @@ fn to_lsp_diagnostic(
})
.filter(|mapped_tags| !mapped_tags.is_empty());

let code_description = diagnostic
.id()
.is_lint()
.then(|| {
Some(lsp_types::CodeDescription {
href: lsp_types::Url::parse(&format!("https://ty.dev/rules#{}", diagnostic.id()))
.ok()?,
})
})
.flatten();

Diagnostic {
range,
severity: Some(severity),
tags,
code: Some(NumberOrString::String(diagnostic.id().to_string())),
code_description: None,
code_description,
source: Some("ty".into()),
message: diagnostic.concise_message().to_string(),
related_information: None,
Expand Down
Loading