|Re: Generating calls to setters/getters [message #903743 is a reply to message #903474]
||Sat, 25 August 2012 11:13
| Stephan Herrmann
Registered: July 2009
I don't see why this would be a typical scenario.|
Please see that code assist can only support the most common scenarios,
otherwise JDT would overwhelm you with proposals what could possibly
be your intention, but the list would be way to long to find the proposal
you are interested in.
Generally, JDT's code assist only proposes small steps.
Larger changes would be invoked as refactoring or via Source > Generate XYZ.
I don't see your proposal fitting into either category.
The Code Recommenders project adds more ambitious recommendations strategies,
so, if any, they might be interested in your proposal, but still you
would have to argue why your usecase is a common situation and why
automating this will save lots of time.
One more option to consider: maybe this is not about adding statements to
an existing method, but about a template proposal to create a
method populated with a sequence of method calls?
Finally, if Foo is your class, why not provide a constructor that includes
setting all those fields, so the setter calls aren't even needed.
|Re: Generating calls to setters/getters [message #903774 is a reply to message #903743]
||Sat, 25 August 2012 19:27
| David Jaquay
Registered: August 2012
Ah, yes, code assist probably isn't the right place for such a thing. Having something as a Generate makes a little more sense, perhaps.|
My situation is common (for me) as we're writing a database app, and have JPA classes that we want to use to create rows in the database, for each of many tables. So, for each JPA class, somewhere in the app (and sometimes in multiple places), we'll call many/most of the setters on a given class. I've spent a lot of time of late hitting "foo." and picking the "next" setter from the list, and have thought that it'd be nice to get them all at once, and remove the few that I might not need.
I will read up more on templates, as that could very well be what I'm after, especially as it seems one can write new ones. And yes, better constructors is a good idea, although to some extent, this kinda kicks the whale down the beach, because then I'll be asking for a way to generate a ctor with all the setters called .
Powered by FUDForum
. Page generated in 0.02326 seconds