@@ -8,7 +8,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
88
99use crate :: lsp_ext;
1010
11- pub ( crate ) type CheckFixes = Arc < FxHashMap < FileId , Vec < Fix > > > ;
11+ pub ( crate ) type CheckFixes = Arc < FxHashMap < usize , FxHashMap < FileId , Vec < Fix > > > > ;
1212
1313#[ derive( Debug , Default , Clone ) ]
1414pub struct DiagnosticsMapConfig {
@@ -22,7 +22,7 @@ pub(crate) struct DiagnosticCollection {
2222 // FIXME: should be FxHashMap<FileId, Vec<ra_id::Diagnostic>>
2323 pub ( crate ) native : FxHashMap < FileId , Vec < lsp_types:: Diagnostic > > ,
2424 // FIXME: should be Vec<flycheck::Diagnostic>
25- pub ( crate ) check : FxHashMap < FileId , Vec < lsp_types:: Diagnostic > > ,
25+ pub ( crate ) check : FxHashMap < usize , FxHashMap < FileId , Vec < lsp_types:: Diagnostic > > > ,
2626 pub ( crate ) check_fixes : CheckFixes ,
2727 changes : FxHashSet < FileId > ,
2828}
@@ -35,9 +35,19 @@ pub(crate) struct Fix {
3535}
3636
3737impl DiagnosticCollection {
38- pub ( crate ) fn clear_check ( & mut self ) {
38+ pub ( crate ) fn clear_check ( & mut self , flycheck_id : usize ) {
39+ if let Some ( it) = Arc :: make_mut ( & mut self . check_fixes ) . get_mut ( & flycheck_id) {
40+ it. clear ( ) ;
41+ }
42+ if let Some ( it) = self . check . get_mut ( & flycheck_id) {
43+ self . changes . extend ( it. drain ( ) . map ( |( key, _value) | key) ) ;
44+ }
45+ }
46+
47+ pub ( crate ) fn clear_check_all ( & mut self ) {
3948 Arc :: make_mut ( & mut self . check_fixes ) . clear ( ) ;
40- self . changes . extend ( self . check . drain ( ) . map ( |( key, _value) | key) )
49+ self . changes
50+ . extend ( self . check . values_mut ( ) . flat_map ( |it| it. drain ( ) . map ( |( key, _value) | key) ) )
4151 }
4252
4353 pub ( crate ) fn clear_native_for ( & mut self , file_id : FileId ) {
@@ -47,20 +57,22 @@ impl DiagnosticCollection {
4757
4858 pub ( crate ) fn add_check_diagnostic (
4959 & mut self ,
60+ flycheck_id : usize ,
5061 file_id : FileId ,
5162 diagnostic : lsp_types:: Diagnostic ,
5263 fix : Option < Fix > ,
5364 ) {
54- let diagnostics = self . check . entry ( file_id) . or_default ( ) ;
65+ let diagnostics = self . check . entry ( flycheck_id ) . or_default ( ) . entry ( file_id) . or_default ( ) ;
5566 for existing_diagnostic in diagnostics. iter ( ) {
5667 if are_diagnostics_equal ( existing_diagnostic, & diagnostic) {
5768 return ;
5869 }
5970 }
6071
6172 let check_fixes = Arc :: make_mut ( & mut self . check_fixes ) ;
62- check_fixes. entry ( file_id) . or_default ( ) . extend ( fix) ;
73+ check_fixes. entry ( flycheck_id ) . or_default ( ) . entry ( file_id) . or_default ( ) . extend ( fix) ;
6374 diagnostics. push ( diagnostic) ;
75+ tracing:: warn!( ?flycheck_id, ?file_id, "add_check_diagnostic changes pushed" ) ;
6476 self . changes . insert ( file_id) ;
6577 }
6678
@@ -89,7 +101,8 @@ impl DiagnosticCollection {
89101 file_id : FileId ,
90102 ) -> impl Iterator < Item = & lsp_types:: Diagnostic > {
91103 let native = self . native . get ( & file_id) . into_iter ( ) . flatten ( ) ;
92- let check = self . check . get ( & file_id) . into_iter ( ) . flatten ( ) ;
104+ let check =
105+ self . check . values ( ) . filter_map ( move |it| it. get ( & file_id) ) . into_iter ( ) . flatten ( ) ;
93106 native. chain ( check)
94107 }
95108
0 commit comments