Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 458208 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunFormatterTests.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2014 IBM Corporation and others.
2
 * Copyright (c) 2005, 2015 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Jesper S Moller - Contribution for bug 402173
10
 *     Jesper S Moller - Contribution for bug 402173
11
 *                       Contribution for bug 402892
11
 *                       Contribution for bug 402892
12
 *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] follow up bug for comments - https://bugs.eclipse.org/458208
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.jdt.core.tests;
14
package org.eclipse.jdt.core.tests;
14
15
Lines 36-41 Link Here
36
		TEST_SUITES.add(FormatterCommentsClearBlankLinesTests.class);
37
		TEST_SUITES.add(FormatterCommentsClearBlankLinesTests.class);
37
		TEST_SUITES.add(FormatterJavadocDontIndentTagsTests.class);
38
		TEST_SUITES.add(FormatterJavadocDontIndentTagsTests.class);
38
		TEST_SUITES.add(FormatterJavadocDontIndentTagsDescriptionTests.class);
39
		TEST_SUITES.add(FormatterJavadocDontIndentTagsDescriptionTests.class);
40
		TEST_SUITES.add(FormatterOldBugsGistTests.class);
39
	}
41
	}
40
42
41
	public static Class[] getTestClasses() {
43
	public static Class[] getTestClasses() {
(-)a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java (-21 / +70 lines)
Lines 10-15 Link Here
10
 *     Ray V. (voidstar@gmail.com) - Contribution for bug 282988
10
 *     Ray V. (voidstar@gmail.com) - Contribution for bug 282988
11
 *     Robin Stocker - Bug 49619 - [formatting] comment formatter leaves whitespace in comments
11
 *     Robin Stocker - Bug 49619 - [formatting] comment formatter leaves whitespace in comments
12
 *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519
12
 *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519
13
 *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] follow up bug for comments - https://bugs.eclipse.org/458208
13
 *******************************************************************************/
14
 *******************************************************************************/
14
package org.eclipse.jdt.core.tests.formatter;
15
package org.eclipse.jdt.core.tests.formatter;
15
16
Lines 1904-1910 Link Here
1904
		"@MessageDriven(mappedName = \"filiality/SchedulerMQService\",\n" + 
1905
		"@MessageDriven(mappedName = \"filiality/SchedulerMQService\",\n" + 
1905
		"		activationConfig = {\n" + 
1906
		"		activationConfig = {\n" + 
1906
		"				@ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + 
1907
		"				@ActivationConfigProperty(propertyName = \"cronTrigger\",\n" + 
1907
		"						propertyValue = \"0/10 * * * * ?\") })\n" + 
1908
		"						propertyValue = \"0/10 * * * * ?\")\n" + 
1909
		"		})\n" + 
1908
		"@RunAs(\"admin\")\n" + 
1910
		"@RunAs(\"admin\")\n" + 
1909
		"@ResourceAdapter(\"quartz-ra.rar\")\n" + 
1911
		"@ResourceAdapter(\"quartz-ra.rar\")\n" + 
1910
		"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + 
1912
		"@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)\n" + 
Lines 8039-8047 Link Here
8039
		"public class X07 {\n" + 
8041
		"public class X07 {\n" + 
8040
		"\n" + 
8042
		"\n" + 
8041
		"	static final long[] jjtoToken = {\n" + 
8043
		"	static final long[] jjtoToken = {\n" + 
8042
		"			0x7fbfecffL, };\n" + 
8044
		"			0x7fbfecffL,\n" + 
8045
		"	};\n" + 
8043
		"	static final long[] jjtoSkip = {\n" + 
8046
		"	static final long[] jjtoSkip = {\n" + 
8044
		"			0x400000L, };\n" + 
8047
		"			0x400000L,\n" + 
8048
		"	};\n" + 
8045
		"\n" + 
8049
		"\n" + 
8046
		"}\n"
8050
		"}\n"
8047
	);
8051
	);
Lines 8070-8079 Link Here
8070
		"\n" + 
8074
		"\n" + 
8071
		"	static final long[] jjtoToken =\n" + 
8075
		"	static final long[] jjtoToken =\n" + 
8072
		"	{\n" + 
8076
		"	{\n" + 
8073
		"			0x7fbfecffL, };\n" + 
8077
		"			0x7fbfecffL,\n" + 
8078
		"	};\n" + 
8074
		"	static final long[] jjtoSkip =\n" + 
8079
		"	static final long[] jjtoSkip =\n" + 
8075
		"	{\n" + 
8080
		"	{\n" + 
8076
		"			0x400000L, };\n" +
8081
		"			0x400000L,\n" +
8082
		"	};\n" + 
8077
		"\n" + 
8083
		"\n" + 
8078
		"}\n"
8084
		"}\n"
8079
	);
8085
	);
Lines 8122-8128 Link Here
8122
		"public class X09 {\n" + 
8128
		"public class X09 {\n" + 
8123
		"	public Class[] getAdapterList() {\n" + 
8129
		"	public Class[] getAdapterList() {\n" + 
8124
		"		return new Class[] {\n" + 
8130
		"		return new Class[] {\n" + 
8125
		"				IWorkbenchAdapter.class };\n" + 
8131
		"				IWorkbenchAdapter.class\n" + 
8132
		"		};\n" + 
8126
		"	}\n" + 
8133
		"	}\n" + 
8127
		"}\n"
8134
		"}\n"
8128
	);
8135
	);
Lines 9303-9309 Link Here
9303
		"	 * 		\"GeneralPage.DoubleClick\", resName, 1,\n" + 
9310
		"	 * 		\"GeneralPage.DoubleClick\", resName, 1,\n" + 
9304
		"	 * 		new String[][] {\n" + 
9311
		"	 * 		new String[][] {\n" + 
9305
		"	 * 				{ \"Open Browser\", \"open\" },\n" + 
9312
		"	 * 				{ \"Open Browser\", \"open\" },\n" + 
9306
		"	 * 				{ \"Expand Tree\", \"expand\" } },\n" + 
9313
		"	 * 				{ \"Expand Tree\", \"expand\" }\n" + 
9314
		"	 * 		},\n" + 
9307
		"	 * 		parent);\n" + 
9315
		"	 * 		parent);\n" + 
9308
		"	 * </pre>\n" + 
9316
		"	 * </pre>\n" + 
9309
		"	 */\n" + 
9317
		"	 */\n" + 
Lines 9335-9341 Link Here
9335
		"			/* INACTIVE */ { \"INACTIVE\", \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\" },\n" + 
9343
		"			/* INACTIVE */ { \"INACTIVE\", \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\" },\n" + 
9336
		"			/* PARTLY_ACTIVE */ { \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\",\n" + 
9344
		"			/* PARTLY_ACTIVE */ { \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\",\n" + 
9337
		"					\"PARTLY_ACTIVE\" },\n" + 
9345
		"					\"PARTLY_ACTIVE\" },\n" + 
9338
		"			/* ACTIVE */ { \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\", \"ACTIVE\" } };\n" + 
9346
		"			/* ACTIVE */ { \"PARTLY_ACTIVE\", \"PARTLY_ACTIVE\", \"ACTIVE\" }\n" + 
9347
		"	};\n" + 
9339
		"}\n"
9348
		"}\n"
9340
	);
9349
	);
9341
}
9350
}
Lines 9506-9512 Link Here
9506
		"				user,\n" + 
9515
		"				user,\n" + 
9507
		"				revision,\n" + 
9516
		"				revision,\n" + 
9508
		"				String.valueOf(delta),\n" + 
9517
		"				String.valueOf(delta),\n" + 
9509
		"				line });\n" + 
9518
		"				line\n" + 
9519
		"		});\n" + 
9510
		"	}\n" + 
9520
		"	}\n" + 
9511
		"}\n"
9521
		"}\n"
9512
	);
9522
	);
Lines 9609-9615 Link Here
9609
		"							IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR),\n" + 
9619
		"							IWorkbenchThemeConstants.INACTIVE_TAB_TEXT_COLOR),\n" + 
9610
		"					new Color[] {\n" + 
9620
		"					new Color[] {\n" + 
9611
		"							colorRegistry.get(\n" + 
9621
		"							colorRegistry.get(\n" + 
9612
		"									IWorkbenchThemeConstants.INACTIVE_TAB_BG_START) },\n" + 
9622
		"									IWorkbenchThemeConstants.INACTIVE_TAB_BG_START)\n" + 
9623
		"					},\n" + 
9613
		"					new int[0],\n" + 
9624
		"					new int[0],\n" + 
9614
		"					true);\n" + 
9625
		"					true);\n" + 
9615
		"		}\n" + 
9626
		"		}\n" + 
Lines 9778-9784 Link Here
9778
		"								public char[][] getCompoundName() {\n" + 
9789
		"								public char[][] getCompoundName() {\n" + 
9779
		"									return EvaluationConstants.ROOT_COMPOUND_NAME;\n" + 
9790
		"									return EvaluationConstants.ROOT_COMPOUND_NAME;\n" + 
9780
		"								}\n" + 
9791
		"								}\n" + 
9781
		"							} },\n" + 
9792
		"							}\n" + 
9793
		"					},\n" + 
9782
		"					null);\n" + 
9794
		"					null);\n" + 
9783
		"		}\n" + 
9795
		"		}\n" + 
9784
		"	}\n" + 
9796
		"	}\n" + 
Lines 9983-9989 Link Here
9983
		"								return info.getLocal()\n" + 
9995
		"								return info.getLocal()\n" + 
9984
		"										.getType() == IResource.FILE;\n" + 
9996
		"										.getType() == IResource.FILE;\n" + 
9985
		"							}\n" + 
9997
		"							}\n" + 
9986
		"						} }),\n" + 
9998
		"						}\n" + 
9999
		"				}),\n" + 
9987
		"				// Conflicting changes of files will fail if the local is not\n" + 
10000
		"				// Conflicting changes of files will fail if the local is not\n" + 
9988
		"				// managed\n" + 
10001
		"				// managed\n" + 
9989
		"				// or is an addition\n" + 
10002
		"				// or is an addition\n" + 
Lines 10010-10016 Link Here
10010
		"								}\n" + 
10023
		"								}\n" + 
10011
		"								return false;\n" + 
10024
		"								return false;\n" + 
10012
		"							}\n" + 
10025
		"							}\n" + 
10013
		"						} }),\n" + 
10026
		"						}\n" + 
10027
		"				}),\n" + 
10014
		"				// Conflicting changes involving a deletion on one side will\n" + 
10028
		"				// Conflicting changes involving a deletion on one side will\n" + 
10015
		"				// aways fail\n" + 
10029
		"				// aways fail\n" + 
10016
		"				new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" + 
10030
		"				new AndSyncInfoFilter(new FastSyncInfoFilter[] {\n" + 
Lines 10029-10035 Link Here
10029
		"											&& !base.equals(remote));\n" + 
10043
		"											&& !base.equals(remote));\n" + 
10030
		"								}\n" + 
10044
		"								}\n" + 
10031
		"							}\n" + 
10045
		"							}\n" + 
10032
		"						} }),\n" + 
10046
		"						}\n" + 
10047
		"				}),\n" + 
10033
		"				// Conflicts where the file type is binary will work but are not\n" + 
10048
		"				// Conflicts where the file type is binary will work but are not\n" + 
10034
		"				// merged\n" + 
10049
		"				// merged\n" + 
10035
		"				// so they should be skipped\n" + 
10050
		"				// so they should be skipped\n" + 
Lines 10058-10066 Link Here
10058
		"								}\n" + 
10073
		"								}\n" + 
10059
		"								return false;\n" + 
10074
		"								return false;\n" + 
10060
		"							}\n" + 
10075
		"							}\n" + 
10061
		"						} }),\n" + 
10076
		"						}\n" + 
10077
		"				}),\n" + 
10062
		"				// Outgoing changes may not fail but they are skipped as well\n" + 
10078
		"				// Outgoing changes may not fail but they are skipped as well\n" + 
10063
		"				new SyncInfoDirectionFilter(SyncInfo.OUTGOING) });\n" + 
10079
		"				new SyncInfoDirectionFilter(SyncInfo.OUTGOING)\n" + 
10080
		"		});\n" + 
10064
		"	}\n" + 
10081
		"	}\n" + 
10065
		"}\n"
10082
		"}\n"
10066
	);
10083
	);
Lines 10111-10117 Link Here
10111
		"					{ 104, 20 },\n" + 
10128
		"					{ 104, 20 },\n" + 
10112
		"					{ 108, 21 },\n" + 
10129
		"					{ 108, 21 },\n" + 
10113
		"					{ 12, 1856 },\n" + 
10130
		"					{ 12, 1856 },\n" + 
10114
		"					{ 13, 1920 } }, };\n" + 
10131
		"					{ 13, 1920 } },\n" + 
10132
		"	};\n" + 
10115
		"}\n"
10133
		"}\n"
10116
	);
10134
	);
10117
}
10135
}
Lines 10252-10258 Link Here
10252
		"					UNKNOWN,\n" + 
10270
		"					UNKNOWN,\n" + 
10253
		"					UNKNOWN,\n" + 
10271
		"					UNKNOWN,\n" + 
10254
		"					UNKNOWN,\n" + 
10272
		"					UNKNOWN,\n" + 
10255
		"					UNKNOWN } };\n" + 
10273
		"					UNKNOWN }\n" + 
10274
		"	};\n" + 
10256
		"\n" + 
10275
		"\n" + 
10257
		"}\n"
10276
		"}\n"
10258
	);
10277
	);
Lines 10298-10304 Link Here
10298
		"					\"READ_POTENTIAL\",\n" + 
10317
		"					\"READ_POTENTIAL\",\n" + 
10299
		"					\"UNKNOWN\",\n" + 
10318
		"					\"UNKNOWN\",\n" + 
10300
		"					\"UNKNOWN\",\n" + 
10319
		"					\"UNKNOWN\",\n" + 
10301
		"					\"UNKNOWN\" }, };\n" + 
10320
		"					\"UNKNOWN\" },\n" + 
10321
		"	};\n" + 
10302
		"\n" + 
10322
		"\n" + 
10303
		"}\n"
10323
		"}\n"
10304
	);
10324
	);
Lines 10346-10352 Link Here
10346
		"					\"READ_POTENTIAL\",\n" + 
10366
		"					\"READ_POTENTIAL\",\n" + 
10347
		"					\"UNKNOWN\",\n" + 
10367
		"					\"UNKNOWN\",\n" + 
10348
		"					\"UNKNOWN\",\n" + 
10368
		"					\"UNKNOWN\",\n" + 
10349
		"					\"UNKNOWN\" }, };\n" + 
10369
		"					\"UNKNOWN\" },\n" + 
10370
		"	};\n" + 
10350
		"\n" + 
10371
		"\n" + 
10351
		"}\n"
10372
		"}\n"
10352
	);
10373
	);
Lines 10387-10393 Link Here
10387
		"                    \"1234567890123456789012345678901234567890\" },\n" + 
10408
		"                    \"1234567890123456789012345678901234567890\" },\n" + 
10388
		"            /* Comment 3 */ {\n" + 
10409
		"            /* Comment 3 */ {\n" + 
10389
		"                    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\",\n" + 
10410
		"                    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\",\n" + 
10390
		"                    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" }, };\n" + 
10411
		"                    \"ABCDEFGHIJKLMNOPQRSTUVWXYZ______________\" },\n" + 
10412
		"    };\n" + 
10391
		"\n" + 
10413
		"\n" + 
10392
		"}\n"
10414
		"}\n"
10393
	);
10415
	);
Lines 10639-10642 Link Here
10639
	
10661
	
10640
	// K_COMPILATION_UNIT is tested by FormatterRegressionTests#test512() and #test643()
10662
	// K_COMPILATION_UNIT is tested by FormatterRegressionTests#test512() and #test643()
10641
}
10663
}
10664
/**
10665
 * @bug 458208: [formatter] follow up bug for comments 
10666
 * @test test a space is not added after a lambda expression in parenthesis
10667
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=458208"
10668
 */
10669
public void testBug458208() throws Exception {
10670
	String source =
10671
		"package p;\n" + 
10672
		"import java.util.function.IntConsumer;\n" + 
10673
		"class TestInlineLambda1 {\n" + 
10674
		"	{\n" + 
10675
		"		IntConsumer op = (x -> {}    );\n" + 
10676
		"	}\n" + 
10677
		"}\n";
10678
	formatSource(source,
10679
		"package p;\n" + 
10680
		"\n" + 
10681
		"import java.util.function.IntConsumer;\n" + 
10682
		"\n" + 
10683
		"class TestInlineLambda1 {\n" + 
10684
		"	{\n" + 
10685
		"		IntConsumer op = (x -> {\n" + 
10686
		"		});\n" + 
10687
		"	}\n" + 
10688
		"}\n"
10689
	);
10690
}
10642
}
10691
}
(-)a/org.eclipse.jdt.core/eclipse.jdt.ui.patch.txt (-4 lines)
Lines 1-114 Link Here
1
### Eclipse Workspace Patch 1.0
2
#P org.eclipse.jdt.ui
3
diff --git ui/org/eclipse/jdt/internal/ui/preferences/formatter/IndentationTabPage.java ui/org/eclipse/jdt/internal/ui/preferences/formatter/IndentationTabPage.java
4
index bbcb3bb..949bf62 100644
(-)a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/SpacePreparator.java (-4 / +38 lines)
Lines 7-16 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519
9
 *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519
10
 *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] follow up bug for comments - https://bugs.eclipse.org/458208
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.formatter;
12
package org.eclipse.jdt.internal.formatter;
12
13
13
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.*;
14
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameAND;
15
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameARROW;
16
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameAT;
17
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameCOLON;
18
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameCOMMA;
19
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameELLIPSIS;
20
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameEQUAL;
21
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameGREATER;
22
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameIdentifier;
23
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameLBRACE;
24
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameLBRACKET;
25
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameLESS;
26
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameLPAREN;
27
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameMINUS;
28
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameMINUS_MINUS;
29
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameOR;
30
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamePLUS;
31
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamePLUS_PLUS;
32
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameQUESTION;
33
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameRBRACE;
34
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameRBRACKET;
35
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameRIGHT_SHIFT;
36
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameRPAREN;
37
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameSEMICOLON;
38
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameUNSIGNED_RIGHT_SHIFT;
39
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamecase;
40
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamedefault;
41
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameinstanceof;
42
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamereturn;
43
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamethrow;
44
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamethrows;
45
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNamewhile;
14
46
15
import java.util.List;
47
import java.util.List;
16
48
Lines 490-498 Link Here
490
		handleToken(node, TokenNameLBRACE, this.options.insert_space_before_opening_brace_in_block, false);
522
		handleToken(node, TokenNameLBRACE, this.options.insert_space_before_opening_brace_in_block, false);
491
		if (this.options.insert_space_after_closing_brace_in_block) {
523
		if (this.options.insert_space_after_closing_brace_in_block) {
492
			int closeBraceIndex = this.tm.lastIndexIn(node, TokenNameRBRACE);
524
			int closeBraceIndex = this.tm.lastIndexIn(node, TokenNameRBRACE);
493
			if (closeBraceIndex + 1 < this.tm.size()
525
			if (closeBraceIndex + 1 < this.tm.size()) {
494
					&& this.tm.get(closeBraceIndex + 1).tokenType != TokenNameSEMICOLON)
526
				int nextToken = this.tm.get(closeBraceIndex + 1).tokenType;
495
				this.tm.get(closeBraceIndex).spaceAfter();
527
				if (nextToken != TokenNameSEMICOLON && nextToken != TokenNameRPAREN)
528
					this.tm.get(closeBraceIndex).spaceAfter();
529
			}
496
		}
530
		}
497
		return true;
531
		return true;
498
	}
532
	}
(-)a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java (+13 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519
9
 *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] Formatter does not format Java code correctly, especially when max line width is set - https://bugs.eclipse.org/303519
10
 *     Mateusz Matela <mateusz.matela@gmail.com> - [formatter] follow up bug for comments - https://bugs.eclipse.org/458208
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.jdt.internal.formatter.linewrap;
12
package org.eclipse.jdt.internal.formatter.linewrap;
12
13
Lines 20-25 Link Here
20
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameLPAREN;
21
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameLPAREN;
21
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameOR;
22
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameOR;
22
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameQUESTION;
23
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameQUESTION;
24
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameRBRACE;
23
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameRPAREN;
25
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameRPAREN;
24
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameStringLiteral;
26
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameStringLiteral;
25
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameextends;
27
import static org.eclipse.jdt.internal.compiler.parser.TerminalTokens.TokenNameextends;
Lines 398-403 Link Here
398
			this.wrapGroupEnd = this.tm.lastIndexIn(node, -1);
400
			this.wrapGroupEnd = this.tm.lastIndexIn(node, -1);
399
			handleWrap(this.options.alignment_for_expressions_in_array_initializer, node);
401
			handleWrap(this.options.alignment_for_expressions_in_array_initializer, node);
400
		}
402
		}
403
		if (!this.options.join_wrapped_lines
404
				&& !this.options.insert_new_line_before_closing_brace_in_array_initializer) {
405
			// if there is a line break before the closing brace, formatter should treat it as a valid wrap to preserve
406
			int closingBraceIndex = this.tm.lastIndexIn(node, TokenNameRBRACE);
407
			Token closingBrace = this.tm.get(closingBraceIndex);
408
			if (this.tm.countLineBreaksBetween(this.tm.get(closingBraceIndex - 1), closingBrace) == 1) {
409
				int openingBraceIndex = this.tm.firstIndexIn(node, TokenNameLBRACE);
410
				closingBrace.setWrapPolicy(
411
						new WrapPolicy(0, openingBraceIndex, this.currentDepth, 1, true, false, -1, false));
412
			}
413
		}
401
		return true;
414
		return true;
402
	}
415
	}
403
416

Return to bug 458208