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 144650 Details for
Bug 286601
[formatter] Code formatter formats anonymous inner classes wrongly when 'Never join lines' is on
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
New proposed patch
v02.txt (text/plain), 6.71 KB, created by
Frederic Fusier
on 2009-08-17 05:21:11 EDT
(
hide
)
Description:
New proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2009-08-17 05:21:11 EDT
Size:
6.71 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java,v >retrieving revision 1.247 >diff -u -r1.247 FormatterRegressionTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 27 Jul 2009 18:20:49 -0000 1.247 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 14 Aug 2009 13:15:28 -0000 >@@ -10849,4 +10849,69 @@ > DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); > runTest(codeFormatter, "test723", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=286601 >+public void testBug286601() throws JavaModelException { >+ this.formatterPrefs.join_wrapped_lines = false; >+ String source = >+ "public class Test\n" + >+ "{\n" + >+ " public void aMethod()\n" + >+ " {\n" + >+ " Object anObject = new Object()\n" + >+ " {\n" + >+ " boolean aVariable;\n" + >+ " };\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ " public void aMethod() {\n" + >+ " Object anObject = new Object()\n" + >+ " {\n" + >+ " boolean aVariable;\n" + >+ " };\n" + >+ " }\n" + >+ "}\n" >+ ); >+} >+public void testBug286601b() throws JavaModelException { >+ this.formatterPrefs.join_wrapped_lines = false; >+ String source = >+ "public class Test {\n" + >+ "\n" + >+ " void foo() {\n" + >+ "long x1 = 100000000\n" + >+ " + 200000000\n" + >+ " + 300000000;\n" + >+ "long x2 = 100000000\n" + >+ " + 200000000\n" + >+ " + 300000000\n" + >+ " + 400000000;\n" + >+ "long x3 = 100000000\n" + >+ " + 200000000\n" + >+ " + 300000000\n" + >+ " + 400000000\n" + >+ " + 500000000;\n" + >+ " }\n" + >+ "}\n"; >+ formatSource(source, >+ "public class Test {\n" + >+ "\n" + >+ " void foo() {\n" + >+ " long x1 = 100000000\n" + >+ " + 200000000\n" + >+ " + 300000000;\n" + >+ " long x2 = 100000000\n" + >+ " + 200000000\n" + >+ " + 300000000\n" + >+ " + 400000000;\n" + >+ " long x3 = 100000000\n" + >+ " + 200000000\n" + >+ " + 300000000\n" + >+ " + 400000000\n" + >+ " + 500000000;\n" + >+ " }\n" + >+ "}\n" >+ ); >+} > } >#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.33 >diff -u -r1.33 Alignment.java >--- formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java 20 Jul 2009 15:10:59 -0000 1.33 >+++ formatter/org/eclipse/jdt/internal/formatter/align/Alignment.java 14 Aug 2009 13:15:40 -0000 >@@ -45,6 +45,7 @@ > public int shiftBreakIndentationLevel; > public int[] fragmentBreaks; > public boolean wasSplit; >+ public boolean useBreakIndentionWhilePreservingLineBreaks = false; > > public Scribe scribe; > >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.169 >diff -u -r1.169 Scribe.java >--- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 20 Jul 2009 15:10:59 -0000 1.169 >+++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 14 Aug 2009 13:15:39 -0000 >@@ -948,10 +948,14 @@ > // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=283476 > if (this.lastNumberOfNewLines == 0) { > StringBuffer buffer = new StringBuffer(getNewLine()); >- int savedIndentation = this.indentationLevel; >- this.indentationLevel = this.currentAlignment.breakIndentationLevel; >- printIndentationIfNecessary(buffer); >- this.indentationLevel = savedIndentation; >+ if (this.currentAlignment.useBreakIndentionWhilePreservingLineBreaks) { >+ int savedIndentation = this.indentationLevel; >+ this.indentationLevel = this.currentAlignment.breakIndentationLevel; >+ printIndentationIfNecessary(buffer); >+ this.indentationLevel = savedIndentation; >+ } else { >+ printIndentationIfNecessary(buffer); >+ } > return buffer.toString(); > } > } >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.216 >diff -u -r1.216 CodeFormatterVisitor.java >--- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 27 Jul 2009 18:20:50 -0000 1.216 >+++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 14 Aug 2009 13:15:37 -0000 >@@ -427,10 +427,11 @@ > BinaryExpressionFragmentBuilder builder = buildFragments(binaryExpression, scope); > final int fragmentsSize = builder.size(); > >- if ((builder.realFragmentsSize() > 1 || builder.size() > 4) && numberOfParens == 0) { >- this.scribe.printComment(); >+ if ((builder.realFragmentsSize() > 1 || fragmentsSize > 2) && numberOfParens == 0) { > Alignment binaryExpressionAlignment = this.scribe.createAlignment("binaryExpressionAlignment", this.preferences.alignment_for_binary_expression, Alignment.R_OUTERMOST, fragmentsSize, this.scribe.scanner.currentPosition); //$NON-NLS-1$ > this.scribe.enterAlignment(binaryExpressionAlignment); >+ binaryExpressionAlignment.useBreakIndentionWhilePreservingLineBreaks = true; >+ this.scribe.printComment(); > boolean ok = false; > ASTNode[] fragments = builder.fragments(); > int[] operators = builder.operators(); >@@ -4861,11 +4862,12 @@ > manageOpeningParenthesizedExpression(stringLiteral, numberOfParens); > } > >- this.scribe.printComment(); > ASTNode[] fragments = stringLiteral.literals; > int fragmentsSize = stringLiteral.counter; > Alignment binaryExpressionAlignment = this.scribe.createAlignment("binaryExpressionAlignment", this.preferences.alignment_for_binary_expression, Alignment.R_OUTERMOST, fragmentsSize, this.scribe.scanner.currentPosition); //$NON-NLS-1$ > this.scribe.enterAlignment(binaryExpressionAlignment); >+ binaryExpressionAlignment.useBreakIndentionWhilePreservingLineBreaks = true; >+ this.scribe.printComment(); > boolean ok = false; > do { > try {
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 286601
:
144516
| 144650 |
149093
|
149117
|
150464