Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 158850 Details for
Bug 302552
[formatter] Formatting qualified invocations can be broken when the Line Wrapping policy forces element to be on a new line
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v00.txt (text/plain), 5.74 KB, created by
Frederic Fusier
on 2010-02-11 09:10:08 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2010-02-11 09:10:08 EST
Size:
5.74 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java,v >retrieving revision 1.224 >diff -u -r1.224 CodeFormatterVisitor.java >--- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 4 Jan 2010 19:48:25 -0000 1.224 >+++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 11 Feb 2010 13:52:50 -0000 >@@ -1394,8 +1394,16 @@ > this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(cascadingMessageSendAlignment); > boolean ok = false; >+ boolean setStartingColumn = startingPositionInCascade == 1; >+ switch (this.preferences.alignment_for_arguments_in_method_invocation) { >+ case Alignment.M_COMPACT_FIRST_BREAK_SPLIT: >+ case Alignment.M_NEXT_SHIFTED_SPLIT: >+ case Alignment.M_ONE_PER_LINE_SPLIT: >+ setStartingColumn = false; >+ break; >+ } > do { >- if (startingPositionInCascade == 1) { >+ if (setStartingColumn) { > cascadingMessageSendAlignment.startingColumn = this.scribe.column; > } > try { >@@ -4083,15 +4091,21 @@ > Alignment messageAlignment = null; > if (!messageSend.receiver.isImplicitThis()) { > messageSend.receiver.traverse(this, scope); >+ int alignmentMode = this.preferences.alignment_for_selector_in_method_invocation; > messageAlignment = this.scribe.createAlignment( > "messageAlignment", //$NON-NLS-1$ >- this.preferences.alignment_for_selector_in_method_invocation, >+ alignmentMode, > 1, > this.scribe.scanner.currentPosition); > this.scribe.enterAlignment(messageAlignment); > boolean ok = false; > do { >- messageAlignment.startingColumn = this.scribe.column; >+ switch (alignmentMode) { >+ case Alignment.M_COMPACT_SPLIT: >+ case Alignment.M_NEXT_PER_LINE_SPLIT: >+ messageAlignment.startingColumn = this.scribe.column; >+ break; >+ } > try { > formatMessageSend(messageSend, scope, messageAlignment); > ok = true; >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java,v >retrieving revision 1.18 >diff -u -r1.18 FormatterBugsTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 9 Feb 2010 08:58:00 -0000 1.18 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 11 Feb 2010 13:52:53 -0000 >@@ -19,6 +19,7 @@ > import org.eclipse.jdt.core.formatter.IndentManipulation; > import org.eclipse.jdt.internal.formatter.DefaultCodeFormatter; > import org.eclipse.jdt.internal.formatter.DefaultCodeFormatterOptions; >+import org.eclipse.jdt.internal.formatter.align.Alignment; > > public class FormatterBugsTests extends FormatterRegressionTests { > >@@ -4018,4 +4019,92 @@ > "}\n" > ); > } >+ >+/** >+ * @bug 302552: [Formatter] Wrap when necessary too aggressive on short qualifiers >+ * @test >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=302552" >+ */ >+public void testBug302552_LW0() { >+ this.formatterPrefs.page_width = 20; >+ this.formatterPrefs.alignment_for_selector_in_method_invocation = Alignment.M_NO_ALIGNMENT; >+ String source = >+ "class Sample2 {int foo(Some a) {return a.getFirst();}}\n"; >+ formatSource(source, >+ "class Sample2 {\n" + >+ " int foo(Some a) {\n" + >+ " return a.getFirst();\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug302552_LW1() { >+ this.formatterPrefs.page_width = 20; >+ this.formatterPrefs.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT; >+ String source = >+ "class Sample2 {int foo(Some a) {return a.getFirst();}}\n"; >+ formatSource(source, >+ "class Sample2 {\n" + >+ " int foo(Some a) {\n" + >+ " return a.getFirst();\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug302552_LW2() { >+ this.formatterPrefs.page_width = 20; >+ this.formatterPrefs.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_FIRST_BREAK_SPLIT; >+ String source = >+ "class Sample2 {int foo(Some a) {return a.getFirst();}}\n"; >+ formatSource(source, >+ "class Sample2 {\n" + >+ " int foo(Some a) {\n" + >+ " return a\n" + >+ " .getFirst();\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug302552_LW3() { >+ this.formatterPrefs.page_width = 20; >+ this.formatterPrefs.alignment_for_selector_in_method_invocation = Alignment.M_ONE_PER_LINE_SPLIT; >+ String source = >+ "class Sample2 {int foo(Some a) {return a.getFirst();}}\n"; >+ formatSource(source, >+ "class Sample2 {\n" + >+ " int foo(Some a) {\n" + >+ " return a\n" + >+ " .getFirst();\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug302552_LW4() { >+ this.formatterPrefs.page_width = 20; >+ this.formatterPrefs.alignment_for_selector_in_method_invocation = Alignment.M_NEXT_SHIFTED_SPLIT; >+ String source = >+ "class Sample2 {int foo(Some a) {return a.getFirst();}}\n"; >+ formatSource(source, >+ "class Sample2 {\n" + >+ " int foo(Some a) {\n" + >+ " return a\n" + >+ " .getFirst();\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug302552_LW5() { >+ this.formatterPrefs.page_width = 20; >+ this.formatterPrefs.alignment_for_selector_in_method_invocation = Alignment.M_NEXT_PER_LINE_SPLIT; >+ String source = >+ "class Sample2 {int foo(Some a) {return a.getFirst();}}\n"; >+ formatSource(source, >+ "class Sample2 {\n" + >+ " int foo(Some a) {\n" + >+ " return a.getFirst();\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 302552
: 158850