Open bramvbilsen opened 5 years ago
There's an "Encapsulate field" assist - is this what you're looking for?
@DanTup It is! ... kinda. In IntelliJ, I can create getters and setters separately (I do not always need a setter for example) and for multiple variables at once. Also, with the current implementation you can only generate the getter and setter for a variable that is not private. I'd already made sure all of my variables were private when I started declaring them, thus for the generation to work, I had to refactor those to public vars. In IntelliJ, it Is possible to create getters and setters for variables that are already private.
But the Encapsulate field
function is definitely nice to have, didn't know about it yet!
Ah, I see. Can you give a screenshot of how it looks in IntelliJ? Most functionality like this powered by the analysis server (the VS Code plugin doesn't parse any code like this itself) so I wonder whether it's doing its own (IntelliJ does currently parse the code) or if it's there somewhere and I've just not wired it up.
Thanks!
Here are some screenshots of what it looks like in IntelliJ:
The last one shows how easy it is to generate them for multiple member variables at once, which is something I use a lot!
Hope this helps :)
@pq are these coded directly in the IntelliJ plugin using its AST rather than from the server?
@DanTup: I believe these are from the Dart Plugin (and not server).
See, for example:
Ah, got it - not something we can easily piggy-back then. Do you know if there are any analytics on how much it's used? Since it'd need work in the server, it'd be good to know if it's used much (or alternatively, we can see if this issue gets many 👍 's).
I'm not sure about analytics but believe jetbrains tracks them.
@devoncarew or @alexander-doroshko could elaborate?
I'm afraid I don't have numbers.
I'd really love this feature
I'd really love this feature
I found this extension https://marketplace.visualstudio.com/items?itemName=PeterHdd.dartgettersetter
Feature Request
There is an extremely useful feature in IntelliJ which allows you to automatically generate setters and getters for a class's member variables. This would be amazing to have in VS Code!
(Apologies if this feature already exists, I have not found it.)