Getter/Setter generation
Aleix Pol
aleixpol at kde.org
Thu Oct 1 16:23:17 BST 2015
On Thu, Oct 1, 2015 at 2:30 PM, Milian Wolff <mail at milianw.de> wrote:
> On Dienstag, 29. September 2015 09:00:36 CEST Felix Mauch wrote:
>> Hey there,
>>
>> I've been using QtCreator for a while now and recently switched to
>> KDevelop because of its awesome code navigation and its ability to
>> change the UI to my needs.
>> However, I was shocked when I didn't find a way to automatically create
>> getter and setter methods (in C++). Did I just miss it or does this
>> feature not exist?
>>
>> I found an old review request on
>> https://git.reviewboard.kde.org/r/103613/ which seems like it never got
>> merged.
>>
>> Is there any way I can achieve this? Otherwise I guess, I should try to
>> implement something myself...
>> Personally I'd prefer a refactoring-entry: "Create Get- and Set-methods"
>> in the context menu over a full blown GUI for this purpose. Maybe that's
>> doable via a lightweigt plugin?
>
> It really isn't implemented yet, and I totally agree that we should come up
> with a solution here. The existing patches we got where always far too dialog
> centric and - imo - got too much into the way.
>
> What I'd love to see is someone taking our feedback into account and creating
> a new solution. Something like:
>
> - detect that there is a member called m_foo
> - during code completion in the header, offer to add a getter/setter for foo
> when it's not there yet
> - outside the class, we can reuse the existing "implement function" code to
> then create the declaration.
>
> That sounds doable to me, and is much better than having a complicated dialog
> which you need to open in order to create a getter/setter.
>
> It would be sufficient to add a simple implementation first, and then later
> add per-project config options that allow you to specify the style of the
> getter/setter. I.e. prefixes, suffixes, return style, ...
+1 to all of that.
Maybe it can be a code hint instead of a code completion thingie.
Aleix
More information about the KDevelop
mailing list