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 »

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: 6367
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 »

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: 6367
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 »

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 »

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: 6367
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 »

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 »

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 »

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: 6367
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 »

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