prettier-java icon indicating copy to clipboard operation
prettier-java copied to clipboard

Continuation Indent

Open jmfee-usgs opened this issue 4 years ago • 1 comments

Prettier-Java ^0.8.0

# Options (if any):
--print-width 80

Input:

// code snippet
public class Test {

  public void testMethod(final String param1, final String param2) throws Exception {
    throw new Exception("blah");
  }

}

Output:

Note that throws and throw appear at the same indentation.

// code snippet
public class Test {

  public void testMethod(final String param1, final String param2)
    throws Exception {
    throw new Exception("blah");
  }
}

Expected behavior:

When throws is wrapped, it seems like it should be more clearly separated from code inside the method.

One option is to use one additional indentation any time a line is wrapped, but open to alternatives:

public class Test {

  public void testMethod(final String param1, final String param2)
      throws Exception {
    throw new Exception("blah");
  }
}

jmfee-usgs avatar Oct 02 '20 20:10 jmfee-usgs

Some related discussion: https://github.com/jhipster/prettier-java/pull/384#discussion_r410712022

jhaber avatar Oct 02 '20 20:10 jhaber