View | Details | Raw Unified | Return to bug 192285
Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java (-4 / +10 lines)
Lines 305-313 Link Here
305
						multiFieldDeclaration.declarations[length] = currentField;
305
						multiFieldDeclaration.declarations[length] = currentField;
306
					} else if (previousMergedNode instanceof FieldDeclaration) {
306
					} else if (previousMergedNode instanceof FieldDeclaration) {
307
						// need to check we need to create a multiple field declaration
307
						// need to check we need to create a multiple field declaration
308
						if (currentField.declarationSourceStart == ((FieldDeclaration) previousMergedNode).declarationSourceStart) {
308
						final FieldDeclaration previousFieldDeclaration = (FieldDeclaration)previousMergedNode;
309
						if (currentField.declarationSourceStart == previousFieldDeclaration.declarationSourceStart) {
309
							// we create a multi field declaration
310
							// we create a multi field declaration
310
							mergedNodes.set(mergedNodes.size() - 1, new MultiFieldDeclaration(new FieldDeclaration[]{ (FieldDeclaration)previousMergedNode, currentField}));
311
							final MultiFieldDeclaration multiFieldDeclaration = new MultiFieldDeclaration(new FieldDeclaration[]{ previousFieldDeclaration, currentField});
312
							multiFieldDeclaration.annotations = previousFieldDeclaration.annotations;
313
							mergedNodes.set(mergedNodes.size() - 1, multiFieldDeclaration);
311
						} else {
314
						} else {
312
							mergedNodes.add(currentNode);
315
							mergedNodes.add(currentNode);
313
						}
316
						}
Lines 368-377 Link Here
368
							System.arraycopy(multiField.declarations, 0, multiField.declarations=new FieldDeclaration[length+1], 0, length);
371
							System.arraycopy(multiField.declarations, 0, multiField.declarations=new FieldDeclaration[length+1], 0, length);
369
							multiField.declarations[length] = field;
372
							multiField.declarations[length] = field;
370
						} else {
373
						} else {
371
							members[index - 1] = new MultiFieldDeclaration(new FieldDeclaration[]{ (FieldDeclaration)previousMember, field});
374
							FieldDeclaration fieldDeclaration = (FieldDeclaration)previousMember;
375
							final MultiFieldDeclaration multiFieldDeclaration = new MultiFieldDeclaration(new FieldDeclaration[]{ fieldDeclaration, field});
376
							multiFieldDeclaration.annotations = fieldDeclaration.annotations;
377
							members[index - 1] = multiFieldDeclaration;
372
						}
378
						}
373
					} else {
379
					} else {
374
						members[index++] = field;					
380
						members[index++] = field;
375
					}
381
					}
376
					previousFieldStart = fieldStart;
382
					previousFieldStart = fieldStart;
377
					if (++fieldIndex < fieldCount) { // find next field if any
383
					if (++fieldIndex < fieldCount) { // find next field if any
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java (-1 / +25 lines)
Lines 54-60 Link Here
54
	private long time;
54
	private long time;
55
	
55
	
56
	static {
56
	static {
57
//		TESTS_NUMBERS = new int[] { 666 };
57
//		TESTS_NUMBERS = new int[] { 667 };
58
//		TESTS_RANGE = new int[] { 658, -1 };
58
//		TESTS_RANGE = new int[] { 658, -1 };
59
	}
59
	}
60
	public static Test suite() {
60
	public static Test suite() {
Lines 9337-9340 Link Here
9337
		DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
9337
		DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
9338
		runTest(codeFormatter, "test666", "A.java");//$NON-NLS-1$ //$NON-NLS-2$
9338
		runTest(codeFormatter, "test666", "A.java");//$NON-NLS-1$ //$NON-NLS-2$
9339
	}
9339
	}
9340
	
9341
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=192285
9342
	public void test667() {
9343
		Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
9344
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
9345
		preferences.brace_position_for_type_declaration = DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP;
9346
		Hashtable javaCoreOptions = JavaCore.getOptions();
9347
		try {
9348
			Hashtable newJavaCoreOptions = JavaCore.getOptions();
9349
			newJavaCoreOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
9350
			newJavaCoreOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
9351
			newJavaCoreOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);
9352
			JavaCore.setOptions(newJavaCoreOptions);
9353
		
9354
			Map compilerOptions = new HashMap();
9355
			compilerOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_5);
9356
			compilerOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_5);
9357
			compilerOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_5);		
9358
			DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences, compilerOptions);
9359
			runTest(codeFormatter, "test667", "A.java", CodeFormatter.K_COMPILATION_UNIT, false);//$NON-NLS-1$ //$NON-NLS-2$
9360
		} finally {
9361
			JavaCore.setOptions(javaCoreOptions);
9362
		}
9363
	}
9340
}
9364
}
(-)workspace/Formatter/test667/A_out.java (+6 lines)
Added Link Here
1
public class FormatTest {
2
	private String a, b, c;
3
4
	@SuppressWarnings("unchecked")
5
	private Long one, two;
6
}
(-)workspace/Formatter/test667/A_in.java (+7 lines)
Added Link Here
1
public class FormatTest {
2
    private String a, 
3
b, c;
4
5
@SuppressWarnings("unchecked")
6
private Long one, two;
7
}

Return to bug 192285