I'm having issues with the analyzer showing old errors on IDE (IntelliJ) when using code generation. Below you can find more information about this issue and a sample project which you can use to reproduce the issue.
Related issue: https://youtrack.jetbrains.com/issue/WEB-45208
Sample project: https://github.com/KlausJokinen/Jetbrains_code_generation_fail
Comment with a video which shows how the error occurs: https://youtrack.jetbrains.com/issue/WEB-45208#focus=Comments-27-4300830.0-0
Where are you generating the generated dart files? If it's within the regular source, the analysis server should see the changes. If it's in the .dart_tool/ directory, I believe this is a known issue - we don't watch for changes in that directory, so won't see updates until the analysis server is restarted.
Files are generated next to source files (lib/models). The analyzer works correctly depending on what we are generating. The file in the example project triggers the failure (https://github.com/KlausJokinen/Jetbrains_code_generation_fail/blob/master/lib/models/application_state/application_state.dart).
I can reproduce the problem using https://github.com/KlausJokinen/Jetbrains_code_generation_fail project and Flutter SDK 1.20.2 (Dart SDK 2.9.1). Steps:
flutter pub get before opening the projectapplication_state.freezed.dart file. Problem: corresponding errors do not appear in the Dart Analysis view.application_state.freezed.dart (luckily it's in Git, use IntelliJ's Git tool window and its Rollback button). Problem: errors do not disappear in the Dart Analysis view.I looked through the Analysis Server instrumentation logs. I can confirm that server receives file deleted / file created events. But I can also confirm that it doesn't send updated errors to the IDE.
@alexander-doroshko Great to hear that you were able to pinpoint the issue. @devoncarew @alexander-doroshko Let me know if I can be more of assist.
Is there any news on this? The development is quite painful because you don't know what error is "real" and what is not.
@devoncarew Is there something I could do to help fix this issue? I've now noticed that this is not just the Freezed package, but code generation in general.
小褋 @bwilkerson @scheglov. Steps to reproduce: https://github.com/dart-lang/sdk/issues/43166#issuecomment-682130478
I have today followed @alexander-doroshko comment and it is still reproducible
Most helpful comment
I can reproduce the problem using https://github.com/KlausJokinen/Jetbrains_code_generation_fail project and Flutter SDK 1.20.2 (Dart SDK 2.9.1). Steps:
flutter pub getbefore opening the projectapplication_state.freezed.dartfile. Problem: corresponding errors do not appear in the Dart Analysis view.application_state.freezed.dart(luckily it's in Git, use IntelliJ's Git tool window and its Rollback button). Problem: errors do not disappear in the Dart Analysis view.I looked through the Analysis Server instrumentation logs. I can confirm that server receives file deleted / file created events. But I can also confirm that it doesn't send updated errors to the IDE.