You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Analyzer doesn't detect changes in l10n Flutter tool. #3074
In Flutter 1.22, a new tool for generating translations was released. This tool generates a synthetic package in the root .dart_tool/flutter_gen/l10n_gen and updates the code when flutter run is running and the arb template file changes .
But the new code generated inside that package is not reanalyzed and saw an error like if the methods inside the package don't exists. Once the file .dart_tool/flutter_gen/l10n_gen/app_localizations.dart is opened the error disapears.
@bwilkerson I can reproduce this in a test - it appears that files inside .dart_tool are analyzed at context creation but if they are modified while the analysis server is active, the updates are ignored.
It seems to be caused by this line in the watcher handler that skips anything in dot-folders:
@bwilkerson with the change at https://dart-review.googlesource.com/c/sdk/+/179776/ this seems to work as expected. I've opened a Flutter project, fetched packages, built and run and I haven't noticed any negative effects. There is likely some overhead in that files that were previously just ignored will be analyzed (though this seems unavoidable to support something like the flutter_gen project that lives inside .dart_tool).
It does however break test_watch_addFile_pathContainsDotFile. I think this is probably expected but would like a second opinion. The test is checking that if you explicitly add (eg. open in the ide) a file inside a dot file that it's also not included in the context, although with this change it will be, it just would not produce error notifications. If that seems reasonable to you, I can remove it, or invert its logic (in which case it would function much like the test immediately below it).
If analyzing all changed files in those directories proves to be a problem, we can probably find a way to optimize it further. That said, I'm going to ask @scheglov for his opinion on this one.
It seems reasonable to me that requirements changed, and now we want to handle some files in dot-directories. I think that the biggest reason to avoid doing this was to avoid handling changes in not user facing directories like .git. So, I would limit it to specifically .dart_tool and package:build.
I've updated https://dart-review.googlesource.com/c/sdk/+/179776 to only handle .dart_tool (I'm not aware of any dot-folders package:build writes to outside of that, but more can be added if that's not true).
Reacted by Jaime Blasco and Aurélien Binder-Meunier
@orestesgaolin the fix above should have shipped in stable releases quite some time ago, but perhaps you're still seeing #3438? The fix for that was in the Dart SDK, but looks like it wasn't in v2.16 (the current stable), so I'd expect it to be in the next major Dart/Flutter release.
I think it's probably already in the Flutter beta channel, as that reports 2.17.0-69.2.beta for the Dart SDK and the commit above includes the tag 2.17.0-20.0.dev.
Reacted by Dominik Roszkowski and mono — Masayuki Ono
Activity
DanTup commentedon Jan 18, 2021
@bwilkerson I can reproduce this in a test - it appears that files inside
.dart_toolare analyzed at context creation but if they are modified while the analysis server is active, the updates are ignored.It seems to be caused by this line in the watcher handler that skips anything in dot-folders:
https://github.com/dart-lang/sdk/blob/04e8aa58ee81bed52a63d4bbb10791a9eb018d7e/pkg/analysis_server/lib/src/context_manager.dart#L1319
It looks like that was added in dart-lang/sdk@f9aebdd to fix dart-lang/sdk#24212 - although perhaps that would also now also fixed by dart-lang/sdk@0450462 (which prevents the errors being sent to the user, but doesn't prevent analysis).
bwilkerson commentedon Jan 18, 2021
I suspect that you're right, that if we re-analyzed files in hidden folders we would now be OK. I certainly think it's worth doing an experiment.
DanTup commentedon Jan 19, 2021
@bwilkerson with the change at https://dart-review.googlesource.com/c/sdk/+/179776/ this seems to work as expected. I've opened a Flutter project, fetched packages, built and run and I haven't noticed any negative effects. There is likely some overhead in that files that were previously just ignored will be analyzed (though this seems unavoidable to support something like the
flutter_genproject that lives inside.dart_tool).It does however break test_watch_addFile_pathContainsDotFile. I think this is probably expected but would like a second opinion. The test is checking that if you explicitly add (eg. open in the ide) a file inside a dot file that it's also not included in the context, although with this change it will be, it just would not produce error notifications. If that seems reasonable to you, I can remove it, or invert its logic (in which case it would function much like the test immediately below it).
bwilkerson commentedon Jan 19, 2021
If analyzing all changed files in those directories proves to be a problem, we can probably find a way to optimize it further. That said, I'm going to ask @scheglov for his opinion on this one.
scheglov commentedon Jan 21, 2021
It seems reasonable to me that requirements changed, and now we want to handle some files in dot-directories. I think that the biggest reason to avoid doing this was to avoid handling changes in not user facing directories like
.git. So, I would limit it to specifically.dart_toolandpackage:build.DanTup commentedon Jan 25, 2021
I've updated https://dart-review.googlesource.com/c/sdk/+/179776 to only handle
.dart_tool(I'm not aware of any dot-folderspackage:buildwrites to outside of that, but more can be added if that's not true).[Analyzer] Allow files inside .dart_tool to be analyzed when modified
DanTup commentedon Feb 1, 2021
This has been fixed in dart-lang/sdk@77353dc which should be included in a future Dart/Flutter SDK release.
orestesgaolin commentedon Mar 14, 2022
I wonder if you know which Flutter or DartCode version is going to include this fix?
DanTup commentedon Mar 14, 2022
@orestesgaolin the fix above should have shipped in stable releases quite some time ago, but perhaps you're still seeing #3438? The fix for that was in the Dart SDK, but looks like it wasn't in v2.16 (the current stable), so I'd expect it to be in the next major Dart/Flutter release.
I think it's probably already in the Flutter beta channel, as that reports
2.17.0-69.2.betafor the Dart SDK and the commit above includes the tag2.17.0-20.0.dev.