@@ -41,27 +41,32 @@ fn analyze_diagnostic_disable(
4141 } ;
4242
4343 let diagnostic_index = analyzer. db . get_diagnostic_index_mut ( ) ;
44- let diagnostic_code_list = diagnostic. get_code_list ( ) ? ;
45- for code in diagnostic_code_list. get_codes ( ) {
46- let name = code. get_name_text ( ) ;
47- let diagnostic_code = if let Some ( code) = DiagnosticCode :: from_str ( name) . ok ( ) {
48- code
49- } else {
50- continue ;
51- } ;
52-
53- if is_file_disable {
54- diagnostic_index. add_file_diagnostic_disabled ( analyzer. file_id , diagnostic_code) ;
55- } else {
56- diagnostic_index. add_diagnostic_action (
57- analyzer. file_id ,
58- DiagnosticAction :: new (
59- owner_block_range,
60- DiagnosticActionKind :: Disable ,
61- diagnostic_code ,
62- ) ,
63- ) ;
44+ if let Some ( diagnostic_code_list) = diagnostic. get_code_list ( ) {
45+ for code in diagnostic_code_list. get_codes ( ) {
46+ let name = code. get_name_text ( ) ;
47+ let diagnostic_code = if let Some ( code) = DiagnosticCode :: from_str ( name) . ok ( ) {
48+ code
49+ } else {
50+ continue ;
51+ } ;
52+
53+ if is_file_disable {
54+ diagnostic_index. add_file_diagnostic_disabled ( analyzer. file_id , diagnostic_code) ;
55+ } else {
56+ diagnostic_index. add_diagnostic_action (
57+ analyzer. file_id ,
58+ DiagnosticAction :: new (
59+ owner_block_range,
60+ DiagnosticActionKind :: Disable ( diagnostic_code ) ,
61+ ) ,
62+ ) ;
63+ }
6464 }
65+ } else {
66+ diagnostic_index. add_diagnostic_action (
67+ analyzer. file_id ,
68+ DiagnosticAction :: new ( owner_block_range, DiagnosticActionKind :: DisableAll ) ,
69+ ) ;
6570 }
6671
6772 Some ( ( ) )
@@ -79,18 +84,24 @@ fn analyze_diagnostic_disable_next_line(
7984 let valid_range = TextRange :: new ( comment_range. start ( ) , line_range. end ( ) ) ;
8085
8186 let diagnostic_index = analyzer. db . get_diagnostic_index_mut ( ) ;
82- let diagnostic_code_list = diagnostic. get_code_list ( ) ? ;
83- for code in diagnostic_code_list. get_codes ( ) {
84- let name = code. get_name_text ( ) ;
85- let diagnostic_code = if let Some ( code) = DiagnosticCode :: from_str ( name) . ok ( ) {
86- code
87- } else {
88- continue ;
89- } ;
87+ if let Some ( diagnostic_code_list) = diagnostic. get_code_list ( ) {
88+ for code in diagnostic_code_list. get_codes ( ) {
89+ let name = code. get_name_text ( ) ;
90+ let diagnostic_code = if let Some ( code) = DiagnosticCode :: from_str ( name) . ok ( ) {
91+ code
92+ } else {
93+ continue ;
94+ } ;
9095
96+ diagnostic_index. add_diagnostic_action (
97+ analyzer. file_id ,
98+ DiagnosticAction :: new ( valid_range, DiagnosticActionKind :: Disable ( diagnostic_code) ) ,
99+ ) ;
100+ }
101+ } else {
91102 diagnostic_index. add_diagnostic_action (
92103 analyzer. file_id ,
93- DiagnosticAction :: new ( valid_range, DiagnosticActionKind :: Disable , diagnostic_code ) ,
104+ DiagnosticAction :: new ( valid_range, DiagnosticActionKind :: DisableAll ) ,
94105 ) ;
95106 }
96107
@@ -108,18 +119,24 @@ fn analyze_diagnostic_disable_line(
108119 let valid_range = document. get_line_range ( comment_end_line) ?;
109120
110121 let diagnostic_index = analyzer. db . get_diagnostic_index_mut ( ) ;
111- let diagnostic_code_list = diagnostic. get_code_list ( ) ? ;
112- for code in diagnostic_code_list. get_codes ( ) {
113- let name = code. get_name_text ( ) ;
114- let diagnostic_code = if let Some ( code) = DiagnosticCode :: from_str ( name) . ok ( ) {
115- code
116- } else {
117- continue ;
118- } ;
122+ if let Some ( diagnostic_code_list) = diagnostic. get_code_list ( ) {
123+ for code in diagnostic_code_list. get_codes ( ) {
124+ let name = code. get_name_text ( ) ;
125+ let diagnostic_code = if let Some ( code) = DiagnosticCode :: from_str ( name) . ok ( ) {
126+ code
127+ } else {
128+ continue ;
129+ } ;
119130
131+ diagnostic_index. add_diagnostic_action (
132+ analyzer. file_id ,
133+ DiagnosticAction :: new ( valid_range, DiagnosticActionKind :: Disable ( diagnostic_code) ) ,
134+ ) ;
135+ }
136+ } else {
120137 diagnostic_index. add_diagnostic_action (
121138 analyzer. file_id ,
122- DiagnosticAction :: new ( valid_range, DiagnosticActionKind :: Disable , diagnostic_code ) ,
139+ DiagnosticAction :: new ( valid_range, DiagnosticActionKind :: DisableAll ) ,
123140 ) ;
124141 }
125142
0 commit comments