devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Property Editor supports refactors

Open elliette opened this issue 1 year ago • 2 comments

The property editor should expose the supported refactors for the selected widget

elliette avatar Dec 20 '24 22:12 elliette

With https://dart-review.googlesource.com/c/sdk/+/428784, it's possible to call textDocument/codeActions over DTD and you will get back a list of Commands that can be invoked using workspace/executeCommand.

Here's an example script you can run in VS Code (make sure you update the DTD URI!) that connects to DTD and lets you execute these:

https://gist.github.com/DanTup/789206bd0e8f29986891ac27af65c760

It only requests actions of kind refactor.flutter.wrap so you'll only see the Wrap actions.

https://github.com/user-attachments/assets/062ce1bc-fb28-4438-9545-c134046bba48

I did find one slight issue which is for CodeActions we usually support a non-standard snippet syntax for VS Code (we're still waiting for the standard LSP version to be released) but it doesn't work here, so using "Wrap with widget" will result in snippet markup appearing in the editor where we'd normally set the selection. I'll work on a fix for that (which unfortunately will mean not selecting the "widget" text as we would from a code action).

DanTup avatar May 15 '25 17:05 DanTup

Thank you! Looking forward to trying this out

elliette avatar May 15 '25 20:05 elliette