Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 17,011
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Eclipse, preprocessing and autoformat/organize imports

I really like eclipse autoformat (ctrl+shift+F) and organize imports (ctrl+shift+O).

 

However, if the file uses preprocessing, both of these functions make the code unusable.

 

- organize imports moves the //#ifdef line behind the line above, rendering it useless.

i have found a workaround, if you put // behind the line above it will stay where it belongs.

 

autoformat puts an indention before the //#ifdef and the compiler stops  using it.

 

before: 

	VerticalFieldManager screenVfm;
//#ifdef VER_4_6_0_AND_ABOVE

after:

	VerticalFieldManager screenVfm;
	// #ifdef VER_4_6_0_AND_ABOVE

 

did anybody find (or know) a way to either

- disable the autoformat of eclipse for the preprocessing tags

- get the compiler to use them even if they are not at the start of the line

?

 

my habits are really hard to control (and giving up autoformat/organize imports is not really a solution) and i am getting frustrated when i have to re-format all 15 preprocessor tags. 

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Eclipse, preprocessing and autoformat/organize imports

[ Edited ]

You can prevent the automatic formatter from formating the preprocess code by disabling the “Enable line comment formatting” (the 3rd checkbox in the General settings) of the format profile you are using. This way eclipse formatter will not format comments.

formatting.JPG

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 17,011
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Eclipse, preprocessing and autoformat/organize imports

unfortunately this does not change the behavior of my eclipse
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter