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

Add quick-fix to fix all of type across the whole file #32474

Closed
DanTup opened this issue Mar 9, 2018 · 8 comments
Closed

Add quick-fix to fix all of type across the whole file #32474

DanTup opened this issue Mar 9, 2018 · 8 comments
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P4 type-enhancement A request for a change that isn't a bug

Comments

@DanTup
Copy link
Collaborator

DanTup commented Mar 9, 2018

One of the things I love about the TypeScript linting in VS Code is that I can fix all instances of the same problem in one go from the quickfix menu. Eg., if I enable a new lint and there are 50 violations in a file and I know they're all safe (eg. use double quotes instead of single), it's just one operation:

screen shot 2018-03-09 at 11 32 18

It'd be great to support the same for Dart (the TS one is actually really buggy, so maybe we can be better!).

@bwilkerson I could possibly make this work without analyzer changes, but it'd end up sending a lot of requests (basically take the diagnostic from the quick fix, find all instances of it in that file, then send requests for fixes for them all and apply them together) but API changes would make it more efficient (I guess this is a similar request to #32462 but for fixes instead of assists).

@devoncarew
Copy link
Member

A fix all operation sounds great! We have had requests for batch applying quick fixes, so this seems like a step in the right direction.

@devoncarew devoncarew added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-quick-fix type-enhancement A request for a change that isn't a bug labels Mar 12, 2018
@bwilkerson
Copy link
Member

Is this not implemented yet? There's certainly some support for it on the server side, but I don't know how far that support was taken.

@devoncarew
Copy link
Member

/cc'ing @jwren who knows about it from the IntelliJ perspective (Jaime is OOO currently however)

@DanTup
Copy link
Collaborator Author

DanTup commented Aug 13, 2018

Oh, nice - I found https://dart-review.googlesource.com/c/sdk/+/56220.

And it works:

screen shot 2018-08-13 at 18 19 10

However, it looks like each fix needs specific work (it's not just just a general "fix all of type in file") so I'm not sure whether it's complete and/or how many it's going to cover.

@bwilkerson
Copy link
Member

However, it looks like each fix needs specific work ...

Correct. Sometimes the changes introduced by a fix are not additive. Consider, for example, the "define a method" fix for an undefined method invocation. If the same method name is invoked multiple times in a file it's important that the method is only defined once.

The simple lexical changes implemented by dartfmt don't have that problem because the changes are always localized.

@DanTup
Copy link
Collaborator Author

DanTup commented Aug 13, 2018

Good point - I guess in TypeScript there's probably some whitelist too then (I couldn't actually get it to give me a suggestion for creating a function now to test it - no idea why, I'm sure it used to support that!).

@HerrNiklasRaab
Copy link

Actually, this would bring tremendous benefits with relatively little work. Maybe prioritizing this, before adding new quick fixes.

@srawlins srawlins added the P4 label Dec 2, 2020
@DanTup
Copy link
Collaborator Author

DanTup commented Dec 8, 2020

I recently raised #44258 which I guess is actually a dupe of that one. That one has a little more info about implementation (since it's now available in LSP, but not in the original protocol) so I'll close this one and keep that one open.

@DanTup DanTup closed this as completed Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P4 type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants