Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend CDT's coding style component?

The C project I am working on has some special coding style rules that I couldn't find an option in CDT's coding style settings. For example,

1.

switch () {
__case xx: <two spaces for case>
____statements; <two more spaces for statements inside case>
    break;

}

2.

RET_TYPE<new line after return type> 
func_name ()<new line>{
    ....
}

3. different from function implementation, for declaration of functions, there should be no space after the function name before (

RET_TYPE<new line>
func_name();

These are the 3 important ones that I couldn't find in the CDT's Preference settings. So I am wondering whether there is an extension point for CDT's coding style component? and where can I start? Never wrote anything for Eclipse before.

Thanks,

like image 995
wei Avatar asked Dec 07 '25 05:12

wei


1 Answers

you could extend the org.eclipse.cdt.core.formatter.CodeFormatter . source can be found in http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/ , which is probably the best documentation you'll find.

an example of this (now almost 6 years old) is available in a subversion repository at http://astyleclipse.svn.sourceforge.net/viewvc/astyleclipse/ .

like image 195
john.k.doe Avatar answered Dec 08 '25 19:12

john.k.doe