@@ -283,24 +283,27 @@ fn to_lsp_diagnostic(
283283 range = diagnostic_range. to_range ( source_kind. source_code ( ) , index, encoding) ;
284284 }
285285
286- let ( severity, tags, code) = if let Some ( code) = code {
287- let code = code. to_string ( ) ;
286+ let ( severity, code) = if let Some ( code) = code {
287+ ( severity ( code) , code. to_string ( ) )
288+ } else {
288289 (
289- Some ( severity ( & code) ) ,
290- tags ( diagnostic) ,
291- Some ( lsp_types:: NumberOrString :: String ( code) ) ,
290+ match diagnostic. severity ( ) {
291+ ruff_db:: diagnostic:: Severity :: Info => lsp_types:: DiagnosticSeverity :: INFORMATION ,
292+ ruff_db:: diagnostic:: Severity :: Warning => lsp_types:: DiagnosticSeverity :: WARNING ,
293+ ruff_db:: diagnostic:: Severity :: Error => lsp_types:: DiagnosticSeverity :: ERROR ,
294+ ruff_db:: diagnostic:: Severity :: Fatal => lsp_types:: DiagnosticSeverity :: ERROR ,
295+ } ,
296+ diagnostic. id ( ) . to_string ( ) ,
292297 )
293- } else {
294- ( None , None , None )
295298 } ;
296299
297300 (
298301 cell,
299302 lsp_types:: Diagnostic {
300303 range,
301- severity,
302- tags,
303- code,
304+ severity : Some ( severity ) ,
305+ tags : tags ( diagnostic ) ,
306+ code : Some ( lsp_types :: NumberOrString :: String ( code ) ) ,
304307 code_description : diagnostic. documentation_url ( ) . and_then ( |url| {
305308 Some ( lsp_types:: CodeDescription {
306309 href : lsp_types:: Url :: parse ( url) . ok ( ) ?,
0 commit comments