Open pq opened 2 years ago
We don't have anything like this in VS Code right now (because it would be hard to do reliable in VS Code versus the server). It does come up now and then though - it'd be awesome to support :-)
Would these be appropriate for snippets, or would they be better as commands?
Yeah, I think snippets (eg. code completion) could be a good place for them. If the goal is for them to be used in both editors, we'd need to add support for snippets to the original protocol.
It could also be useful to have a way to re-generate them if you add new fields (perhaps as an assist on the method?).
I also wonder if there's any overlap with static metaprogramming - some of the things above are specifically noted as use cases in that issue. I can see reasons for both (being able to have invisible generated code, or having them visible in the code for simplicity, or being able to generate a basic implementation to customise), but I wonder if there should be some relationship between them (for example, might it be useful to "inline" some code that was previously being generated with static meta programming to customise, and could/should these snippets be driven by that?).
If the goal is for them to be used in both editors, we'd need to add support for snippets to the original protocol.
@jwren We'll need to talk to Alex and get a clear direction for where we want this to go in IntelliJ, but if we do nothing else we could always return them as code completions the way we're doing in LSP.
I also wonder if there's any overlap with static metaprogramming ...
Yes, absolutely. This is one of the use cases that static metaprogramming would support. That proposal has the advantage that the methods would automatically be kept up to date.
That said, Dart team hasn't yet decided whether static metaprogramming will be approved and supported, and even if it is, I expect it will take a while for it to be implemented. It might well be worthwhile for us to support some of the more common cases in the meantime.
Form a discussion on flutter-insiders:
Currently the
"Generate..."
menu produces this in IntelliJ@DanTup: do we have similar support in VSCode?
(And are these current menu items implementing in IntelliJ or server-provided?)
/cc @stevemessick