File tree Expand file tree Collapse file tree 3 files changed +45
-4
lines changed Expand file tree Collapse file tree 3 files changed +45
-4
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,12 @@ pub enum NumberOrString {
29
29
String ( String ) ,
30
30
}
31
31
32
+ #[ derive( Debug , Clone ) ]
33
+ pub enum DiagnosticTag {
34
+ Unnecessary ,
35
+ Deprecated ,
36
+ }
37
+
32
38
/// Corresponds to [`lsp_types::Diagnostic`](https://docs.rs/lsp-types/0.91.0/lsp_types/struct.Diagnostic.html)
33
39
#[ derive( Debug , Clone ) ]
34
40
pub struct Diagnostic {
@@ -37,4 +43,6 @@ pub struct Diagnostic {
37
43
pub message : String ,
38
44
pub severity : Option < Severity > ,
39
45
pub code : Option < NumberOrString > ,
46
+ pub tags : Option < Vec < DiagnosticTag > > ,
47
+ pub source : Option < String > ,
40
48
}
Original file line number Diff line number Diff line change @@ -84,15 +84,33 @@ pub mod util {
84
84
None => None ,
85
85
} ;
86
86
87
+ let tags = if let Some ( ref tags) = diag. tags {
88
+ let new_tags = tags
89
+ . iter ( )
90
+ . map ( |tag| match tag {
91
+ helix_core:: diagnostic:: DiagnosticTag :: Unnecessary => {
92
+ lsp:: DiagnosticTag :: UNNECESSARY
93
+ }
94
+ helix_core:: diagnostic:: DiagnosticTag :: Deprecated => {
95
+ lsp:: DiagnosticTag :: DEPRECATED
96
+ }
97
+ } )
98
+ . collect ( ) ;
99
+
100
+ Some ( new_tags)
101
+ } else {
102
+ None
103
+ } ;
104
+
87
105
// TODO: add support for Diagnostic.data
88
106
lsp:: Diagnostic :: new (
89
107
range_to_lsp_range ( doc, range, offset_encoding) ,
90
108
severity,
91
109
code,
92
- None ,
110
+ diag . source . clone ( ) ,
93
111
diag. message . to_owned ( ) ,
94
112
None ,
95
- None ,
113
+ tags ,
96
114
)
97
115
}
98
116
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use arc_swap::{access::Map, ArcSwap};
2
2
use futures_util:: Stream ;
3
3
use helix_core:: {
4
4
config:: { default_syntax_loader, user_syntax_loader} ,
5
- diagnostic:: NumberOrString ,
5
+ diagnostic:: { DiagnosticTag , NumberOrString } ,
6
6
pos_at_coords, syntax, Selection ,
7
7
} ;
8
8
use helix_lsp:: { lsp, util:: lsp_pos_to_pos, LspProgressMap } ;
@@ -605,13 +605,28 @@ impl Application {
605
605
None => None ,
606
606
} ;
607
607
608
+ let tags = if let Some ( ref tags) = diagnostic. tags {
609
+ let new_tags = tags. iter ( ) . filter_map ( |tag| {
610
+ match * tag {
611
+ lsp:: DiagnosticTag :: DEPRECATED => Some ( DiagnosticTag :: Deprecated ) ,
612
+ lsp:: DiagnosticTag :: UNNECESSARY => Some ( DiagnosticTag :: Unnecessary ) ,
613
+ _ => None
614
+ }
615
+ } ) . collect ( ) ;
616
+
617
+ Some ( new_tags)
618
+ } else {
619
+ None
620
+ } ;
621
+
608
622
Some ( Diagnostic {
609
623
range : Range { start, end } ,
610
624
line : diagnostic. range . start . line as usize ,
611
625
message : diagnostic. message . clone ( ) ,
612
626
severity,
613
627
code,
614
- // source
628
+ tags,
629
+ source : diagnostic. source . clone ( )
615
630
} )
616
631
} )
617
632
. collect ( ) ;
You can’t perform that action at this time.
0 commit comments