Skip to content

Allow users and/or packages to create custom versions of "Wrap with ..." actions #56265

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

Open
Tracked by #55825
DanTup opened this issue Jul 17, 2024 · 9 comments
Open
Tracked by #55825
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-assist Issues with analysis server assists devexp-server Issues related to some aspect of the analysis server P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug

Comments

@DanTup
Copy link
Collaborator

DanTup commented Jul 17, 2024

It doesn't seem like there's an issue specifically for this, but there has been some discussion across various other issues (and PRs like Dart-Code/Dart-Code#4232).

There is a desire to have more options in the "Wrap with..." actions list. Sometimes package-specific widgets, and sometimes widgets that users feel they use a lot. Including all of them in the default list could make it unwieldy (and doesn't handle packages). Perhaps analysis server plugins are the best way to handle this, but they might also be a bit complex for simple uses where a user just wants a simple extra wrap for a widget.

@DanTup DanTup added legacy-area-analyzer Use area-devexp instead. devexp-server Issues related to some aspect of the analysis server type-enhancement A request for a change that isn't a bug devexp-assist Issues with analysis server assists labels Jul 17, 2024
@DanTup
Copy link
Collaborator Author

DanTup commented Jul 17, 2024

It's not great, but I noticed that user-defined snippets in VS Code can use $TM_SELECTED_TEXT to wrap a selection. So VS Code users can create their own snippets to do this, but they will need invoking/selecting from the command palette (maybe there's a way to optimise this, but I couldn't see anything obvious).

wrap_with_snippet.mp4

(ofc, for something this simple you should just use wrap with widget... but if you have something more complex, you can add multiple parameters, tabstops etc. in snippets)

@srawlins srawlins added the P3 A lower priority bug or feature request label Jul 17, 2024
@FMorschel
Copy link
Contributor

I saw this comment here from the PR mentioned above.

I was thinking if this ever becomes a thing, there could be a way for the user to set which assists they'd like to see. Like a list option in vs code configs or something where they tick whatever they want to show. WDYT?

Not really sure how could we make that reflect the options on the analyzer, but maybe not to select what you want but possibly the other way around. Like what you'd like to hide kind of a thing.

@DanTup
Copy link
Collaborator Author

DanTup commented Sep 16, 2024

I was thinking if this ever becomes a thing, there could be a way for the user to set which assists they'd like to see.

Do you mean allowing the user to also hide some of the existing values (like "Wrap with Padding"), or also hide other kinds of assists (like "Change to double quotes")?

Assuming the former and that the goal is to reduce the number of entries, something that might not be obvious (and doesn't negate the desire for this, but might help in the meantime), is that you can type to jump around the code actions list. For example here, I hit Ctrl+. and then typed column and it jumped to that action in the list:

image

@FMorschel
Copy link
Contributor

I meant only hiding the "Wrap with ..." assists. Great help, will use your tip!

However, your comment got me wondering if the user's created "Wrap with" could be added to non-Widget classes for dart packages that add wrappers to their own or Dart base classes. Or even for List and other base classes like ValueNotifier if these assists can be made by users.

@DanTup
Copy link
Collaborator Author

DanTup commented Sep 16, 2024

your comment got me wondering if the user's created "Wrap with" could be added to non-Widget classes for dart packages that add wrappers to their own or Dart base classes

I think that would be more difficult, because the current assists are specifically written for Widgets with build, and child/children. For non-widget classes, presumably these patterns might not be the same. However, for your own classes, analysis server plugins might be a way to achieve some of this (although at this point they're still a work in progress).

@malkoG
Copy link

malkoG commented Oct 10, 2024

How about Shopify's approach?
Shopify is building ruby lsp (language server for ruby, and it's mainstream in ecosysyem)

As you see this article, Shopify add capability to extending language server's feature. So called ruby lsp addon

https://railsatscale.com/2024-10-03-the-ruby-lsp-addon-system/

@bwilkerson
Copy link
Member

Thanks for the reference.

Ruby's approach is very similar to what we refer to as analysis server plugins. (The analysis server is our LSP support.) The initial prototype of plugins for Dart has been around for several years, and we're in the process of updating and simplifying the whole system with a goal of releasing it more formally.

Plugins are one way to provide some extensibility. They would support the "packages" portion of this request, but wouldn't support the "users" portion. For that I think we'd need a different solution.

@malkoG
Copy link

malkoG commented Oct 10, 2024

@bwilkerson

Okay. (If i guested corrrectly), Do you mean, Even though it's referencing package in local path, they would support package's customized behaviour? not in Project's configuration? Like custom lint ruies?

@bwilkerson
Copy link
Member

There are two potential ways to provide this kind of capability.

This first is to allow a package author to specify that some of the widgets in that package should have a "Wrap with" action created for them. Plugins would support this use case.

The second is to allow an individual user to specify that they want a "Wrap with" action for a given widget even though the author of the widget didn't specify this. Plugins are too heavy weight, IMO, to be a good way to support this second use case.

@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-assist Issues with analysis server assists devexp-server Issues related to some aspect of the analysis server P3 A lower priority bug or feature request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants