Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Help with Java code formatter
Help with Java code formatter [message #761470] Tue, 06 December 2011 14:13 Go to next message
Patrick is currently offline PatrickFriend
Messages: 55
Registered: July 2009
Member
Hello,

I try to use the Java code formatter but I can't get what I want with
line wrapping.
I've set the policy to "Wrap where necessary" and maximum line width to
80, but either it wraps where it shouldn't, or it doesn't wrap where it
should...
Here is an example of result:


//
-------------------------------------------------------------------------80->
public class FormatterTest {
void test() {
int a, x = 1, y = 2, z = 3, somelongvariablename1 = 1,
somelongvariablename2 =
2;
a =
x
* y
* z
* (somelongvariablename1 + somelongvariablename1
+ somelongvariablename1 +
somelongvariablename2 + somelongvariablename2);
}
}
//
-------------------------------------------------------------------------80->

Thanks for your help.
--
Patrick
Re: Help with Java code formatter [message #761485 is a reply to message #761470] Tue, 06 December 2011 14:39 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
Formatter does provide various options to handle wrapping at different type of nodes. It doesn't have an option to take care of multiple assignments, but has different option for different kind of expressions and their options. See if they could help.
Re: Help with Java code formatter [message #761500 is a reply to message #761485] Tue, 06 December 2011 14:53 Go to previous messageGo to next message
Patrick is currently offline PatrickFriend
Messages: 55
Registered: July 2009
Member
Le 06/12/2011 15:39, Satyam Kandula a écrit :
> Formatter does provide various options to handle wrapping at different
> type of nodes. It doesn't have an option to take care of multiple
> assignments, but has different option for different kind of
> expressions and their options. See if they could help.

I already tried the different formatter options and didn't get what I
want, that's why I'm asking here. The problem is not with multiple
assignments, but simple expressions that cannot get wrapped correctly.

For example this line is formatted like:

a =
x
* y
* z
* (somelongvariablename1 + somelongvariablename1
+ somelongvariablename1 +
somelongvariablename2 + somelongvariablename2);

But I would prefer:

a = x * y * z * (somelongvariablename1 + somelongvariablename1
+ somelongvariablename1 + somelongvariablename2 +
somelongvariablename2);
Re: Help with Java code formatter [message #761826 is a reply to message #761500] Wed, 07 December 2011 06:03 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
This looks like https://bugs.eclipse.org/bugs/show_bug.cgi?id=250636
Re: Help with Java code formatter [message #762191 is a reply to message #761826] Wed, 07 December 2011 17:06 Go to previous messageGo to next message
Patrick is currently offline PatrickFriend
Messages: 55
Registered: July 2009
Member
Le 07/12/2011 07:03, Satyam Kandula a écrit :
> This looks like https://bugs.eclipse.org/bugs/show_bug.cgi?id=250636

Hmm... the bug is 3 years old, and low priority... I'll have to cope
with that funky formatting.
Re: Help with Java code formatter [message #762675 is a reply to message #762191] Thu, 08 December 2011 13:48 Go to previous message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
FYI, you could turn off the formatter for a region.
Previous Topic:How can I tell Eclipse to not include other jars on a jar dependency's classpath?
Next Topic: Minimalist GUI, do I need to add anything to Eclipse IDE?
Goto Forum:
  


Current Time: Fri Mar 29 15:14:39 GMT 2024

Powered by FUDForum. Page generated in 0.03135 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top