@@ -189,9 +189,10 @@ impl ServerState {
189189 stats : Arc :: default ( ) ,
190190 } ) ;
191191
192- let mut hooks: Vec < Box < dyn CompileHook + Send + Sync > > = Vec :: new ( ) ;
193- hooks. push ( Box :: new ( DiagHook :: new ( analysis. clone ( ) , editor_tx. clone ( ) ) ) ) ;
194- hooks. push ( Box :: new ( LintHook :: new ( analysis. clone ( ) , editor_tx. clone ( ) ) ) ) ;
192+ let mut hooks: Vec < Box < dyn CompileHook + Send + Sync > > = vec ! [
193+ Box :: new( DiagHook :: new( analysis. clone( ) , editor_tx. clone( ) ) ) ,
194+ Box :: new( LintHook :: new( analysis. clone( ) , editor_tx. clone( ) ) ) ,
195+ ] ;
195196 #[ cfg( feature = "preview" ) ]
196197 hooks. push ( Box :: new ( PreviewHook :: new ( preview) ) ) ;
197198 #[ cfg( feature = "export" ) ]
@@ -466,12 +467,14 @@ fn push_editor_diagnostics(
466467 . log_error ( "failed to send diagnostics" ) ;
467468}
468469
470+ /// A hook that handles diagnostics.
469471pub struct DiagHook {
470472 analysis : Arc < Analysis > ,
471473 editor_tx : EditorSender ,
472474}
473475
474476impl DiagHook {
477+ /// Creates a new diagnostics hook.
475478 pub fn new ( analysis : Arc < Analysis > , editor_tx : EditorSender ) -> Self {
476479 Self {
477480 analysis,
@@ -499,8 +502,11 @@ impl DiagHook {
499502 }
500503}
501504
505+ /// A hook that handles compilation events.
502506pub trait CompileHook {
507+ /// Notifies the hook of a compilation result.
503508 fn notify ( & self , dv : ProjVersion , art : & LspCompiledArtifact , client : & Arc < dyn ProjectClient > ) ;
509+ /// Notifies the hook of a compilation status.
504510 fn status ( & self , _revision : usize , _rep : & CompileReport ) { }
505511}
506512
@@ -515,12 +521,14 @@ impl CompileHook for DiagHook {
515521 }
516522}
517523
524+ /// A hook that handles linting.
518525pub struct LintHook {
519526 analysis : Arc < Analysis > ,
520527 editor_tx : EditorSender ,
521528}
522529
523530impl LintHook {
531+ /// Creates a new lint hook.
524532 pub fn new ( analysis : Arc < Analysis > , editor_tx : EditorSender ) -> Self {
525533 Self {
526534 analysis,
@@ -584,12 +592,14 @@ impl CompileHook for LintHook {
584592
585593#[ cfg( feature = "preview" ) ]
586594#[ derive( Clone ) ]
595+ /// A hook that handles preview.
587596pub struct PreviewHook {
588597 state : ProjectPreviewState ,
589598}
590599
591600#[ cfg( feature = "preview" ) ]
592601impl PreviewHook {
602+ /// Creates a new preview hook.
593603 pub fn new ( state : ProjectPreviewState ) -> Self {
594604 Self { state }
595605 }
@@ -616,6 +626,7 @@ impl PreviewHook {
616626 }
617627 }
618628
629+ #[ allow( dead_code) ]
619630 fn state ( & self ) -> ProjectPreviewState {
620631 self . state . clone ( )
621632 }
@@ -639,16 +650,19 @@ impl CompileHook for PreviewHook {
639650
640651#[ cfg( feature = "export" ) ]
641652#[ derive( Clone ) ]
653+ /// A hook that handles export.
642654pub struct ExportHook {
643655 task : crate :: task:: ExportTask ,
644656}
645657
646658#[ cfg( feature = "export" ) ]
647659impl ExportHook {
660+ /// Creates a new export hook.
648661 pub fn new ( task : crate :: task:: ExportTask ) -> Self {
649662 Self { task }
650663 }
651664
665+ #[ allow( dead_code) ]
652666 fn task ( & self ) -> crate :: task:: ExportTask {
653667 self . task . clone ( )
654668 }
0 commit comments