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
"Create missing overrides" generates invalid code on Windows #2766
I was creating a CustomShapeBorder by extending the ShapeBorder class, then when I used quickfix to create the 5 @overrides using the quickfix from VSCode. 3 of 5 overrides the getInnerPath, getOuterPath and paint had syntax errors in their parameters.
the code is as follows with the errors:
class CustomCardShapeBorder extends ShapeBorder{
@override
// TODO: implement dimensions
EdgeInsetsGeometry get dimensions => throw UnimplementedError();
@override
// error: parameter with ${3|
Path getInnerPath(Rect rect${3|, {TextDirect,TextDirection,Object|}ion textDirection}) {
// TODO: implement getInnerPath
throw UnimplementedError();
}
@override
// error: parameter with closing } in the end of text direction
Path getOuterPath(Rect rectrection textDirection}) {
// TODO: implement getOuterPath
throw UnimplementedError();
}
@override
// error: parameter with speling errors and closing } in the end of text direction
void paint(Canvas canvas, Rect rectxtDirection textDirection}) {
// TODO: implement paint
}
@override
ShapeBorder scale(double t) {
// TODO: implement scale
throw UnimplementedError();
}
}
Can you confirm which version of the Flutter SDK you're using? And also whether you have the LSP Preview enabled (the dart.previewLsp setting)? I'm unable to repro this on a recent build (with or without LSP) though I think it might be this that was recently fixed (and might not be in your version yet):
Flutter SDK version 1.20.2 and the LSP preview is not enabled.
flutter doctor -v
[√] Flutter (Channel stable, 1.20.2, on Microsoft Windows [Version 10.0.19041.450], locale en-IN)
• Flutter version 1.20.2 at C:\code\flutter\flutter
• Framework revision bbfbf1770c (3 weeks ago), 2020-08-13 08:33:09 -0700
• Engine revision 9d5b21729f
• Dart version 2.9.1
[√] VS Code (version 1.48.2)
• VS Code at C:\Users\wr\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.13.2
I tried with the same Flutter version, but it still didn't happen:
The weird thing about the ${3| appearing in the text is that we use VS Code's SnippetString to build edits, so it doesn't seem like we should be able to produce this text.
Can you try disabling any other extensions (leaving just Dart + Flutter) to see if this makes a difference? If not, I'll make a custom build that has more logging in it, so we can try to understand what's happening. Thanks!
@DanTup disabled all other extensions leaving Flutter and Dart but the problem still persists.
If any other extension is causing the problem then should I send all the extension that I have Installed so that you can replicate my environment and then you could run logging.
If it happens with other extensions disabled, it seems unlikely they're causing it. I'll make a build with some additional logging and provide instructions on how to install it shortly, then if you can reproduce with that build, it might be clearer from the logs what's going wrong. Thanks!
Download the vsix file from that release to your computer
Run the Extensions: Install from VSIX command in the VS Code command palette
Select the vsix file you downloaded
When prompted, click the Reload button to finish installing the extension
Open a simple Flutter project (eg. the sample counter app) and create (and save) a new Dart file for testing, containing just class CustomCardShapeBorder extends ShapeBorder{}
Wait for a minute or so, for all initial analysis to complete
Run the Dart: Capture Logs command from the VS Code command palette (leave everything ticked and click OK)
Invoke the quick-fix to create the missing overrides
Click Cancel on the logging notification to stop logging and open the log file
Attach the log here
Hopefully the log will help understand where things are becoming messed up.
This means all of the offsets calculated for the snippets are now wrong. I'll see if I can repro on Windows and find a solution.
In the meantime, if you're able to try enabling the dart.previewLsp setting (restart VS Code after changing the setting), that uses a different code path so it'd be interesting to know if the issue goes away (in the future, the LSP option will become the default).
changed the title [-][ShapeBorder Class]-3of 5 Overrides created have errors when created using QuickFix of VsCode[/-][+]"Create missing overrides" generates invalid code on Windows[/+]on Sep 14, 2020
@DanTup After turning on the previreLsp the problem doesn't appear. The problem did not appear even after rolling back to version 3.14.1 from 3.15.0-dev.1
I'll have a look if there's an easy fix for non-LSP, since it'll still be around for at least a few months (how fast it rolls out depends on how quickly we find/fix any remaining issues).
I'd recommend you stick on LSP to avoid this, and if you find any issues while using it, please open new issues here so I can get them fixed. Thanks!
Working around this for non-LSP in the VS Code extension is but I've landed some fixes in the server that will prevent generating the problematic edits:
Activity
DanTup commentedon Sep 3, 2020
Can you confirm which version of the Flutter SDK you're using? And also whether you have the LSP Preview enabled (the
dart.previewLspsetting)? I'm unable to repro this on a recent build (with or without LSP) though I think it might be this that was recently fixed (and might not be in your version yet):dart-lang/sdk#41147
Maverick-I0 commentedon Sep 3, 2020
Flutter SDK version 1.20.2 and the LSP preview is not enabled.
DanTup commentedon Sep 7, 2020
I tried with the same Flutter version, but it still didn't happen:
The weird thing about the
${3|appearing in the text is that we use VS Code'sSnippetStringto build edits, so it doesn't seem like we should be able to produce this text.Can you try disabling any other extensions (leaving just Dart + Flutter) to see if this makes a difference? If not, I'll make a custom build that has more logging in it, so we can try to understand what's happening. Thanks!
Maverick-I0 commentedon Sep 7, 2020
Okk, I will do as told and then report back
Maverick-I0 commentedon Sep 8, 2020
@DanTup disabled all other extensions leaving Flutter and Dart but the problem still persists.
If any other extension is causing the problem then should I send all the extension that I have Installed so that you can replicate my environment and then you could run logging.
DanTup commentedon Sep 8, 2020
If it happens with other extensions disabled, it seems unlikely they're causing it. I'll make a build with some additional logging and provide instructions on how to install it shortly, then if you can reproduce with that build, it might be clearer from the logs what's going wrong. Thanks!
DanTup commentedon Sep 8, 2020
Ok, please try this:
class CustomCardShapeBorder extends ShapeBorder{}Hopefully the log will help understand where things are becoming messed up.
Maverick-I0 commentedon Sep 14, 2020
The Log file is as follows: @DanTup
DanTup commentedon Sep 14, 2020
Thanks - I think I see what's going on. The edit we're appling has some
\n's in it:However the edit being made by VS Code has these normalised to
\r\n:This means all of the offsets calculated for the snippets are now wrong. I'll see if I can repro on Windows and find a solution.
In the meantime, if you're able to try enabling the
dart.previewLspsetting (restart VS Code after changing the setting), that uses a different code path so it'd be interesting to know if the issue goes away (in the future, the LSP option will become the default).Thanks!
[-][ShapeBorder Class]-3of 5 Overrides created have errors when created using QuickFix of VsCode[/-][+]"Create missing overrides" generates invalid code on Windows[/+]Maverick-I0 commentedon Sep 14, 2020
ohhh, I get it. I'll turn on the LSP and then report back
Maverick-I0 commentedon Sep 14, 2020
@DanTup After turning on the
previreLspthe problem doesn't appear. The problem did not appear even after rolling back to version 3.14.1 from 3.15.0-dev.1Maverick-I0 commentedon Sep 14, 2020
So I guess the issue can be closed because according to you LSP option will become a default in future.
DanTup commentedon Sep 14, 2020
I'll have a look if there's an easy fix for non-LSP, since it'll still be around for at least a few months (how fast it rolls out depends on how quickly we find/fix any remaining issues).
I'd recommend you stick on LSP to avoid this, and if you find any issues while using it, please open new issues here so I can get them fixed. Thanks!
Maverick-I0 commentedon Sep 14, 2020
yep 👍🏻
[Analyzer] Make newlines in fixes like CreateMissingOverrides consist…
DanTup commentedon Sep 23, 2020
Working around this for non-LSP in the VS Code extension is but I've landed some fixes in the server that will prevent generating the problematic edits:
dart-lang/sdk@f820c1f
So the issue is resolved either by:
Long-term the buggy code here will be removed, once LS becomes the only option.