1- use std:: { collections :: HashSet , sync:: Arc } ;
1+ use std:: sync:: Arc ;
22
33pub use super :: checker:: DiagnosticContext ;
4- use super :: { checker:: check_file, DiagnosticCode } ;
4+ use super :: { checker:: check_file, lua_diagnostic_config :: LuaDiagnosticConfig } ;
55use crate :: { Emmyrc , FileId , LuaCompilation } ;
66use lsp_types:: Diagnostic ;
77use tokio_util:: sync:: CancellationToken ;
88
99#[ derive( Debug ) ]
1010pub struct LuaDiagnostic {
1111 enable : bool ,
12- workspace_enabled : Arc < HashSet < DiagnosticCode > > ,
13- workspace_disabled : Arc < HashSet < DiagnosticCode > > ,
12+ config : Arc < LuaDiagnosticConfig > ,
1413}
1514
1615impl LuaDiagnostic {
1716 pub fn new ( ) -> Self {
1817 Self {
1918 enable : true ,
20- workspace_enabled : HashSet :: new ( ) . into ( ) ,
21- workspace_disabled : HashSet :: new ( ) . into ( ) ,
19+ config : Arc :: new ( LuaDiagnosticConfig :: default ( ) ) ,
2220 }
2321 }
2422
2523 pub fn update_config ( & mut self , emmyrc : Arc < Emmyrc > ) {
2624 self . enable = emmyrc. diagnostics . enable ;
27- self . workspace_disabled = Arc :: new ( emmyrc. diagnostics . disable . iter ( ) . cloned ( ) . collect ( ) ) ;
28- self . workspace_enabled = Arc :: new ( emmyrc. diagnostics . enables . iter ( ) . cloned ( ) . collect ( ) ) ;
25+ self . config = LuaDiagnosticConfig :: new ( & emmyrc) . into ( ) ;
2926 }
3027
3128 pub async fn diagnose_file (
@@ -44,12 +41,7 @@ impl LuaDiagnostic {
4441
4542 let db = compilation. get_db ( ) ;
4643 let mut semantic_model = compilation. get_semantic_model ( file_id) ?;
47- let mut context = DiagnosticContext :: new (
48- file_id,
49- db,
50- self . workspace_enabled . clone ( ) ,
51- self . workspace_disabled . clone ( ) ,
52- ) ;
44+ let mut context = DiagnosticContext :: new ( file_id, db, self . config . clone ( ) ) ;
5345
5446 check_file ( & mut context, & mut semantic_model) ;
5547
0 commit comments