View | Details | Raw Unified | Return to bug 284789 | Differences between
and this patch

Collapse All | Expand All

(-)formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java (+11 lines)
Lines 197-202 Link Here
197
	public static final String FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.alignment_for_expressions_in_array_initializer";	 //$NON-NLS-1$
197
	public static final String FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.alignment_for_expressions_in_array_initializer";	 //$NON-NLS-1$
198
	/**
198
	/**
199
	 * <pre>
199
	 * <pre>
200
	 * FORMATTER / Option for alignment of method declaration
201
	 *     - option id:         "org.eclipse.jdt.core.formatter.alignment_for_method_declaration"
202
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
203
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
204
	 * </pre>
205
	 * @see #createAlignmentValue(boolean, int, int)
206
	 * @since 3.6
207
	 */
208
	public static final String FORMATTER_ALIGNMENT_FOR_METHOD_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.alignment_for_method_declaration";	 //$NON-NLS-1$
209
	/**
210
	 * <pre>
200
	 * FORMATTER / Option for alignment of multiple fields
211
	 * FORMATTER / Option for alignment of multiple fields
201
	 *     - option id:         "org.eclipse.jdt.core.formatter.alignment_for_multiple_fields"
212
	 *     - option id:         "org.eclipse.jdt.core.formatter.alignment_for_multiple_fields"
202
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
213
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
(-)formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java (-71 / +97 lines)
Lines 4126-4209 Link Here
4126
			return false;
4126
			return false;
4127
		}
4127
		}
4128
4128
4129
        /*
4130
         * Print comments to get proper line number
4131
         */
4132
        this.scribe.printComment();
4133
        int line = this.scribe.line;
4134
4135
        this.scribe.printModifiers(methodDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER);
4136
4137
		if (this.scribe.line > line) {
4138
        	// annotations introduced new line, but this is not a line wrapping
4139
			// see 158267
4140
			line = this.scribe.line;
4141
		}
4142
		this.scribe.space();
4143
4144
		TypeParameter[] typeParameters = methodDeclaration.typeParameters;
4145
		if (typeParameters != null) {
4146
			this.scribe.printNextToken(TerminalTokens.TokenNameLESS, this.preferences.insert_space_before_opening_angle_bracket_in_type_parameters);
4147
			if (this.preferences.insert_space_after_opening_angle_bracket_in_type_parameters) {
4148
				this.scribe.space();
4149
			}
4150
			int length = typeParameters.length;
4151
			for (int i = 0; i < length - 1; i++) {
4152
				typeParameters[i].traverse(this, methodDeclaration.scope);
4153
				this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_type_parameters);
4154
				if (this.preferences.insert_space_after_comma_in_type_parameters) {
4155
					this.scribe.space();
4156
				}
4157
			}
4158
			typeParameters[length - 1].traverse(this, methodDeclaration.scope);
4159
			if (isClosingGenericToken()) {
4160
				this.scribe.printNextToken(CLOSING_GENERICS_EXPECTEDTOKENS, this.preferences.insert_space_before_closing_angle_bracket_in_type_parameters);
4161
			}
4162
			if (this.preferences.insert_space_after_closing_angle_bracket_in_type_parameters) {
4163
				this.scribe.space();
4164
			}
4165
		}
4166
4167
		/*
4129
		/*
4168
		 * Print the method return type
4130
		 * Print comments to get proper line number
4169
		 */
4131
		 */
4170
		final TypeReference returnType = methodDeclaration.returnType;
4132
		this.scribe.printComment();
4133
		int line = this.scribe.line;
4134
4135
		// Create alignment
4136
		Alignment methodDeclAlignment = this.scribe.createAlignment(
4137
				"methodDeclaration",//$NON-NLS-1$
4138
				this.preferences.alignment_for_method_declaration,
4139
				Alignment.R_INNERMOST,
4140
				3,
4141
				this.scribe.scanner.currentPosition);
4142
		this.scribe.enterAlignment(methodDeclAlignment);
4143
		boolean ok = false;
4171
		final MethodScope methodDeclarationScope = methodDeclaration.scope;
4144
		final MethodScope methodDeclarationScope = methodDeclaration.scope;
4145
		do {
4146
			try {
4172
4147
4173
		if (returnType != null) {
4148
				this.scribe.printModifiers(methodDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER);
4174
			returnType.traverse(this, methodDeclarationScope);
4149
				int fragmentIndex = 0;
4175
		}
4150
				this.scribe.alignFragment(methodDeclAlignment, fragmentIndex);
4176
		/*
4151
4177
		 * Print the method name
4152
				if (this.scribe.line > line) {
4178
		 */
4153
					// annotations introduced new line, but this is not a line wrapping
4179
		this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true);
4154
					// see 158267
4155
					line = this.scribe.line;
4156
				}
4157
				this.scribe.space();
4158
4159
				TypeParameter[] typeParameters = methodDeclaration.typeParameters;
4160
				if (typeParameters != null) {
4161
					this.scribe.printNextToken(TerminalTokens.TokenNameLESS, this.preferences.insert_space_before_opening_angle_bracket_in_type_parameters);
4162
					if (this.preferences.insert_space_after_opening_angle_bracket_in_type_parameters) {
4163
						this.scribe.space();
4164
					}
4165
					int length = typeParameters.length;
4166
					for (int i = 0; i < length - 1; i++) {
4167
						typeParameters[i].traverse(this, methodDeclaration.scope);
4168
						this.scribe.printNextToken(TerminalTokens.TokenNameCOMMA, this.preferences.insert_space_before_comma_in_type_parameters);
4169
						if (this.preferences.insert_space_after_comma_in_type_parameters) {
4170
							this.scribe.space();
4171
						}
4172
					}
4173
					typeParameters[length - 1].traverse(this, methodDeclaration.scope);
4174
					if (isClosingGenericToken()) {
4175
						this.scribe.printNextToken(CLOSING_GENERICS_EXPECTEDTOKENS, this.preferences.insert_space_before_closing_angle_bracket_in_type_parameters);
4176
					}
4177
					if (this.preferences.insert_space_after_closing_angle_bracket_in_type_parameters) {
4178
						this.scribe.space();
4179
					}
4180
					this.scribe.alignFragment(methodDeclAlignment, ++fragmentIndex);
4181
				}
4180
4182
4181
		formatMethodArguments(
4183
				/*
4182
			methodDeclaration,
4184
				 * Print the method return type
4183
			this.preferences.insert_space_before_opening_paren_in_method_declaration,
4185
				 */
4184
			this.preferences.insert_space_between_empty_parens_in_method_declaration,
4186
				final TypeReference returnType = methodDeclaration.returnType;
4185
			this.preferences.insert_space_before_closing_paren_in_method_declaration,
4187
		
4186
			this.preferences.insert_space_after_opening_paren_in_method_declaration,
4188
				if (returnType != null) {
4187
			this.preferences.insert_space_before_comma_in_method_declaration_parameters,
4189
					returnType.traverse(this, methodDeclarationScope);
4188
			this.preferences.insert_space_after_comma_in_method_declaration_parameters,
4190
				}
4189
			this.preferences.alignment_for_parameters_in_method_declaration);
4191
				this.scribe.alignFragment(methodDeclAlignment, ++fragmentIndex);
4190
4192
4191
		/*
4193
				/*
4192
		 * Check for extra dimensions
4194
				 * Print the method name
4193
		 */
4195
				 */
4194
		int extraDimensions = getDimensions();
4196
				this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, true);
4195
		if (extraDimensions != 0) {
4197
4196
			 for (int i = 0; i < extraDimensions; i++) {
4198
				// Format arguments
4197
			 	this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
4199
				formatMethodArguments(
4198
			 	this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
4200
					methodDeclaration,
4199
			 }
4201
					this.preferences.insert_space_before_opening_paren_in_method_declaration,
4200
		}
4202
					this.preferences.insert_space_between_empty_parens_in_method_declaration,
4203
					this.preferences.insert_space_before_closing_paren_in_method_declaration,
4204
					this.preferences.insert_space_after_opening_paren_in_method_declaration,
4205
					this.preferences.insert_space_before_comma_in_method_declaration_parameters,
4206
					this.preferences.insert_space_after_comma_in_method_declaration_parameters,
4207
					this.preferences.alignment_for_parameters_in_method_declaration);
4208
4209
				/*
4210
				 * Check for extra dimensions
4211
				 */
4212
				int extraDimensions = getDimensions();
4213
				if (extraDimensions != 0) {
4214
					 for (int i = 0; i < extraDimensions; i++) {
4215
					 	this.scribe.printNextToken(TerminalTokens.TokenNameLBRACKET);
4216
					 	this.scribe.printNextToken(TerminalTokens.TokenNameRBRACKET);
4217
					 }
4218
				}
4201
4219
4202
		formatThrowsClause(
4220
				// Format throws
4203
			methodDeclaration,
4221
				formatThrowsClause(
4204
			this.preferences.insert_space_before_comma_in_method_declaration_throws,
4222
					methodDeclaration,
4205
			this.preferences.insert_space_after_comma_in_method_declaration_throws,
4223
					this.preferences.insert_space_before_comma_in_method_declaration_throws,
4206
			this.preferences.alignment_for_throws_clause_in_method_declaration);
4224
					this.preferences.insert_space_after_comma_in_method_declaration_throws,
4225
					this.preferences.alignment_for_throws_clause_in_method_declaration);
4226
				ok = true;
4227
			} catch (AlignmentException e) {
4228
				this.scribe.redoAlignment(e);
4229
			}
4230
		} while (!ok);
4231
		this.scribe.exitAlignment(methodDeclAlignment, true);
4207
4232
4208
		if (!methodDeclaration.isNative() && !methodDeclaration.isAbstract() && ((methodDeclaration.modifiers & ExtraCompilerModifiers.AccSemicolonBody) == 0)) {
4233
		if (!methodDeclaration.isNative() && !methodDeclaration.isAbstract() && ((methodDeclaration.modifiers & ExtraCompilerModifiers.AccSemicolonBody) == 0)) {
4209
			/*
4234
			/*
Lines 4249-4254 Link Here
4249
		}
4274
		}
4250
		return false;
4275
		return false;
4251
	}
4276
	}
4277
4252
	public boolean visit(NormalAnnotation annotation, BlockScope scope) {
4278
	public boolean visit(NormalAnnotation annotation, BlockScope scope) {
4253
		this.scribe.printNextToken(TerminalTokens.TokenNameAT);
4279
		this.scribe.printNextToken(TerminalTokens.TokenNameAT);
4254
		if (this.preferences.insert_space_after_at_in_annotation) {
4280
		if (this.preferences.insert_space_after_at_in_annotation) {
(-)formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java (+12 lines)
Lines 58-63 Link Here
58
	public int alignment_for_conditional_expression;
58
	public int alignment_for_conditional_expression;
59
	public int alignment_for_enum_constants;
59
	public int alignment_for_enum_constants;
60
	public int alignment_for_expressions_in_array_initializer;
60
	public int alignment_for_expressions_in_array_initializer;
61
	public int alignment_for_method_declaration;
61
	public int alignment_for_multiple_fields;
62
	public int alignment_for_multiple_fields;
62
	public int alignment_for_parameters_in_constructor_declaration;
63
	public int alignment_for_parameters_in_constructor_declaration;
63
	public int alignment_for_parameters_in_method_declaration;
64
	public int alignment_for_parameters_in_method_declaration;
Lines 348-353 Link Here
348
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, getAlignment(this.alignment_for_conditional_expression));
349
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, getAlignment(this.alignment_for_conditional_expression));
349
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, getAlignment(this.alignment_for_enum_constants));
350
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, getAlignment(this.alignment_for_enum_constants));
350
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, getAlignment(this.alignment_for_expressions_in_array_initializer));
351
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, getAlignment(this.alignment_for_expressions_in_array_initializer));
352
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_METHOD_DECLARATION, getAlignment(this.alignment_for_method_declaration));
351
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS, getAlignment(this.alignment_for_multiple_fields));
353
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS, getAlignment(this.alignment_for_multiple_fields));
352
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, getAlignment(this.alignment_for_parameters_in_constructor_declaration));
354
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, getAlignment(this.alignment_for_parameters_in_constructor_declaration));
353
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_parameters_in_method_declaration));
355
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_parameters_in_method_declaration));
Lines 732-737 Link Here
732
				this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT;
734
				this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT;
733
			}
735
			}
734
		}
736
		}
737
		final Object alignmentForMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_METHOD_DECLARATION);
738
		if (alignmentForMethodDeclarationOption != null) {
739
			try {
740
				this.alignment_for_method_declaration = Integer.parseInt((String) alignmentForMethodDeclarationOption);
741
			} catch (NumberFormatException e) {
742
				this.alignment_for_method_declaration = Alignment.M_COMPACT_SPLIT;
743
			} catch(ClassCastException e) {
744
				this.alignment_for_method_declaration = Alignment.M_COMPACT_SPLIT;
745
			}
746
		}
735
		final Object alignmentForMultipleFieldsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS);
747
		final Object alignmentForMultipleFieldsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS);
736
		if (alignmentForMultipleFieldsOption != null) {
748
		if (alignmentForMultipleFieldsOption != null) {
737
			try {
749
			try {
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java (+246 lines)
Lines 977-982 Link Here
977
}
977
}
978
978
979
/**
979
/**
980
 * @bug 284789: [formatter] Does not line-break method declaration exception with parameters
981
 * @test Verify that the new preference to split method declaration works properly
982
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=284789"
983
 */
984
public void testBug284789() throws JavaModelException {
985
	this.formatterPrefs.alignment_for_method_declaration = Alignment.M_COMPACT_SPLIT;
986
	String source =
987
		"public class Test {\n" + 
988
		"public synchronized List<FantasticallyWonderfulContainer<FantasticallyWonderfulClass>> getMeTheFantasticContainer() {\n" + 
989
		"	return null;\n" + 
990
		"}\n" + 
991
		"}\n";
992
	formatSource(source,
993
		"public class Test {\n" + 
994
		"	public synchronized\n" + 
995
		"			List<FantasticallyWonderfulContainer<FantasticallyWonderfulClass>>\n" + 
996
		"			getMeTheFantasticContainer() {\n" + 
997
		"		return null;\n" + 
998
		"	}\n" + 
999
		"}\n"
1000
	);
1001
}
1002
public void testBug284789_01a() throws JavaModelException {
1003
	// default is no wrapping for method declaration
1004
	String source =
1005
		"class X01 {\n" + 
1006
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name() {\n" + 
1007
		"		return null;\n" + 
1008
		"	}\n" + 
1009
		"}\n";
1010
	formatSource(source,
1011
		"class X01 {\n" + 
1012
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name() {\n" + 
1013
		"		return null;\n" + 
1014
		"	}\n" + 
1015
		"}\n"
1016
	);
1017
}
1018
public void testBug284789_01b() throws JavaModelException {
1019
	this.formatterPrefs.alignment_for_method_declaration = Alignment.M_COMPACT_SPLIT;
1020
	String source =
1021
		"class X01 {\n" + 
1022
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name() {\n" + 
1023
		"		return null;\n" + 
1024
		"	}\n" + 
1025
		"}\n";
1026
	formatSource(source,
1027
		"class X01 {\n" + 
1028
		"	public final synchronized java.lang.String\n" + 
1029
		"			a_method_which_have_a_very_long_name() {\n" + 
1030
		"		return null;\n" + 
1031
		"	}\n" + 
1032
		"}\n"
1033
	);
1034
}
1035
public void testBug284789_01c() throws JavaModelException {
1036
	this.formatterPrefs.alignment_for_method_declaration = Alignment.M_COMPACT_FIRST_BREAK_SPLIT;
1037
	String source =
1038
		"class X01 {\n" + 
1039
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name() {\n" + 
1040
		"		return null;\n" + 
1041
		"	}\n" + 
1042
		"}\n";
1043
	formatSource(source,
1044
		"class X01 {\n" + 
1045
		"	public final synchronized\n" + 
1046
		"			java.lang.String a_method_which_have_a_very_long_name() {\n" + 
1047
		"		return null;\n" + 
1048
		"	}\n" + 
1049
		"}\n"
1050
	);
1051
}
1052
public void testBug284789_01d() throws JavaModelException {
1053
	this.formatterPrefs.alignment_for_method_declaration = Alignment.M_ONE_PER_LINE_SPLIT;
1054
	String source =
1055
		"class X01 {\n" + 
1056
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name() {\n" + 
1057
		"		return null;\n" + 
1058
		"	}\n" + 
1059
		"}\n";
1060
	formatSource(source,
1061
		"class X01 {\n" + 
1062
		"	public final synchronized\n" + 
1063
		"			java.lang.String\n" + 
1064
		"			a_method_which_have_a_very_long_name() {\n" + 
1065
		"		return null;\n" + 
1066
		"	}\n" + 
1067
		"}\n"
1068
	);
1069
}
1070
public void testBug284789_01e() throws JavaModelException {
1071
	this.formatterPrefs.alignment_for_method_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
1072
	String source =
1073
		"class X01 {\n" + 
1074
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name() {\n" + 
1075
		"		return null;\n" + 
1076
		"	}\n" + 
1077
		"}\n";
1078
	formatSource(source,
1079
		"class X01 {\n" + 
1080
		"	public final synchronized\n" + 
1081
		"			java.lang.String\n" + 
1082
		"				a_method_which_have_a_very_long_name() {\n" + 
1083
		"		return null;\n" + 
1084
		"	}\n" + 
1085
		"}\n"
1086
	);
1087
}
1088
public void testBug284789_01f() throws JavaModelException {
1089
	this.formatterPrefs.alignment_for_method_declaration = Alignment.M_NEXT_PER_LINE_SPLIT;
1090
	String source =
1091
		"class X01 {\n" + 
1092
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name() {\n" + 
1093
		"		return null;\n" + 
1094
		"	}\n" + 
1095
		"}\n";
1096
	formatSource(source,
1097
		"class X01 {\n" + 
1098
		"	public final synchronized java.lang.String\n" + 
1099
		"			a_method_which_have_a_very_long_name() {\n" + 
1100
		"		return null;\n" + 
1101
		"	}\n" + 
1102
		"}\n"
1103
	);
1104
}
1105
public void testBug284789_02a() throws JavaModelException {
1106
	// default is no wrapping for method declaration
1107
	String source =
1108
		"class X02 {\n" + 
1109
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name(String first, String second, String third) {\n" + 
1110
		"		return null;\n" + 
1111
		"	}\n" + 
1112
		"}\n";
1113
	formatSource(source,
1114
		"class X02 {\n" + 
1115
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name(\n" + 
1116
		"			String first, String second, String third) {\n" + 
1117
		"		return null;\n" + 
1118
		"	}\n" + 
1119
		"}\n"
1120
	);
1121
}
1122
public void testBug284789_02b() throws JavaModelException {
1123
	this.formatterPrefs.alignment_for_method_declaration = Alignment.M_COMPACT_SPLIT;
1124
	this.formatterPrefs.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT;
1125
	String source =
1126
		"class X02 {\n" + 
1127
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name(String first, String second, String third) {\n" + 
1128
		"		return null;\n" + 
1129
		"	}\n" + 
1130
		"}\n";
1131
	formatSource(source,
1132
		"class X02 {\n" + 
1133
		"	public final synchronized java.lang.String\n" + 
1134
		"			a_method_which_have_a_very_long_name(String first, String second,\n" + 
1135
		"					String third) {\n" + 
1136
		"		return null;\n" + 
1137
		"	}\n" + 
1138
		"}\n"
1139
	);
1140
}
1141
public void testBug284789_02c() throws JavaModelException {
1142
	this.formatterPrefs.alignment_for_method_declaration = Alignment.M_COMPACT_FIRST_BREAK_SPLIT;
1143
	this.formatterPrefs.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_FIRST_BREAK_SPLIT;
1144
	String source =
1145
		"class X02 {\n" + 
1146
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name(String first, String second, String third) {\n" + 
1147
		"		return null;\n" + 
1148
		"	}\n" + 
1149
		"}\n";
1150
	formatSource(source,
1151
		"class X02 {\n" + 
1152
		"	public final synchronized\n" + 
1153
		"			java.lang.String a_method_which_have_a_very_long_name(\n" + 
1154
		"					String first, String second, String third) {\n" + 
1155
		"		return null;\n" + 
1156
		"	}\n" + 
1157
		"}\n"
1158
	);
1159
}
1160
public void testBug284789_02d() throws JavaModelException {
1161
	this.formatterPrefs.alignment_for_method_declaration = Alignment.M_ONE_PER_LINE_SPLIT;
1162
	this.formatterPrefs.alignment_for_parameters_in_method_declaration = Alignment.M_ONE_PER_LINE_SPLIT;
1163
	String source =
1164
		"class X02 {\n" + 
1165
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name(String first, String second, String third) {\n" + 
1166
		"		return null;\n" + 
1167
		"	}\n" + 
1168
		"}\n";
1169
	formatSource(source,
1170
		"class X02 {\n" + 
1171
		"	public final synchronized\n" + 
1172
		"			java.lang.String\n" + 
1173
		"			a_method_which_have_a_very_long_name(\n" + 
1174
		"					String first,\n" + 
1175
		"					String second,\n" + 
1176
		"					String third) {\n" + 
1177
		"		return null;\n" + 
1178
		"	}\n" + 
1179
		"}\n"
1180
	);
1181
}
1182
public void testBug284789_02e() throws JavaModelException {
1183
	this.formatterPrefs.alignment_for_method_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
1184
	this.formatterPrefs.alignment_for_parameters_in_method_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
1185
	String source =
1186
		"class X02 {\n" + 
1187
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name(String first, String second, String third) {\n" + 
1188
		"		return null;\n" + 
1189
		"	}\n" + 
1190
		"}\n";
1191
	formatSource(source,
1192
		"class X02 {\n" + 
1193
		"	public final synchronized\n" + 
1194
		"			java.lang.String\n" + 
1195
		"				a_method_which_have_a_very_long_name(\n" + 
1196
		"						String first,\n" + 
1197
		"							String second,\n" + 
1198
		"							String third) {\n" + 
1199
		"		return null;\n" + 
1200
		"	}\n" + 
1201
		"}\n"
1202
	);
1203
}
1204
public void testBug284789_02f() throws JavaModelException {
1205
	this.formatterPrefs.alignment_for_method_declaration = Alignment.M_NEXT_PER_LINE_SPLIT;
1206
	this.formatterPrefs.alignment_for_parameters_in_method_declaration = Alignment.M_NEXT_PER_LINE_SPLIT;
1207
	String source =
1208
		"class X02 {\n" + 
1209
		"	public final synchronized java.lang.String a_method_which_have_a_very_long_name(String first, String second, String third) {\n" + 
1210
		"		return null;\n" + 
1211
		"	}\n" + 
1212
		"}\n";
1213
	formatSource(source,
1214
		"class X02 {\n" + 
1215
		"	public final synchronized java.lang.String\n" + 
1216
		"			a_method_which_have_a_very_long_name(String first,\n" + 
1217
		"					String second,\n" + 
1218
		"					String third) {\n" + 
1219
		"		return null;\n" + 
1220
		"	}\n" + 
1221
		"}\n"
1222
	);
1223
}
1224
1225
/**
980
 * @bug 285565: [formatter] wrong indentation with 'Never join lines' selected
1226
 * @bug 285565: [formatter] wrong indentation with 'Never join lines' selected
981
 * @test Test to make sure that use either formatter or {@link IndentManipulation}
1227
 * @test Test to make sure that use either formatter or {@link IndentManipulation}
982
 * 	API methods an indentation set to zero does not thrown any exception.
1228
 * 	API methods an indentation set to zero does not thrown any exception.

Return to bug 284789