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 122520 Details for
Bug 260798
[formatter] Strange behavior of never join lines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v00.txt (text/plain), 5.95 KB, created by
Frederic Fusier
on 2009-01-14 05:48:14 EST
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2009-01-14 05:48:14 EST
Size:
5.95 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java,v >retrieving revision 1.30 >diff -u -r1.30 Alignment.java >--- formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java 3 Sep 2008 13:36:24 -0000 1.30 >+++ formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java 14 Jan 2009 10:16:28 -0000 >@@ -222,6 +222,16 @@ > } > } > >+ public int depth() { >+ int depth = 0; >+ Alignment current = this.enclosing; >+ while (current != null) { >+ depth++; >+ current = current.enclosing; >+ } >+ return depth; >+ } >+ > public boolean couldBreak(){ > int i; > switch(this.mode & SPLIT_MASK){ >Index: formatter/org/eclipse/jdt/internal/formatter/Scribe.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java,v >retrieving revision 1.157 >diff -u -r1.157 Scribe.java >--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 9 Jan 2009 15:10:20 -0000 1.157 >+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 14 Jan 2009 10:16:28 -0000 >@@ -936,13 +936,15 @@ > if (count == 0) { > // preserve line breaks in wrapping if specified > // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=198074 >- if (this.currentAlignment != null && !this.formatter.preferences.join_wrapped_lines) { >- int savedIndentation = this.indentationLevel; >- StringBuffer buffer = new StringBuffer(getNewLine()); >- this.indentationLevel = this.currentAlignment.breakIndentationLevel; >- printIndentationIfNecessary(buffer); >- this.indentationLevel = savedIndentation; >- return buffer.toString(); >+ if (this.currentAlignment != null && this.memberAlignment != null && !this.formatter.preferences.join_wrapped_lines) { >+ if (this.memberAlignment.depth() <= this.currentAlignment.depth()) { >+ int savedIndentation = this.indentationLevel; >+ StringBuffer buffer = new StringBuffer(getNewLine()); >+ this.indentationLevel = this.currentAlignment.breakIndentationLevel; >+ printIndentationIfNecessary(buffer); >+ this.indentationLevel = savedIndentation; >+ return buffer.toString(); >+ } > } > return Util.EMPTY_STRING; > } >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v >retrieving revision 1.33 >diff -u -r1.33 FormatterCommentsBugsTest.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 9 Jan 2009 15:10:18 -0000 1.33 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 14 Jan 2009 10:16:29 -0000 >@@ -3428,4 +3428,110 @@ > "}\n" > ); > } >+ >+/** >+ * @bug 260798: [formatter] Strange behavior of never join lines >+ * @test Ensure that the formatter indents lines correctly when never join lines pref is activated >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260798" >+ */ >+public void testBug260798() throws JavaModelException { >+ this.formatterPrefs.join_wrapped_lines = false; >+ String source = >+ "class X {\n" + >+ " @Override\n" + >+ " public void addSelectionListener(SelectionListener listener) {\n" + >+ " super.addSelectionListener(new SelectionListener() {\n" + >+ " @Override\n" + >+ " public void widgetSelected(SelectionEvent e) {\n" + >+ " }\n" + >+ "\n" + >+ " @Override\n" + >+ " public void widgetDefaultSelected(SelectionEvent e) {\n" + >+ " };\n" + >+ " });\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "class X {\n" + >+ " @Override\n" + >+ " public void addSelectionListener(SelectionListener listener) {\n" + >+ " super.addSelectionListener(new SelectionListener() {\n" + >+ " @Override\n" + >+ " public void widgetSelected(SelectionEvent e) {\n" + >+ " }\n" + >+ "\n" + >+ " @Override\n" + >+ " public void widgetDefaultSelected(SelectionEvent e) {\n" + >+ " };\n" + >+ " });\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug260798b() throws JavaModelException { >+ this.formatterPrefs.join_wrapped_lines = false; >+ String source = >+ "class X {\n" + >+ "\n" + >+ " void foo() {\n" + >+ " this.bar(new Object() {\n" + >+ " @Override\n" + >+ " public String toString() {\n" + >+ " return \"\";\n" + >+ " }\n" + >+ " });\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "class X {\n" + >+ "\n" + >+ " void foo() {\n" + >+ " this.bar(new Object() {\n" + >+ " @Override\n" + >+ " public String toString() {\n" + >+ " return \"\";\n" + >+ " }\n" + >+ " });\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug260798c() throws JavaModelException { >+ this.formatterPrefs.join_wrapped_lines = false; >+ String source = >+ "class X {\n" + >+ "\n" + >+ "{\n" + >+ " this.bar(new Object() {\n" + >+ " @Override\n" + >+ " public String toString() {\n" + >+ " return \"\";\n" + >+ " }\n" + >+ " });\n" + >+ "}\n" + >+ " void bar(Object object) {\n" + >+ " \n" + >+ " }\n" + >+ "\n" + >+ "}\n"; >+ formatSource(source, >+ "class X {\n" + >+ "\n" + >+ " {\n" + >+ " this.bar(new Object() {\n" + >+ " @Override\n" + >+ " public String toString() {\n" + >+ " return \"\";\n" + >+ " }\n" + >+ " });\n" + >+ " }\n" + >+ "\n" + >+ " void bar(Object object) {\n" + >+ "\n" + >+ " }\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 260798
:
122376
| 122520