@@ -311,9 +311,13 @@ pub fn diagnostics(
311
311
FileRange { file_id, range : err. range ( ) } ,
312
312
)
313
313
} ) ) ;
314
+ let parse_errors = res. len ( ) ;
314
315
315
316
let parse = sema. parse ( file_id) ;
316
317
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
317
321
for node in parse. syntax ( ) . descendants ( ) {
318
322
handlers:: useless_braces:: useless_braces ( & mut res, file_id, & node) ;
319
323
handlers:: field_shorthand:: field_shorthand ( & mut res, file_id, & node) ;
@@ -326,7 +330,10 @@ pub fn diagnostics(
326
330
327
331
let mut diags = Vec :: new ( ) ;
328
332
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 ( _) => ( ) ,
330
337
None => handlers:: unlinked_file:: unlinked_file ( & ctx, & mut res, file_id) ,
331
338
}
332
339
0 commit comments