Community
Participate
Working Groups
need option to control line wrapping before/after operators It would be nice if there was a code formatting option (that could ideally be referenced by the wrap java strings feature of the java editor), to set wrapping before or after operators. One example of where this option would apply is when formatting code that looks like this: if (a.getSomeBooleanValue() && b.getSomeOtherBooleanValue() && c.getYetAnotherBooleanValue()) { doSomething(); } The code formatter currently always changes the code above to the code below, and there's no option (at least not that I've found) to control this behavior. if (a.getSomeBooleanValue() && b.getSomeOtherBooleanValue() && c.getYetAnotherBooleanValue()) { doSomething(); } Note also that the wrap java strings feature and the code formatter are inconsistent with respect to this behavior. Specifically, if I use the wrap java strings feature, I get this: System.out.println("asdlfj asfl;kj saflksj fl;ksaj flsjd f;asl fsjdf" + "sdflkjsdfl;jaslfdjsdlfkj sdflk sdjflks f"); Now, when I format the code using the code formatter, I get System.out.println("asdlfj asfl;kj saflksj fl;ksaj flsjd f;asl fsjdf" + "sdflkjsdfl;jaslfdjsdlfkj sdflk sdjflks f"); Note that one wraps before the + operator and the other wraps after the plus operator (not to mention the inconsistent indentation).
Deferring post 3.1
Reopen
*** Bug 115210 has been marked as a duplicate of this bug. ***
I would add the following constant: /** * <pre> * FORMATTER / Option to wrap before the binary operator * - option id: "org.eclipse.jdt.core.formatter.wrap after the binary operator" * - possible values: { TRUE, FALSE } * - default: FALSE * </pre> * This option is used only if the option {@link #FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION} is set. * @see #TRUE * @see #FALSE * @since 3.3 */ public static final String FORMATTER_WRAP_BEFORE_BINARY_OPERATOR = JavaCore.PLUGIN_ID + ".formatter.wrap_before_binary_operator"; //$NON-NLS-1$ One of the two cases described below won't be preserved.
+1
The constant has been added for 3.3M6 and the implementation will be provided post M6.
Released for 3.3M7.
Added regression test org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests.test661()
Verified for 3.3 M7 using build I20070427-0010.
*** Bug 48476 has been marked as a duplicate of this bug. ***