@@ -311,9 +311,13 @@ pub fn diagnostics(
311311 FileRange { file_id, range : err. range ( ) } ,
312312 )
313313 } ) ) ;
314+ let parse_errors = res. len ( ) ;
314315
315316 let parse = sema. parse ( file_id) ;
316317
318+ // FIXME: This iterates the entire file which is a rather expensive operation.
319+ // We should implement these differently in some form?
320+ // Salsa caching + incremental re-parse would be better here
317321 for node in parse. syntax ( ) . descendants ( ) {
318322 handlers:: useless_braces:: useless_braces ( & mut res, file_id, & node) ;
319323 handlers:: field_shorthand:: field_shorthand ( & mut res, file_id, & node) ;
@@ -326,7 +330,10 @@ pub fn diagnostics(
326330
327331 let mut diags = Vec :: new ( ) ;
328332 match module {
329- Some ( m) => m. diagnostics ( db, & mut diags, config. style_lints ) ,
333+ // A bunch of parse errors in a file indicate some bigger structural parse changes in the
334+ // file, so we skip semantic diagnostics so we can show these faster.
335+ Some ( m) if parse_errors < 16 => m. diagnostics ( db, & mut diags, config. style_lints ) ,
336+ Some ( _) => ( ) ,
330337 None => handlers:: unlinked_file:: unlinked_file ( & ctx, & mut res, file_id) ,
331338 }
332339
0 commit comments