문제

I like being able to use the (Java) Code Formatter in Eclipse, but Eclipse reformats this:

return new Element( OrderXMLGeneratorConstants.PERSONAL_DETAILS )
    .addContent( createElement( OrderXMLGeneratorConstants.FIRST_NAME, firstName ) )
    .addContent( createElement( OrderXMLGeneratorConstants.LAST_NAME, lastName ) )
    .addContent( createElement( OrderXMLGeneratorConstants.EMAIL, email ) );

to

return new Element( OrderXMLGeneratorConstants.PERSONAL_DETAILS )
                                                                   .addContent( createElement( OrderXMLGeneratorConstants.FIRST_NAME, firstName ) )
                                                                   .addContent( createElement( OrderXMLGeneratorConstants.LAST_NAME, lastName ) )   
                                                                   .addContent( createElement( OrderXMLGeneratorConstants.EMAIL, email ) )

How can I use the Code Formatter without getting this ridiculous amount of indentation?

Thanks.

도움이 되었습니까?

해결책

Go to Windows -> Preferences :

In the dialog, select Java -> Code Style -> Formatter and select Edit.

Under the line wrapping tab, Function Calls -> Qualified invocations, you select indent by one, or Default Indentation at the bottom drop down menu (Indentation policy)

This one is probably set to Indent on column... this is what you do NOT want.

Edit and note : I use Helios SR1. I think the options are the same on Ganymede or Galileo though.

다른 팁

You should be able to modify the formatter settings. Go to window->preferences->java->code style->formatter. I think you need to look at the indentation policy on the line wrapping tab.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top