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
errors remain after running flutter generate #1970
I'm not sure if this is a problem with DartCode or some kind of analysis daemon.
I have a package that utilizes custom Builder, like r_flutter.
New person joins the team, and downloads git.
When they launch the project in VSCode, the code was not generated yet, so there are errors.
New person runs flutter generate, the command suceeds, but errors are still there.
New person executes "Reload window" and errors disappear.
Similiar issues may also happen after flutter clean or switching branch.
I think it would be ideal if VSCode could handle this automatically: do not perform analysis until files have been generated.
EDIT: as requested I will divide this into 2 issues. The problem here is that error remain after running flutter generate - user needs to reload window to fix this.
I would expect the server to handle this automatically as the new files are generated. Are the errors the result of missing generated code, or missing packages?
Do you happen to have a small sample I could use to reproduce and test with?
I think it would be ideal if VSCode could handle this automatically: do not perform analysis until files have been generated.
I don't think it's possible for the VS Code extension to know that there are files that need to be generated. But even if it did, I don't think it makes sense to remove all language functionality (including things like code completion) due to missing files. You might need to work on your code before you can get the generator to generate the files (for example if you have errors that prevent it).
I think there should be a better way to fix this that doesn't involve taking any functionality away when the files are missing.
What I had in mind was something similiar to promptToRunPubGet that asks user to run flutter generate, maybe it could be even done in the same operation?
User agrees to download packages.
After packages have been downloaded, DartCode checks if builders: option exists in pubspec.
If it exists, it runs flutter generate and updates the prompt message.
After that it restarts analysis server to hide errors.
If there are errors preventing generate from working then that's a pity, DartCode should continue working as it currently does.
What I had in mind was something similiar to promptToRunPubGet that asks user to run flutter generate,
I think that's a reasonable idea (though I don't know how easily it can be detected right now - I've never used flutter generate :-)). Could you file a new issue to request that, and we can use this one for investigating why the errors don't go away on their own. I'd prefer to fix that (if we can) before restarting the server, since it would be much faster to not have to reinitialise everything.
I'll see if I can repro using your sample - thanks!
Before this gets fixed, is there a way to force dart analyzer to recheck? I'm writing VSCode extension that runs flutter generate by itself and it would be nice to force analyzer to refresh itself.
The only way right now is to reload the project (the VS Code Reload Window command) but that will terminate the extension host and restart your extension too.
I had a look at this and can repro. I'm not totally familiar with how this works (the import statement imports a file that's in .dart_tool even though it doesn't specify the full path), but it feels like an analysis server bug so I've opened dart-lang/sdk#41605 for it to be looked at there.
Activity
DanTup commentedon Sep 5, 2019
I would expect the server to handle this automatically as the new files are generated. Are the errors the result of missing generated code, or missing packages?
Do you happen to have a small sample I could use to reproduce and test with?
I don't think it's possible for the VS Code extension to know that there are files that need to be generated. But even if it did, I don't think it makes sense to remove all language functionality (including things like code completion) due to missing files. You might need to work on your code before you can get the generator to generate the files (for example if you have errors that prevent it).
I think there should be a better way to fix this that doesn't involve taking any functionality away when the files are missing.
szotp commentedon Sep 5, 2019
Here is the sample: generation_sample.zip
What I had in mind was something similiar to
promptToRunPubGetthat asks user to runflutter generate, maybe it could be even done in the same operation?builders:option exists in pubspec.flutter generateand updates the prompt message.If there are errors preventing generate from working then that's a pity, DartCode should continue working as it currently does.
DanTup commentedon Sep 5, 2019
I think that's a reasonable idea (though I don't know how easily it can be detected right now - I've never used
flutter generate:-)). Could you file a new issue to request that, and we can use this one for investigating why the errors don't go away on their own. I'd prefer to fix that (if we can) before restarting the server, since it would be much faster to not have to reinitialise everything.I'll see if I can repro using your sample - thanks!
[-]support for flutter generate[/-][+]errors remain after running flutter generate[/+]szotp commentedon Sep 29, 2019
Before this gets fixed, is there a way to force dart analyzer to recheck? I'm writing VSCode extension that runs flutter generate by itself and it would be nice to force analyzer to refresh itself.
DanTup commentedon Sep 30, 2019
The only way right now is to reload the project (the VS Code Reload Window command) but that will terminate the extension host and restart your extension too.
DanTup commentedon Apr 21, 2020
I had a look at this and can repro. I'm not totally familiar with how this works (the import statement imports a file that's in
.dart_tooleven though it doesn't specify the full path), but it feels like an analysis server bug so I've opened dart-lang/sdk#41605 for it to be looked at there.