Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Add null check fix for entire file #56084

Open
rxvivek opened this issue Jun 26, 2024 · 4 comments
Open

Support Add null check fix for entire file #56084

rxvivek opened this issue Jun 26, 2024 · 4 comments
Labels
analyzer-bulk-fix analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P4 triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-enhancement A request for a change that isn't a bug

Comments

@rxvivek
Copy link

rxvivek commented Jun 26, 2024

Version information

  • IDEA AI-233.14808.21.2331.11842104
  • 3.4.3
  • AI-233.14808.21.2331.11842104, JRE 17.0.10+0-17.0.10b1087.21-11572160x64 JetBrains s.r.o., OS Mac OS X(x86_64) v13.6.6, screens 1920.0x1080.0

Analyzer is not showing the suggestion of error solving in the whole file like in second screenshot.

Screenshot 2024-06-26 at 6 11 44 PM
Screenshot 2024-06-26 at 6 12 23 PM

@dart-github-bot
Copy link
Collaborator

Summary: The IntelliJ Dart analyzer is not providing error resolution suggestions for the entire file, despite the presence of errors. This issue prevents users from efficiently fixing errors in their code.

@dart-github-bot dart-github-bot added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jun 26, 2024
@rxvivek
Copy link
Author

rxvivek commented Jun 26, 2024

If i wanted to add null safety in whole file then i have to add manually as dart does not support migration in other versions. Dart analyzer should provide this feature to solve errors effectively.

Doing manually error solving for same time of errros is very hard for large projects.

@bwilkerson
Copy link
Member

If i wanted to add null safety in whole file then i have to add manually as dart does not support migration in other versions.

In versions of the SDK before 3.0 (when non-nullable by default became the only option) there was a migration tool specifically targeted at this kind of migration. If you can go back to an earlier version to do the migration, that might be the easiest path forward. (We can't support the migration tool in 3.0 because the tools no longer understand pre 2.12 code.)

Doing manually error solving for same time of errros is very hard for large projects.

Yes it is.

The reasons we don't currently support this operation across multiple locations within the same file are:

  1. Adding a null check changes the type of the expression in ways that can cause other null-related diagnostics to appear or disappear. There's no guarantee that adding a null check operator in some given location would still be necessary or appropriate after adding a null check operator somewhere else.

  2. Add a null check operator is rarely the right way to solve the problem, so you really ought to be looking at each site individually to decide whether there might be a better way to solve the problem. One reason why it's not usually the right solution is because it converts a compile-time error into a run-time error, and run-time errors tend to be harder to find and fix.

I'm not sure we'd want to enable this fix for broad use across a file because of those reasons.

@rxvivek
Copy link
Author

rxvivek commented Jun 27, 2024

Thanks for the valuable feedback.
What I did to migrate null safety

  1. Followed the steps to migrate to null safety. [2.10.5 to 3.7.12 flutter version]
  2. Migrated to drift database from moor.
  3. Still migration errors as well as some null safety errors in the project [dart analyzer didn't solve null safety in project, they solved some part of files.].
  4. Downgraded again but now i am facing an error of drift errors as well as null safety compilation errors, Due to that i can't migrate to null safety against those files are pending to migrate to null safety.
  5. So i used dart migrate --skip-import-check --ignore-errors to ignore errors but migration can't apply for those file.

@keertip keertip added type-enhancement A request for a change that isn't a bug P4 and removed type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jul 8, 2024
@keertip keertip changed the title Analyzer Feedback from IntelliJ Support Add null check fix for entire file Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-bulk-fix analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P4 triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants