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

New Dart Analysis Protocol for IntelliJ's "Override Methods of a Superclass" action #35639

Open
jwren opened this issue Jan 11, 2019 · 6 comments
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@jwren
Copy link
Member

jwren commented Jan 11, 2019

The new 2 calls to the DAS will provide the following:

A call to get all overridable methods given some file and offset. This will return with a tree structure to display something similar to Java:

select_methods_to_override

The second call will send a query to return a set of SourceFileEdits back for the addition of some set of method/ operator/ getter/ settter declarations.

@dgrove dgrove added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Jan 12, 2019
@stereotype441 stereotype441 added analyzer-server P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug labels Jan 14, 2019
@stereotype441
Copy link
Member

@jwren will work on this at some point this quarter if he has time.

@lambdabaa lambdabaa self-assigned this Jul 10, 2019
@escamoteur
Copy link

I think this features title should be broadened to not only address IntelliJ but also offers this functionality to VS code.
There should be quick fixes for

  1. Create Implementing Class

Which creates a class that implements the currently selected class and overwrites all available functions adding an not implemented exception in all of them.

2 Create Derived Class

Which opens in dialogue to select which functions should be overridden in the derived class.

@bwilkerson
Copy link
Member

  1. Create Implementing Class

I believe that we could support this via LSP as a code action.

Note that if you define an empty class that overrides the class in question then there is a quick fix to add the required overrides. It doesn't add overrides for methods with a concrete implementation, but we also have code completion support to make that a little bit easier. (I'm not proposing that the feature you're suggesting is not interesting, just pointing out existing support in case it makes your life easier.)

  1. Create Derived Class

I don't believe that LSP gives us the ability to open a dialog like the one described here, so I'm not sure how we'd implement this feature.

@escamoteur
Copy link

@bwilkerson sure LSP can't open a dialog but I think the IDE plugins could if they get the information on the selected class and the potential overrides @DanTup does that make sense?

@escamoteur
Copy link

@bwilkerson people who have used VS Studio with Resharper are missing such refatorings a lot :-)

@DanTup
Copy link
Collaborator

DanTup commented Apr 29, 2021

sure LSP can't open a dialog but I think the IDE plugins could if they get the information on the selected class and the potential overrides

VS Code doesn't have any concept of dialogs (besides embedding something in a webview like DevTools is, but that wouldn't be a good experience as a way to make dialogs), although if the goal is just to let the user pick some items from a list, you can do a (single question) picklist with tickboxes:

Screenshot 2021-04-29 at 17 13 27

Using this would involve custom LSP messages and an implementation in the VS Code extension though, which is not an ideal solution. There's an open issue in LSP about having some way for refactors to collect user input here:

microsoft/language-server-protocol#1164

I would recommend adding 👍 's to that, as a standard way to do this would be much better than a custom one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants