Author Topic: Class Wizard Plugin Enhancements  (Read 20817 times)

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Class Wizard Plugin Enhancements
« on: October 07, 2014, 01:20:08 pm »
I've implemented scope (public etc..) selection for member variables for the class wizard. And I'm implementing other stuff to make the class wizard more suitable for general usage as I believe it is very strictly tuned to wx and CB development (like space character usage everywhere without the option for tab usage, methods implemented in class definition etc...). So please let me know if it is still maintained as I don't want my patches to end up dead in the patch tracker because of lack of maintenance. ;)

Let me be clear, my intention is NOT to change the default behavior but to add extra functionality and options for the user.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Class Wizard Plugin Enhancements
« Reply #1 on: October 07, 2014, 04:53:59 pm »
So please let me know if it is still maintained as I don't want my patches to end up dead in the patch tracker because of lack of maintenance. ;)
Yes, but please don't make it over-complicated. Sometimes its easier to just implement things in the source code than understanding and using an UI. Keep in mind, the class wizard is there especially for beginners. :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Class Wizard Plugin Enhancements
« Reply #2 on: October 07, 2014, 06:25:46 pm »
Ok thnx. Actually my syntax for a class is much more different than what the class wizard spits out (I use tabs for indentation, begin methods with lowercase, implement every method in source file etc...) but I don't have the time and patience to implement each and every different usage of mine into the wizard and I also think the easier is the better so I don't plan to complicate things. I personally believe the experienced might benefit more from the capabilities of the class wizard with some extra additions. Most of the things I plan to implement are time-consuming differences to edit manually (like deleting spaces and inserting tabs, creating methods in the source file etc...). Here is a list of what I plan:

1- Scope selection for member variables,
2- Option to use spaces or tabs,
3- Optional indentation level (like no indentation for scope delimiters and 1 level of indentation for methods or the current default),
4- Option to move getter, setter methods and the documentation for methods from header to source.

Please comment!

I'll submit the patch for item 1 to the patch tracker on sourceforge (if I can find it ;)) or should I submit it to somewhere else?

Btw I have a novice question about creating patches. How should I create patches, 1 by 1 adding functionality over the previous version or a single patch for all? Or is there any other way to create sequential patches for modifications to the same file?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re:
« Reply #3 on: October 07, 2014, 08:00:17 pm »
Features look ok. Make sure you consider the users default settings from the editor. For patches use svn.
Checkout your copy of trunk
Change sources as needed
Run: svn diff > my_patch.patch
From the command line and from the root of your checkout.
Post the patch at sourceforge using the tracker one by one, at best one patch per feature.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Class Wizard Plugin Enhancements
« Reply #4 on: October 09, 2014, 01:15:24 am »
Btw I have a novice question about creating patches. How should I create patches, 1 by 1 adding functionality over the previous version or a single patch for all? Or is there any other way to create sequential patches for modifications to the same file?
Sorry to be the git advocate once more time, but if you plan to do multiple patches git is one of the softwares you can use.

About the tabs - just consider the settings for the editors and don't add UI for choosing tabs vs spaces... It should just work automagically...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Class Wizard Plugin Enhancements
« Reply #5 on: October 09, 2014, 02:52:29 am »
Sorry to be the git advocate once more time, but if you plan to do multiple patches git is one of the softwares you can use.
Thnx for the help. My problem is not creating patches, I can do that just fine (only with svn as of yet). What I was trying to ask was something different. Let me be more specific. Consider the scenario: I modified the file 'a.cpp' to implement some feature. I created a patch and submitted it. While waiting for the patch to be approved I decided to implement another feature again by modifying the file 'a.cpp'. Now should I modify the original 'a.cpp' lacking the previous feature OR modify the already modified 'a.cpp'? If both feature modifications overlap the same part of the code, I think the former case will be impossible. And for the latter case, first feature must be approved for the second patch to work. Or is there a better approach to manage this situation?

About the tabs - just consider the settings for the editors and don't add UI for choosing tabs vs spaces... It should just work automagically...
Please elaborate. I didn't quite get what you mean. If you mean the class wizard should show the same exact behavior (spaces as default etc...), my intention is to keep it like that as I mentioned in my first post. What I have in mind is to insert a checkbox titled 'use tabs for indentation' which will be unchecked by default and when it is checked indentation spaces will turn into tabs automagically. ;)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Class Wizard Plugin Enhancements
« Reply #6 on: October 09, 2014, 09:26:58 am »
Thnx for the help. My problem is not creating patches, I can do that just fine (only with svn as of yet). What I was trying to ask was something different. Let me be more specific. Consider the scenario: I modified the file 'a.cpp' to implement some feature. I created a patch and submitted it. While waiting for the patch to be approved I decided to implement another feature again by modifying the file 'a.cpp'. Now should I modify the original 'a.cpp' lacking the previous feature OR modify the already modified 'a.cpp'? If both feature modifications overlap the same part of the code, I think the former case will be impossible. And for the latter case, first feature must be approved for the second patch to work. Or is there a better approach to manage this situation?
With git you can do both of these: you can commit every change as a separate commit on top of the older changes or you can create separate branches for different changes. It is up to you.

Please elaborate. I didn't quite get what you mean. If you mean the class wizard should show the same exact behavior (spaces as default etc...), my intention is to keep it like that as I mentioned in my first post. What I have in mind is to insert a checkbox titled 'use tabs for indentation' which will be unchecked by default and when it is checked indentation spaces will turn into tabs automagically. ;)
The thing is that the editor knows if it has to use tabs or spaces (and how many).
So there should be no need to add an explicit option in the dialog.

There are the cbEditor::DoIndent and DoUnindent methods also which might be useful.
.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Class Wizard Plugin Enhancements
« Reply #7 on: October 09, 2014, 12:27:59 pm »
The thing is that the editor knows if it has to use tabs or spaces (and how many).
So there should be no need to add an explicit option in the dialog.
If you mean editor settings, it is very unwise to let them decide. As a simple example, I have tabs chosen for every setting in the editor and if I had to create a class for CB, it would insert tabs everywhere. Or is it something else?

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Class Wizard Plugin Enhancements
« Reply #8 on: October 09, 2014, 05:46:35 pm »
Patch for item 1 is ready. Yet I couldn't find any patch tracker on sourceforge but only tickets as mentioned on the frontpage of cb's website. Shall I submit my patch there as attachment or am I missing something? Please advise!

Offline Bat

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: Class Wizard Plugin Enhancements
« Reply #9 on: October 09, 2014, 08:07:00 pm »
Yes, same question for me on another topic.
Should theses patchs commited on a perso github account, where we de a clone of C::B git ?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Class Wizard Plugin Enhancements
« Reply #10 on: October 09, 2014, 08:46:47 pm »
Either put them as attachments in sf.net tickets or as pull requests with a topic on the forum.
Keep in mind that some of the developers don't use or like git so you're lowering the chances for inclusion.

@Morten: Can we have a separate status/category in the issue tracker on sf for patches?


If you mean editor settings, it is very unwise to let them decide. As a simple example, I have tabs chosen for every setting in the editor and if I had to create a class for CB, it would insert tabs everywhere. Or is it something else?
Why would it be unwise? The user has decided that he wants tabs and the class wizard generate tabs for indents. If he/she wants to use spaces (2,3,4 or 7) the class wizard must use spaces for the indentations.

p.s. the preview post feature of the forum seems broken :(
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Class Wizard Plugin Enhancements
« Reply #11 on: October 09, 2014, 10:44:21 pm »
I submitted the patch for itme 1 (member variable scope implementation) to sourceforge with the ticket link -> http://sourceforge.net/p/codeblocks/tickets/61/
Some comments about the patch:

1- I couldn't find a way to edit the .xrc file visually so I had to edit it by hand. I couldn't get anything even wxsmith to load the file (it complained something about 'project is not configured for wxsmith' or something). So please feel free to perform any bug fixes or optimizations I might have missed.
2- Scope dropdown defaults to 'private' as in the original class wizard.
3- Member variable list window is quite narrow to fit anything that is even not reasonably long so I abbreviated the scope delimiters as 'pub, pro, pri'. A list window with a horizontal slider may do better or some other notation.
4- I added some extra empty lines to make the generated code easier to read. I think the generated code is quite messy when the documentation is enabled. 'bool addnewline' variable is used to prevent extra empty lines to be inserted in case there are no public variables and/or getter, setter methods.


Why would it be unwise?
If you mean editor settings, it is very unwise to let them decide. As a simple example, I have tabs chosen for every setting in the editor and if I had to create a class for CB, it would insert tabs everywhere.

The user has decided that he wants tabs and the class wizard generate tabs for indents. If he/she wants to use spaces (2,3,4 or 7) the class wizard must use spaces for the indentations.
As I already mentioned that will be presented as an option in the wizard and if you mean it should default to what the user has set in his/her editor settings, I will implement that too.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Class Wizard Plugin Enhancements
« Reply #12 on: October 10, 2014, 07:58:18 pm »
I don't think there is a need for an option.
Why would you bother to spend time on add UI, additional code to handle the special case, add additional complexity to the UI increase the maintenance cost?
99.999% of the people will be happy with the default behaviour, so I don't see why bother with the options.

Also we're not living in the 90's or early 2000's where everything should be configurable:)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Class Wizard Plugin Enhancements
« Reply #13 on: October 10, 2014, 11:10:05 pm »
I don't think there is a need for an option.
Why would you bother to spend time on add UI, additional code to handle the special case, add additional complexity to the UI increase the maintenance cost?
I have nothing else to say then. You're the boss, I respect your decision. I didn't mean to add extra maintenance overcome for an option no developer opts for, sorry for that. I don't use documentation much and fortunately it doesn't affect the code so I don't see a reason to add an option for that too which will increase complexity.

Offline scarphin

  • Lives here!
  • ****
  • Posts: 644
Re: Class Wizard Plugin Enhancements
« Reply #14 on: October 22, 2015, 11:46:56 am »
I see that my patch was applied in trunk but my first version lacked the spacing under the scope elements. I attached a simple patch to add some spacing between the scope elements and 'add getter method' tickbox in case someone may want to review. Also the initial value of 'remove prefix' box seems to be broken, it should be 'm_' but it is 'm&'. Attached patch also fixes that.