Bug 97613

Summary: [formatting] Prevent line breaks before "."
Product: [Eclipse Project] JDT Reporter: Scott Duchin <sduchin>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: frederic_fusier, mateusz.matela, Olivier_Thomann, ric.almeida
Version: 3.1   
Target Milestone: 4.7 M2   
Hardware: PC   
OS: Windows 2000   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=59891
https://bugs.eclipse.org/bugs/show_bug.cgi?id=95735
Whiteboard: To be verified for 4.7 M2

Description Scott Duchin CLA 2005-05-31 13:46:17 EDT
It would be nice when the automatic formatter is run that an option be available
to specify the preferences (priorities) of where a line break should go.

Ex. (if the line is too long and breaks):
variable = object.method();

Now:
variable = object
  .method();

Requested
variable =
  object.method();

This could be done if breaking after "=" is a higher priority then after "."
Comment 1 Stefan Küttner CLA 2005-11-01 03:24:23 EST
There is another problem with line breaking before dots.
The following example shows it best (see end of comment for code to reproduce
the bug):

Code before formatting:
    private int testvar = someObject.someMethod(args);

Code after formatting:
    private int testvar = someObject
                                    .someMethod(args);

Code before formatting:
    someObject.someMethod("This is a long non breakable String constant");

Code after formatting:
    someObject
              .someMethod("This is a long non breakable String constant");



This happens with long non-breakable code lines (for example String constants)
and especially with setting the format option "Align fields in columns". The
line breaks should be prevented.


For easy reproduction insert the folling code into your class declaration and
set "Align fields in columns" to enabled. Format the code fragment. The
formatter will indent the code after 's' in the last line in a wrong way.

    private static final AppConfigurationEntry.LoginModuleControlFlag
CONSTANTWITHLONGNAME = null;
    private String s = "";
    private String testString = s.concat("This is a long non-breakable String
constant that won't be broken");
Comment 2 Olivier Thomann CLA 2006-11-21 12:33:10 EST

*** This bug has been marked as a duplicate of 59891 ***
Comment 3 Frederic Fusier CLA 2010-04-23 06:15:52 EDT
This issue will be considered separately from bug 59891.
Comment 4 Mateusz Matela CLA 2016-09-01 07:24:21 EDT
These issues no longer occur after the formatter redesign.

Wrapping on assignment operator is now naturally considered higher priority than inside the assigned expression. Note that wrapping on assignment is not enabled by default though.

*** This bug has been marked as a duplicate of bug 303519 ***
Comment 5 Sasikanth Bharadwaj CLA 2016-09-13 02:28:13 EDT
Verified for 4.7 M2 using I20160912-2000 build