Itay Sela
Itay Sela

Reputation: 974

intellij formatter line wrap for method call with instance calling

enter image description hereI've started working with Intellij (used Eclipse before), and I can't seem to mimic the eclipse formatting

the Eclipse Code Formatter plugin did most of the work, but there are still some differences.

for example:

Original line:

object.add(new ClassForSomething(param1, param2, paramObj.method()));

with IntelliJ formatting:

object.add(new ClassForSomething(param1, param2, paramObj
          .method()));

with Eclipse formatting:

object.add(new ClassForSomething(param1, param2, 
          paramObj.method()));

where do I find the configuration to adjust my intelliJ formatter to what I used to have on the eclipse?

EDIT 1: I've uploaded my code style --> wrapping and braces configuration

Upvotes: 2

Views: 1657

Answers (2)

glytching
glytching

Reputation: 47995

In Preferences > Editor > Code Style > Java > Wrapping and Braces

  • Method call arguments - Do not wrap
  • Take priority over call chain wrapping - True

Here's a screenshot:

enter image description here

I reproduced the method splitting behaviour you described and then 'fixed' it with the settings I propose here. However, there are so many formatter configurations, some of which impact each other, that it's possible I haven't reproduced exactly what you are seeing. If so, then I'd suggest trying the following:

  • Save your Java Code Style to a project specific version then start changing its configuration one item at a time until you find the right one.
  • Export your Eclipse codestyle (from Eclipse’s Preferences > Java > Code Style > Formatter and export the settings to an XML file via the Export All button) and then import that into IntelliJ (see screenshot below) ... perhaps IntelliJ can work out the correct configuration from the Eclipse formatter.

enter image description here

Upvotes: 4

AlminaS
AlminaS

Reputation: 105

Check File -> Settings -> Code Style -> Java -> Wrapping and Braces. Make sure "Chained method calls" is set to "Do not wrap" and two squares are unchecked.

Upvotes: 1

Related Questions