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 71335 Details for
Bug 192285
[formatter] Java source formatter not working if class has annotation on single line multiple fields declaration.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix + regression test
patch_192285.txt (text/plain), 5.84 KB, created by
Olivier Thomann
on 2007-06-14 12:22:50 EDT
(
hide
)
Description:
Proposed fix + regression test
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2007-06-14 12:22:50 EDT
Size:
5.84 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.199 >diff -u -r1.199 CodeFormatterVisitor.java >--- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 8 May 2007 14:33:33 -0000 1.199 >+++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 14 Jun 2007 16:22:14 -0000 >@@ -305,9 +305,12 @@ > multiFieldDeclaration.declarations[length] = currentField; > } else if (previousMergedNode instanceof FieldDeclaration) { > // need to check we need to create a multiple field declaration >- if (currentField.declarationSourceStart == ((FieldDeclaration) previousMergedNode).declarationSourceStart) { >+ final FieldDeclaration previousFieldDeclaration = (FieldDeclaration)previousMergedNode; >+ if (currentField.declarationSourceStart == previousFieldDeclaration.declarationSourceStart) { > // we create a multi field declaration >- mergedNodes.set(mergedNodes.size() - 1, new MultiFieldDeclaration(new FieldDeclaration[]{ (FieldDeclaration)previousMergedNode, currentField})); >+ final MultiFieldDeclaration multiFieldDeclaration = new MultiFieldDeclaration(new FieldDeclaration[]{ previousFieldDeclaration, currentField}); >+ multiFieldDeclaration.annotations = previousFieldDeclaration.annotations; >+ mergedNodes.set(mergedNodes.size() - 1, multiFieldDeclaration); > } else { > mergedNodes.add(currentNode); > } >@@ -368,10 +371,13 @@ > System.arraycopy(multiField.declarations, 0, multiField.declarations=new FieldDeclaration[length+1], 0, length); > multiField.declarations[length] = field; > } else { >- members[index - 1] = new MultiFieldDeclaration(new FieldDeclaration[]{ (FieldDeclaration)previousMember, field}); >+ FieldDeclaration fieldDeclaration = (FieldDeclaration)previousMember; >+ final MultiFieldDeclaration multiFieldDeclaration = new MultiFieldDeclaration(new FieldDeclaration[]{ fieldDeclaration, field}); >+ multiFieldDeclaration.annotations = fieldDeclaration.annotations; >+ members[index - 1] = multiFieldDeclaration; > } > } else { >- members[index++] = field; >+ members[index++] = field; > } > previousFieldStart = fieldStart; > if (++fieldIndex < fieldCount) { // find next field if any >#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.213 >diff -u -r1.213 FormatterRegressionTests.java >--- src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 24 Apr 2007 15:46:08 -0000 1.213 >+++ src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 14 Jun 2007 16:22:15 -0000 >@@ -54,7 +54,7 @@ > private long time; > > static { >-// TESTS_NUMBERS = new int[] { 666 }; >+// TESTS_NUMBERS = new int[] { 667 }; > // TESTS_RANGE = new int[] { 658, -1 }; > } > public static Test suite() { >@@ -9337,4 +9337,28 @@ > DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); > runTest(codeFormatter, "test666", "A.java");//$NON-NLS-1$ //$NON-NLS-2$ > } >+ >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=192285 >+ public void test667() { >+ Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); >+ DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); >+ preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP; >+ Hashtable javaCoreOptions = JavaCore.getOptions(); >+ try { >+ Hashtable newJavaCoreOptions = JavaCore.getOptions(); >+ newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); >+ newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); >+ newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); >+ JavaCore.setOptions(newJavaCoreOptions); >+ >+ Map compilerOptions = new HashMap(); >+ compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5); >+ compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5); >+ compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5); >+ DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions); >+ runTest(codeFormatter, "test667", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$ >+ } finally { >+ JavaCore.setOptions(javaCoreOptions); >+ } >+ } > } >Index: workspace/Formatter/test667/A_out.java >=================================================================== >RCS file: workspace/Formatter/test667/A_out.java >diff -N workspace/Formatter/test667/A_out.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test667/A_out.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,6 @@ >+public class FormatTest { >+ private String a, b, c; >+ >+ @SuppressWarnings("unchecked") >+ private Long one, two; >+} >Index: workspace/Formatter/test667/A_in.java >=================================================================== >RCS file: workspace/Formatter/test667/A_in.java >diff -N workspace/Formatter/test667/A_in.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ workspace/Formatter/test667/A_in.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,7 @@ >+public class FormatTest { >+ private String a, >+b, c; >+ >+@SuppressWarnings("unchecked") >+private Long one, two; >+}
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 192285
: 71335