@@ -15,7 +15,7 @@ use hir_def::{
1515 hir:: { ExprId , PatId } ,
1616} ;
1717use hir_ty:: { Interner , Substitution , TyExt , TypeFlags } ;
18- use ide:: { LineCol , RootDatabase } ;
18+ use ide:: { Analysis , AnnotationConfig , DiagnosticsConfig , InlayHintsConfig , LineCol , RootDatabase } ;
1919use ide_db:: {
2020 base_db:: {
2121 salsa:: { self , debug:: DebugQueryTable , ParallelDatabase } ,
@@ -30,7 +30,7 @@ use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustLibSourc
3030use rayon:: prelude:: * ;
3131use rustc_hash:: FxHashSet ;
3232use syntax:: { AstNode , SyntaxNode } ;
33- use vfs:: { AbsPathBuf , Vfs , VfsPath } ;
33+ use vfs:: { AbsPathBuf , FileId , Vfs , VfsPath } ;
3434
3535use crate :: cli:: {
3636 flags:: { self , OutputFormat } ,
@@ -149,8 +149,10 @@ impl flags::AnalysisStats {
149149 let mut bodies = Vec :: new ( ) ;
150150 let mut adts = Vec :: new ( ) ;
151151 let mut consts = Vec :: new ( ) ;
152+ let mut file_ids = Vec :: new ( ) ;
152153 while let Some ( module) = visit_queue. pop ( ) {
153154 if visited_modules. insert ( module) {
155+ file_ids. extend ( module. as_source_file_id ( db) ) ;
154156 visit_queue. extend ( module. children ( db) ) ;
155157
156158 for decl in module. declarations ( db) {
@@ -224,6 +226,10 @@ impl flags::AnalysisStats {
224226 self . run_const_eval ( db, & consts, verbosity) ;
225227 }
226228
229+ if self . run_all_ide_things {
230+ self . run_ide_things ( host. analysis ( ) , file_ids) ;
231+ }
232+
227233 let total_span = analysis_sw. elapsed ( ) ;
228234 eprintln ! ( "{:<20} {total_span}" , "Total:" ) ;
229235 report_metric ( "total time" , total_span. time . as_millis ( ) as u64 , "ms" ) ;
@@ -729,6 +735,83 @@ impl flags::AnalysisStats {
729735 report_metric ( "body lowering time" , body_lowering_time. time . as_millis ( ) as u64 , "ms" ) ;
730736 }
731737
738+ fn run_ide_things ( & self , analysis : Analysis , mut file_ids : Vec < FileId > ) {
739+ file_ids. sort ( ) ;
740+ file_ids. dedup ( ) ;
741+ let mut sw = self . stop_watch ( ) ;
742+
743+ for & file_id in & file_ids {
744+ _ = analysis. diagnostics (
745+ & DiagnosticsConfig {
746+ enabled : true ,
747+ proc_macros_enabled : true ,
748+ proc_attr_macros_enabled : true ,
749+ disable_experimental : false ,
750+ disabled : Default :: default ( ) ,
751+ expr_fill_default : Default :: default ( ) ,
752+ insert_use : ide_db:: imports:: insert_use:: InsertUseConfig {
753+ granularity : ide_db:: imports:: insert_use:: ImportGranularity :: Crate ,
754+ enforce_granularity : true ,
755+ prefix_kind : hir:: PrefixKind :: ByCrate ,
756+ group : true ,
757+ skip_glob_imports : true ,
758+ } ,
759+ prefer_no_std : Default :: default ( ) ,
760+ } ,
761+ ide:: AssistResolveStrategy :: All ,
762+ file_id,
763+ ) ;
764+ }
765+ for & file_id in & file_ids {
766+ _ = analysis. inlay_hints (
767+ & InlayHintsConfig {
768+ render_colons : false ,
769+ type_hints : true ,
770+ discriminant_hints : ide:: DiscriminantHints :: Always ,
771+ parameter_hints : true ,
772+ chaining_hints : true ,
773+ adjustment_hints : ide:: AdjustmentHints :: Always ,
774+ adjustment_hints_mode : ide:: AdjustmentHintsMode :: Postfix ,
775+ adjustment_hints_hide_outside_unsafe : false ,
776+ closure_return_type_hints : ide:: ClosureReturnTypeHints :: Always ,
777+ closure_capture_hints : true ,
778+ binding_mode_hints : true ,
779+ lifetime_elision_hints : ide:: LifetimeElisionHints :: Always ,
780+ param_names_for_lifetime_elision_hints : true ,
781+ hide_named_constructor_hints : false ,
782+ hide_closure_initialization_hints : false ,
783+ closure_style : hir:: ClosureStyle :: ImplFn ,
784+ max_length : Some ( 25 ) ,
785+ closing_brace_hints_min_lines : Some ( 20 ) ,
786+ } ,
787+ file_id,
788+ None ,
789+ ) ;
790+ }
791+ for & file_id in & file_ids {
792+ analysis
793+ . annotations (
794+ & AnnotationConfig {
795+ binary_target : true ,
796+ annotate_runnables : true ,
797+ annotate_impls : true ,
798+ annotate_references : false ,
799+ annotate_method_references : false ,
800+ annotate_enum_variant_references : false ,
801+ location : ide:: AnnotationLocation :: AboveName ,
802+ } ,
803+ file_id,
804+ )
805+ . unwrap ( )
806+ . into_iter ( )
807+ . for_each ( |annotation| {
808+ _ = analysis. resolve_annotation ( annotation) ;
809+ } ) ;
810+ }
811+ let ide_time = sw. elapsed ( ) ;
812+ eprintln ! ( "{:<20} {} ({} files)" , "IDE:" , ide_time, file_ids. len( ) ) ;
813+ }
814+
732815 fn stop_watch ( & self ) -> StopWatch {
733816 StopWatch :: start ( ) . memory ( self . memory_usage )
734817 }
0 commit comments