Bug 97613 - [formatting] Prevent line breaks before "."
Summary: [formatting] Prevent line breaks before "."
Status: VERIFIED DUPLICATE of bug 303519
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 normal with 1 vote (vote)
Target Milestone: 4.7 M2   Edit
Assignee: Mateusz Matela CLA
QA Contact:
URL:
Whiteboard: To be verified for 4.7 M2
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-31 13:46 EDT by Scott Duchin CLA
Modified: 2016-09-13 02:28 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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