Namespace and inline implementation for "New class wizard"

Post here any ideas/problems/suggestions you have regarding CodeLite's Gizmos plugin
ilkapo
CodeLite Curious
Posts: 5
Joined: Thu Nov 19, 2009 6:43 pm
Genuine User: Yes
IDE Question: c++
Contact:

Namespace and inline implementation for "New class wizard"

Post by ilkapo » Mon Nov 23, 2009 5:22 pm

Hi,
I like CodeLite and I think is a very promising IDE, sure better than more of the opensoruce IDE we can download today.
This is my first participation on an opensource project so please be patient.

I usually use Eclipse with CDT(but I am switching to CodeLite), this IDE allow to insert the namespace when creating a class using the new class wizard.

So I downloaded the codelite sources package (codelite-2.0.3365.tar.gz ) from sourceforge and I started applying my changes. Finally I generated a patch containing:

- a new field on the "New class wizard" to insert the namespace with the possibility to choose from an existing one

- a checkbox on the "New class wizard" to create a single header file with declaration an implementation inline

- automatically add include directives for base classes on generated header file

- changed the symbol used as block guard on the generated header file, for C++ standards compliance the starting double underscore was removed

On the attachments you can find also a screenshot of the new dialog.

In case you think this could be useful this my share. Please let me know if you need more information on the patch.

cheers
You do not have the required permissions to view the files attached to this post.

User avatar
eranif
CodeLite Plugin
Posts: 5849
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Namespace and inline implementation for "New class wizard"

Post by eranif » Mon Nov 23, 2009 6:14 pm

Thanks for this!

I will download it later tonight and will apply it on my local copy.
Btw, it will be better if you simply checkout the sources from SVN and create your patches from them - since the development branch changes quickly, so there is a reasonable chance that I wont be able to apply the patch on my local SVN repository.

About creating patches:
The best tool to create the patch: is with codelite.

Install svn client - the command line tool
and then from the 'Explorer' tab right click on codelite source tree root and select 'Svn -> Show diff' save the generated file and you are done

Eran
Make sure you have read the HOW TO POST thread

User avatar
eranif
CodeLite Plugin
Posts: 5849
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Namespace and inline implementation for "New class wizard"

Post by eranif » Thu Nov 26, 2009 10:48 am

I applied this patch with some other additions:
- An option to set the block guard manually
- Implement virtual methods -> now uses better algorithm to filter non interesting methods + it only applies to the direct parents

Eran
Make sure you have read the HOW TO POST thread

ilkapo
CodeLite Curious
Posts: 5
Joined: Thu Nov 19, 2009 6:43 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Namespace and inline implementation for "New class wizard"

Post by ilkapo » Thu Dec 03, 2009 3:48 pm

I saw your implementation, good work (I wonder how you find the time to manage all the project). I see also the refactory after rename a file this is very cool.

The text control for set the block guard manualy is a good idea, since we have many different naming conventions.
In this day I think to create a settings dialog for let the user configure its own naming convention like:
  • 1 - default header-file suffix (the .h is the most used but someone use hh or other)
    2- default implementation-file suffix (the .cpp is the most used but someone use cc)
    3 - case for file names: lower case, upper case or none
    4 - the block guard style with:
    • 4.1 - a free text for prefix
      4.2 - a free text for suffix
      4.3 - the choice to prepend namespace
      4.4 - block guard case: : lower case, upper case or none
The idea is to delegate the names generation on a proper singleton class and expose:
  • - wxString generateHeaderFileName(wxString className)
    - wxString generateImplementationFileName(wxString className)
    - wxString generateBlockGuard(wxString className, wxStringArray namespaceList)
in this way we can generate consistent names an all Gizmos.

What do you think about this?

User avatar
eranif
CodeLite Plugin
Posts: 5849
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Namespace and inline implementation for "New class wizard"

Post by eranif » Thu Dec 03, 2009 3:57 pm

This is a good idea, I would also include in that class the following:

- Doxygen: use '\' or '@' for keywords
- Setters / Getters: use 'm_' for members or only '_'
- Setters / Getters: Methods starts with uppers case / lower case

I would name this class something like:

'UserCppPerfernces' and make it by user name.
Make sure you dont use wxGetUserName() but rather clGetUserName() (located in globals.h)

Also:
- Adding it under the 'Settings' menu is a good idea

Eran
Make sure you have read the HOW TO POST thread

ilkapo
CodeLite Curious
Posts: 5
Joined: Thu Nov 19, 2009 6:43 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Namespace and inline implementation for "New class wizard"

Post by ilkapo » Thu Dec 03, 2009 5:59 pm

I agree with all your ideas. The lack of wizards is that often you need to touch generated code, in this way CodeLite can speed up development (be clear the main feauture, for me, is the code completition).

I start draw a dialog with all this concept and I will let you know with a post.

ilkapo
CodeLite Curious
Posts: 5
Joined: Thu Nov 19, 2009 6:43 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Namespace and inline implementation for "New class wizard"

Post by ilkapo » Fri Dec 04, 2009 3:32 pm

Thi is my mock up. I try to cover all naming convention I know.

I use a tabbed window beacuse many controls are needed for a complete definition.
The Tab1 allow to configure file names and the header block guard. I add the inline file suffix because someone use the "-inl.h" suffix for this kind of files. For the header block guard is possible to select a prefix and a suffix (maybe someone would use the starting underscore).
Tab1.png
The Tab2 allow to configure member variables and member functions. I add the possibility to use the "is" prefix for boolean variables (I see the GetMemberType on the TagsManager that is suitable for this scope).
Tab2.png
The Tab3 allow to configure doxygen comments generation. These informations are today visible on the "Global editor preferences->C++->Doxygen" tab.
Tab3.png
In the future we could use this settings also for check if a project follow the naming convention, and also suggest fix when a name is not valid. Let me explain if a user type a member variable like "foo_var" but the naming convention is like attached pictures, then CodeLIte can suggest to change the variable name with "m_fooVar". But this is only a trip. Now I start to write the UserCppPreferences class.
You do not have the required permissions to view the files attached to this post.

User avatar
eranif
CodeLite Plugin
Posts: 5849
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Namespace and inline implementation for "New class wizard"

Post by eranif » Fri Dec 04, 2009 6:12 pm

ilkapo wrote:I see the GetMemberType on the TagsManager that is suitable for this scope).
GetMemberType works on an entries which already exists in the database, but since in the generate setter/getter the entries do not exist yet...

You should use the following:
In the method:

Code: Select all

wxString SettersGettersDlg::GenerateGetter(TagEntryPtr tag, bool &alreadyExist, wxString &displayName)
You can simply do this to get the type of the variable:

Code: Select all

if(var.m_type == "bool")
Eran
Make sure you have read the HOW TO POST thread

Post Reply