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

Collapse All | Expand All

(-)formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java (+58 lines)
Lines 1206-1216 Link Here
1206
	 * @see JavaCore#INSERT
1206
	 * @see JavaCore#INSERT
1207
	 * @see JavaCore#DO_NOT_INSERT
1207
	 * @see JavaCore#DO_NOT_INSERT
1208
	 * @since 3.4
1208
	 * @since 3.4
1209
	 * @deprecated
1210
	 * All new options must be enabled to activate old strategy
1211
	 * {@link #FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD}
1212
	 * {@link #FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD}
1213
	 * {@link #FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE}
1214
	 * {@link #FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE}
1209
	 */
1215
	 */
1210
	public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_annotation_on_member";//$NON-NLS-1$
1216
	public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_annotation_on_member";//$NON-NLS-1$
1211
1217
1212
	/**
1218
	/**
1213
	 * <pre>
1219
	 * <pre>
1220
	 * FORMATTER / Option to insert a new line after an annotation on a field declaration
1221
	 *     - option id:         "org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field"
1222
	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1223
	 *     - default:           INSERT
1224
	 * </pre>
1225
	 * @see JavaCore#INSERT
1226
	 * @see JavaCore#DO_NOT_INSERT
1227
	 * @since 3.7
1228
	 */
1229
	public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_annotation_on_field";//$NON-NLS-1$
1230
1231
	/**
1232
	 * <pre>
1233
	 * FORMATTER / Option to insert a new line after an annotation on a method declaration
1234
	 *     - option id:         "org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method"
1235
	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1236
	 *     - default:           INSERT
1237
	 * </pre>
1238
	 * @see JavaCore#INSERT
1239
	 * @see JavaCore#DO_NOT_INSERT
1240
	 * @since 3.7
1241
	 */
1242
	public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_annotation_on_method";//$NON-NLS-1$
1243
1244
	/**
1245
	 * <pre>
1246
	 * FORMATTER / Option to insert a new line after an annotation on a package declaration
1247
	 *     - option id:         "org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package"
1248
	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1249
	 *     - default:           INSERT
1250
	 * </pre>
1251
	 * @see JavaCore#INSERT
1252
	 * @see JavaCore#DO_NOT_INSERT
1253
	 * @since 3.7
1254
	 */
1255
	public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_annotation_on_package";//$NON-NLS-1$
1256
1257
	/**
1258
	 * <pre>
1259
	 * FORMATTER / Option to insert a new line after an annotation on a type declaration
1260
	 *     - option id:         "org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type"
1261
	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1262
	 *     - default:           INSERT
1263
	 * </pre>
1264
	 * @see JavaCore#INSERT
1265
	 * @see JavaCore#DO_NOT_INSERT
1266
	 * @since 3.7
1267
	 */
1268
	public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_annotation_on_type";//$NON-NLS-1$
1269
1270
	/**
1271
	 * <pre>
1214
	 * FORMATTER / Option to insert a new line after an annotation on a parameter
1272
	 * FORMATTER / Option to insert a new line after an annotation on a parameter
1215
	 *     - option id:         "org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter"
1273
	 *     - option id:         "org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter"
1216
	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1274
	 *     - possible values:   { INSERT, DO_NOT_INSERT }
(-)formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java (-8 / +8 lines)
Lines 561-567 Link Here
561
		Alignment memberAlignment = this.scribe.getMemberAlignment();
561
		Alignment memberAlignment = this.scribe.getMemberAlignment();
562
562
563
        this.scribe.printComment();
563
        this.scribe.printComment();
564
		this.scribe.printModifiers(fieldDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER);
564
		this.scribe.printModifiers(fieldDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_FIELD);
565
		this.scribe.space();
565
		this.scribe.space();
566
		/*
566
		/*
567
		 * Field type
567
		 * Field type
Lines 675-681 Link Here
675
		Alignment fieldAlignment = this.scribe.getMemberAlignment();
675
		Alignment fieldAlignment = this.scribe.getMemberAlignment();
676
676
677
        this.scribe.printComment();
677
        this.scribe.printComment();
678
		this.scribe.printModifiers(multiFieldDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER);
678
		this.scribe.printModifiers(multiFieldDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_FIELD);
679
		this.scribe.space();
679
		this.scribe.space();
680
680
681
		multiFieldDeclaration.declarations[0].type.traverse(this, scope);
681
		multiFieldDeclaration.declarations[0].type.traverse(this, scope);
Lines 911-917 Link Here
911
		this.scribe.printComment();
911
		this.scribe.printComment();
912
		int line = this.scribe.line;
912
		int line = this.scribe.line;
913
913
914
		this.scribe.printModifiers(typeDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER);
914
		this.scribe.printModifiers(typeDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_TYPE);
915
915
916
		if (this.scribe.line > line) {
916
		if (this.scribe.line > line) {
917
			// annotations introduced new line, but this is not a line wrapping
917
			// annotations introduced new line, but this is not a line wrapping
Lines 2443-2449 Link Here
2443
         * Print comments to get proper line number
2443
         * Print comments to get proper line number
2444
         */
2444
         */
2445
        this.scribe.printComment();
2445
        this.scribe.printComment();
2446
        this.scribe.printModifiers(annotationTypeMemberDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER);
2446
        this.scribe.printModifiers(annotationTypeMemberDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_METHOD);
2447
		this.scribe.space();
2447
		this.scribe.space();
2448
		/*
2448
		/*
2449
		 * Print the method return type
2449
		 * Print the method return type
Lines 3070-3076 Link Here
3070
				this.scribe.printEmptyLines(blankLinesBeforePackage);
3070
				this.scribe.printEmptyLines(blankLinesBeforePackage);
3071
			}
3071
			}
3072
3072
3073
			this.scribe.printModifiers(currentPackage.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER);
3073
			this.scribe.printModifiers(currentPackage.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_PACKAGE);
3074
			this.scribe.space();
3074
			this.scribe.space();
3075
			// dump the package keyword
3075
			// dump the package keyword
3076
			this.scribe.printNextToken(TerminalTokens.TokenNamepackage);
3076
			this.scribe.printNextToken(TerminalTokens.TokenNamepackage);
Lines 3306-3312 Link Here
3306
         */
3306
         */
3307
        this.scribe.printComment();
3307
        this.scribe.printComment();
3308
        int line = this.scribe.line;
3308
        int line = this.scribe.line;
3309
		this.scribe.printModifiers(constructorDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER);
3309
		this.scribe.printModifiers(constructorDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_METHOD);
3310
		if (this.scribe.line > line) {
3310
		if (this.scribe.line > line) {
3311
        	// annotations introduced new line, but this is not a line wrapping
3311
        	// annotations introduced new line, but this is not a line wrapping
3312
			// see 158267
3312
			// see 158267
Lines 3523-3529 Link Here
3523
         */
3523
         */
3524
        this.scribe.printComment();
3524
        this.scribe.printComment();
3525
        final int line = this.scribe.line;
3525
        final int line = this.scribe.line;
3526
        this.scribe.printModifiers(enumConstant.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER);
3526
        this.scribe.printModifiers(enumConstant.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_FIELD);
3527
		this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, false);
3527
		this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, false);
3528
		formatEnumConstantArguments(
3528
		formatEnumConstantArguments(
3529
			enumConstant,
3529
			enumConstant,
Lines 4219-4225 Link Here
4219
		do {
4219
		do {
4220
			try {
4220
			try {
4221
4221
4222
				this.scribe.printModifiers(methodDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER);
4222
				this.scribe.printModifiers(methodDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_METHOD);
4223
				int fragmentIndex = 0;
4223
				int fragmentIndex = 0;
4224
				this.scribe.alignFragment(methodDeclAlignment, fragmentIndex);
4224
				this.scribe.alignFragment(methodDeclAlignment, fragmentIndex);
4225
4225
(-)formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java (-11 / +48 lines)
Lines 135-141 Link Here
135
	public boolean indent_switchstatements_compare_to_switch;
135
	public boolean indent_switchstatements_compare_to_switch;
136
	public int indentation_size;
136
	public int indentation_size;
137
137
138
	public boolean insert_new_line_after_annotation_on_member;
138
	public boolean insert_new_line_after_annotation_on_type;
139
	public boolean insert_new_line_after_annotation_on_field;
140
	public boolean insert_new_line_after_annotation_on_method;
141
	public boolean insert_new_line_after_annotation_on_package;
139
	public boolean insert_new_line_after_annotation_on_parameter;
142
	public boolean insert_new_line_after_annotation_on_parameter;
140
	public boolean insert_new_line_after_annotation_on_local_variable;
143
	public boolean insert_new_line_after_annotation_on_local_variable;
141
	public boolean insert_new_line_after_label;
144
	public boolean insert_new_line_after_label;
Lines 421-427 Link Here
421
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, this.indent_switchstatements_compare_to_cases ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
424
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, this.indent_switchstatements_compare_to_cases ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
422
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, this.indent_switchstatements_compare_to_switch ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
425
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, this.indent_switchstatements_compare_to_switch ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
423
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, Integer.toString(this.indentation_size));
426
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, Integer.toString(this.indentation_size));
424
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, this.insert_new_line_after_annotation_on_member ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
427
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, this.insert_new_line_after_annotation_on_type ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
428
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, this.insert_new_line_after_annotation_on_field ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
429
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, this.insert_new_line_after_annotation_on_method ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
430
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, this.insert_new_line_after_annotation_on_package ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
425
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, this.insert_new_line_after_annotation_on_parameter ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
431
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, this.insert_new_line_after_annotation_on_parameter ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
426
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, this.insert_new_line_after_annotation_on_local_variable ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
432
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, this.insert_new_line_after_annotation_on_local_variable ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
427
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, this.insert_new_line_after_opening_brace_in_array_initializer? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
433
		options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, this.insert_new_line_after_opening_brace_in_array_initializer? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
Lines 2028-2043 Link Here
2028
				this.comment_clear_blank_lines_in_block_comment = DefaultCodeFormatterConstants.TRUE.equals(commentClearBlankLinesInBlockCommentOption);
2034
				this.comment_clear_blank_lines_in_block_comment = DefaultCodeFormatterConstants.TRUE.equals(commentClearBlankLinesInBlockCommentOption);
2029
			}
2035
			}
2030
		}
2036
		}
2031
		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247
2037
		// New line after annotations
2032
		final Object insertNewLineAfterAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION);
2038
		final Object insertNewLineAfterAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION);
2033
		if (insertNewLineAfterAnnotationOption != null) { // check if deprecated option was used
2039
		if (insertNewLineAfterAnnotationOption != null) { // check if deprecated 3.1 option was used
2034
			this.insert_new_line_after_annotation_on_member = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOption);
2040
			boolean insert = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOption);
2035
			this.insert_new_line_after_annotation_on_parameter = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOption);
2041
			this.insert_new_line_after_annotation_on_type = insert;
2036
			this.insert_new_line_after_annotation_on_local_variable = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOption);
2042
			this.insert_new_line_after_annotation_on_field = insert;
2043
			this.insert_new_line_after_annotation_on_method = insert;
2044
			this.insert_new_line_after_annotation_on_package = insert;
2045
			this.insert_new_line_after_annotation_on_parameter = insert;
2046
			this.insert_new_line_after_annotation_on_local_variable = insert;
2037
		} else {
2047
		} else {
2038
			final Object insertNewLineAfterAnnotationOnMemberOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER);
2048
			final Object insertNewLineAfterAnnotationOnMemberOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER);
2039
			if (insertNewLineAfterAnnotationOnMemberOption != null) { // otherwhise, use the new options
2049
			if (insertNewLineAfterAnnotationOnMemberOption != null) { // check if deprecated 3.4 option was used
2040
				this.insert_new_line_after_annotation_on_member = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnMemberOption);
2050
				boolean insert = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnMemberOption);
2051
				this.insert_new_line_after_annotation_on_type = insert;
2052
				this.insert_new_line_after_annotation_on_field = insert;
2053
				this.insert_new_line_after_annotation_on_method = insert;
2054
				this.insert_new_line_after_annotation_on_package = insert;
2055
			} else { // otherwise use new options
2056
				final Object insertNewLineAfterAnnotationOnTypeOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE);
2057
				if (insertNewLineAfterAnnotationOnTypeOption != null) {
2058
					this.insert_new_line_after_annotation_on_type = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnTypeOption);
2059
				}
2060
				final Object insertNewLineAfterAnnotationOnFieldOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD);
2061
				if (insertNewLineAfterAnnotationOnFieldOption != null) {
2062
					this.insert_new_line_after_annotation_on_field = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnFieldOption);
2063
				}
2064
				final Object insertNewLineAfterAnnotationOnMethodOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD);
2065
				if (insertNewLineAfterAnnotationOnMethodOption != null) {
2066
					this.insert_new_line_after_annotation_on_method = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnMethodOption);
2067
				}
2068
				final Object insertNewLineAfterAnnotationOnPackageOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE);
2069
				if (insertNewLineAfterAnnotationOnPackageOption != null) {
2070
					this.insert_new_line_after_annotation_on_package = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnPackageOption);
2071
				}
2041
			}
2072
			}
2042
			final Object insertNewLineAfterAnnotationOnParameterOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER);
2073
			final Object insertNewLineAfterAnnotationOnParameterOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER);
2043
			if (insertNewLineAfterAnnotationOnParameterOption != null) {
2074
			if (insertNewLineAfterAnnotationOnParameterOption != null) {
Lines 2126-2132 Link Here
2126
		this.indent_switchstatements_compare_to_cases = true;
2157
		this.indent_switchstatements_compare_to_cases = true;
2127
		this.indent_switchstatements_compare_to_switch = true;
2158
		this.indent_switchstatements_compare_to_switch = true;
2128
		this.indentation_size = 4;
2159
		this.indentation_size = 4;
2129
		this.insert_new_line_after_annotation_on_member = true;
2160
		this.insert_new_line_after_annotation_on_type = true;
2161
		this.insert_new_line_after_annotation_on_field = true;
2162
		this.insert_new_line_after_annotation_on_method = true;
2163
		this.insert_new_line_after_annotation_on_package = true;
2130
		this.insert_new_line_after_annotation_on_parameter = false;
2164
		this.insert_new_line_after_annotation_on_parameter = false;
2131
		this.insert_new_line_after_annotation_on_local_variable = true;
2165
		this.insert_new_line_after_annotation_on_local_variable = true;
2132
		this.insert_new_line_after_opening_brace_in_array_initializer = false;
2166
		this.insert_new_line_after_opening_brace_in_array_initializer = false;
Lines 2401-2407 Link Here
2401
		this.indent_switchstatements_compare_to_cases = true;
2435
		this.indent_switchstatements_compare_to_cases = true;
2402
		this.indent_switchstatements_compare_to_switch = false;
2436
		this.indent_switchstatements_compare_to_switch = false;
2403
		this.indentation_size = 4;
2437
		this.indentation_size = 4;
2404
		this.insert_new_line_after_annotation_on_member = true;
2438
		this.insert_new_line_after_annotation_on_type = true;
2439
		this.insert_new_line_after_annotation_on_field = true;
2440
		this.insert_new_line_after_annotation_on_method = true;
2441
		this.insert_new_line_after_annotation_on_package = true;
2405
		this.insert_new_line_after_annotation_on_parameter = false;
2442
		this.insert_new_line_after_annotation_on_parameter = false;
2406
		this.insert_new_line_after_annotation_on_local_variable = true;
2443
		this.insert_new_line_after_annotation_on_local_variable = true;
2407
		this.insert_new_line_after_opening_brace_in_array_initializer = false;
2444
		this.insert_new_line_after_opening_brace_in_array_initializer = false;
(-)formatter/org/eclipse/jdt/internal/formatter/ICodeFormatterConstants.java (-4 / +13 lines)
Lines 24-35 Link Here
24
	/** annotation on unspecified source*/
24
	/** annotation on unspecified source*/
25
	public static final int ANNOTATION_UNSPECIFIED = 0;
25
	public static final int ANNOTATION_UNSPECIFIED = 0;
26
26
27
	/** annotation on a member (type, method, field) */
27
	/** annotation on a type */
28
	public static final int ANNOTATION_ON_MEMBER = 1;
28
	public static final int ANNOTATION_ON_TYPE = 1;
29
30
	/** annotation on a field */
31
	public static final int ANNOTATION_ON_FIELD = 2;
32
33
	/** annotation on a method */
34
	public static final int ANNOTATION_ON_METHOD = 3;
35
36
	/** annotation on a package */
37
	public static final int ANNOTATION_ON_PACKAGE = 4;
29
38
30
	/** annotation on a parameter */
39
	/** annotation on a parameter */
31
	public static final int ANNOTATION_ON_PARAMETER = 2;
40
	public static final int ANNOTATION_ON_PARAMETER = 5;
32
41
33
	/** annotation on a local variable */
42
	/** annotation on a local variable */
34
	public static final int ANNOTATION_ON_LOCAL_VARIABLE = 3;
43
	public static final int ANNOTATION_ON_LOCAL_VARIABLE = 6;
35
}
44
}
(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-2 / +17 lines)
Lines 4469-4476 Link Here
4469
							// https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247
4469
							// https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247
4470
							boolean shouldAddNewLine = false;
4470
							boolean shouldAddNewLine = false;
4471
							switch (annotationSourceKind) {
4471
							switch (annotationSourceKind) {
4472
								case ICodeFormatterConstants.ANNOTATION_ON_MEMBER :
4472
								case ICodeFormatterConstants.ANNOTATION_ON_TYPE :
4473
									if (this.formatter.preferences.insert_new_line_after_annotation_on_member) {
4473
									if (this.formatter.preferences.insert_new_line_after_annotation_on_type) {
4474
										shouldAddNewLine = true;
4475
									}
4476
									break;
4477
								case ICodeFormatterConstants.ANNOTATION_ON_FIELD :
4478
									if (this.formatter.preferences.insert_new_line_after_annotation_on_field) {
4479
										shouldAddNewLine = true;
4480
									}
4481
									break;
4482
								case ICodeFormatterConstants.ANNOTATION_ON_METHOD :
4483
									if (this.formatter.preferences.insert_new_line_after_annotation_on_method) {
4484
										shouldAddNewLine = true;
4485
									}
4486
									break;
4487
								case ICodeFormatterConstants.ANNOTATION_ON_PACKAGE :
4488
									if (this.formatter.preferences.insert_new_line_after_annotation_on_package) {
4474
										shouldAddNewLine = true;
4489
										shouldAddNewLine = true;
4475
									}
4490
									}
4476
									break;
4491
									break;
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java (-8 / +175 lines)
Lines 10364-10370 Link Here
10364
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10364
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10365
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10365
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10366
		preferences.line_separator = "\n";//$NON-NLS-1$
10366
		preferences.line_separator = "\n";//$NON-NLS-1$
10367
		preferences.insert_new_line_after_annotation_on_member = false;
10367
		preferences.insert_new_line_after_annotation_on_type = false;
10368
		preferences.insert_new_line_after_annotation_on_field = false;
10369
		preferences.insert_new_line_after_annotation_on_method = false;
10370
		preferences.insert_new_line_after_annotation_on_package = false;
10368
		preferences.insert_new_line_after_annotation_on_parameter = true;
10371
		preferences.insert_new_line_after_annotation_on_parameter = true;
10369
		DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
10372
		DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
10370
		IRegion[] regions = new IRegion[] {
10373
		IRegion[] regions = new IRegion[] {
Lines 10378-10384 Link Here
10378
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10381
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10379
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10382
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10380
		preferences.line_separator = "\n";//$NON-NLS-1$
10383
		preferences.line_separator = "\n";//$NON-NLS-1$
10381
		preferences.insert_new_line_after_annotation_on_member = false;
10384
		preferences.insert_new_line_after_annotation_on_type = false;
10385
		preferences.insert_new_line_after_annotation_on_field = false;
10386
		preferences.insert_new_line_after_annotation_on_method = false;
10387
		preferences.insert_new_line_after_annotation_on_package = false;
10382
		preferences.insert_new_line_after_annotation_on_parameter = false;
10388
		preferences.insert_new_line_after_annotation_on_parameter = false;
10383
		DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
10389
		DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
10384
		IRegion[] regions = new IRegion[] {
10390
		IRegion[] regions = new IRegion[] {
Lines 10393-10399 Link Here
10393
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10399
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10394
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10400
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10395
		preferences.line_separator = "\n";//$NON-NLS-1$
10401
		preferences.line_separator = "\n";//$NON-NLS-1$
10396
		preferences.insert_new_line_after_annotation_on_member = false;
10402
		preferences.insert_new_line_after_annotation_on_type = false;
10403
		preferences.insert_new_line_after_annotation_on_field = false;
10404
		preferences.insert_new_line_after_annotation_on_method = false;
10405
		preferences.insert_new_line_after_annotation_on_package = false;
10397
		preferences.insert_new_line_after_annotation_on_parameter = true;
10406
		preferences.insert_new_line_after_annotation_on_parameter = true;
10398
		preferences.insert_new_line_after_annotation_on_local_variable = false;
10407
		preferences.insert_new_line_after_annotation_on_local_variable = false;
10399
		Hashtable javaCoreOptions = JavaCore.getOptions();
10408
		Hashtable javaCoreOptions = JavaCore.getOptions();
Lines 10419-10425 Link Here
10419
	public void test707() {
10428
	public void test707() {
10420
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10429
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10421
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10430
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10422
		preferences.insert_new_line_after_annotation_on_member = true;
10431
		preferences.insert_new_line_after_annotation_on_type = true;
10432
		preferences.insert_new_line_after_annotation_on_field = true;
10433
		preferences.insert_new_line_after_annotation_on_method = true;
10434
		preferences.insert_new_line_after_annotation_on_package = true;
10423
		preferences.insert_new_line_after_annotation_on_parameter = true;
10435
		preferences.insert_new_line_after_annotation_on_parameter = true;
10424
		preferences.insert_new_line_after_annotation_on_local_variable = false;
10436
		preferences.insert_new_line_after_annotation_on_local_variable = false;
10425
		preferences.line_separator = "\n";//$NON-NLS-1$
10437
		preferences.line_separator = "\n";//$NON-NLS-1$
Lines 10447-10453 Link Here
10447
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10459
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10448
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10460
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10449
		preferences.line_separator = "\n";//$NON-NLS-1$
10461
		preferences.line_separator = "\n";//$NON-NLS-1$
10450
		preferences.insert_new_line_after_annotation_on_member = true;
10462
		preferences.insert_new_line_after_annotation_on_type = true;
10463
		preferences.insert_new_line_after_annotation_on_field = true;
10464
		preferences.insert_new_line_after_annotation_on_method = true;
10465
		preferences.insert_new_line_after_annotation_on_package = true;
10451
		preferences.insert_new_line_after_annotation_on_parameter = false;
10466
		preferences.insert_new_line_after_annotation_on_parameter = false;
10452
		preferences.insert_new_line_after_annotation_on_local_variable = false;
10467
		preferences.insert_new_line_after_annotation_on_local_variable = false;
10453
		Hashtable javaCoreOptions = JavaCore.getOptions();
10468
		Hashtable javaCoreOptions = JavaCore.getOptions();
Lines 10473-10479 Link Here
10473
	public void test709() {
10488
	public void test709() {
10474
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10489
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10475
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10490
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10476
		preferences.insert_new_line_after_annotation_on_member = false;
10491
		preferences.insert_new_line_after_annotation_on_type = false;
10492
		preferences.insert_new_line_after_annotation_on_field = false;
10493
		preferences.insert_new_line_after_annotation_on_method = false;
10494
		preferences.insert_new_line_after_annotation_on_package = false;
10477
		preferences.insert_new_line_after_annotation_on_parameter = false;
10495
		preferences.insert_new_line_after_annotation_on_parameter = false;
10478
		preferences.insert_new_line_after_annotation_on_local_variable = false;
10496
		preferences.insert_new_line_after_annotation_on_local_variable = false;
10479
		preferences.line_separator = "\n";//$NON-NLS-1$
10497
		preferences.line_separator = "\n";//$NON-NLS-1$
Lines 10500-10506 Link Here
10500
	public void test710() {
10518
	public void test710() {
10501
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10519
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10502
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10520
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10503
		preferences.insert_new_line_after_annotation_on_member = false;
10521
		preferences.insert_new_line_after_annotation_on_type = false;
10522
		preferences.insert_new_line_after_annotation_on_field = false;
10523
		preferences.insert_new_line_after_annotation_on_method = false;
10524
		preferences.insert_new_line_after_annotation_on_package = false;
10504
		preferences.insert_new_line_after_annotation_on_parameter = true;
10525
		preferences.insert_new_line_after_annotation_on_parameter = true;
10505
		preferences.insert_new_line_after_annotation_on_local_variable = true;
10526
		preferences.insert_new_line_after_annotation_on_local_variable = true;
10506
		preferences.line_separator = "\n";//$NON-NLS-1$
10527
		preferences.line_separator = "\n";//$NON-NLS-1$
Lines 10527-10533 Link Here
10527
	public void test711() {
10548
	public void test711() {
10528
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10549
		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
10529
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10550
		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
10530
		preferences.insert_new_line_after_annotation_on_member = false;
10551
		preferences.insert_new_line_after_annotation_on_type = false;
10552
		preferences.insert_new_line_after_annotation_on_field = false;
10553
		preferences.insert_new_line_after_annotation_on_method = false;
10554
		preferences.insert_new_line_after_annotation_on_package = false;
10531
		preferences.insert_new_line_after_annotation_on_parameter = false;
10555
		preferences.insert_new_line_after_annotation_on_parameter = false;
10532
		preferences.insert_new_line_after_annotation_on_local_variable = true;
10556
		preferences.insert_new_line_after_annotation_on_local_variable = true;
10533
		preferences.line_separator = "\n";//$NON-NLS-1$
10557
		preferences.line_separator = "\n";//$NON-NLS-1$
Lines 10726-10729 Link Here
10726
		"}\n"
10750
		"}\n"
10727
	);
10751
	);
10728
}
10752
}
10753
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=308000
10754
public void test725() {
10755
	this.formatterPrefs = null;
10756
	this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
10757
	this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
10758
	this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
10759
	String source =
10760
		"@Deprecated package pack;\n" + 
10761
		"public class Test {\n" + 
10762
		"    @Deprecated Test(String s) {}\n" + 
10763
		"    @Deprecated String label;\n" + 
10764
		"    @Deprecated void foo() {}\n" + 
10765
		"    @Deprecated interface I {}\n" + 
10766
		"}\n";
10767
	formatSource(source,
10768
		"@Deprecated\n" +
10769
		"package pack;\n" + 
10770
		"\n" + 
10771
		"public class Test {\n" + 
10772
		"	@Deprecated\n" + 
10773
		"	Test(String s) {\n" + 
10774
		"	}\n" + 
10775
		"\n" + 
10776
		"	@Deprecated\n" + 
10777
		"	String label;\n" + 
10778
		"\n" + 
10779
		"	@Deprecated\n" + 
10780
		"	void foo() {\n" + 
10781
		"	}\n" + 
10782
		"\n" + 
10783
		"	@Deprecated\n" + 
10784
		"	interface I {\n" + 
10785
		"	}\n" + 
10786
		"}\n"
10787
	);
10788
}
10789
public void test726() {
10790
	this.formatterPrefs = null;
10791
	this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
10792
	this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
10793
	this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
10794
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, DefaultCodeFormatterConstants.FALSE);
10795
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, DefaultCodeFormatterConstants.FALSE);
10796
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, DefaultCodeFormatterConstants.FALSE);
10797
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, DefaultCodeFormatterConstants.FALSE);
10798
	String source =
10799
		"@Deprecated package pack;\n" + 
10800
		"public class Test {\n" + 
10801
		"    @Deprecated Test(String s) {}\n" + 
10802
		"    @Deprecated String label;\n" + 
10803
		"    @Deprecated void foo() {}\n" + 
10804
		"    @Deprecated interface I {}\n" + 
10805
		"}\n";
10806
	formatSource(source,
10807
		"@Deprecated package pack;\n" + 
10808
		"\n" + 
10809
		"public class Test {\n" + 
10810
		"	@Deprecated Test(String s) {\n" + 
10811
		"	}\n" + 
10812
		"\n" + 
10813
		"	@Deprecated String label;\n" + 
10814
		"\n" + 
10815
		"	@Deprecated void foo() {\n" + 
10816
		"	}\n" + 
10817
		"\n" + 
10818
		"	@Deprecated interface I {\n" + 
10819
		"	}\n" + 
10820
		"}\n"
10821
	);
10822
}
10823
10824
/**
10825
 * @deprecated Use a deprecated formatter option.
10826
 */
10827
public void test727() {
10828
	this.formatterPrefs = null;
10829
	this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
10830
	this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
10831
	this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
10832
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, DefaultCodeFormatterConstants.TRUE);
10833
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, DefaultCodeFormatterConstants.FALSE);
10834
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, DefaultCodeFormatterConstants.FALSE);
10835
	String source =
10836
		"@Deprecated package pack;\n" + 
10837
		"public class Test {\n" + 
10838
		"    @Deprecated Test(String s) {}\n" + 
10839
		"    @Deprecated String label;\n" + 
10840
		"    @Deprecated void foo() {}\n" + 
10841
		"    @Deprecated interface I {}\n" + 
10842
		"}\n";
10843
	formatSource(source,
10844
		"@Deprecated package pack;\n" + 
10845
		"\n" + 
10846
		"public class Test {\n" + 
10847
		"	@Deprecated Test(String s) {\n" + 
10848
		"	}\n" + 
10849
		"\n" + 
10850
		"	@Deprecated String label;\n" + 
10851
		"\n" + 
10852
		"	@Deprecated void foo() {\n" + 
10853
		"	}\n" + 
10854
		"\n" + 
10855
		"	@Deprecated interface I {\n" + 
10856
		"	}\n" + 
10857
		"}\n"
10858
	);
10859
}
10860
10861
/**
10862
 * @deprecated Use a deprecated formatter option.
10863
 */
10864
public void test728() {
10865
	this.formatterPrefs = null;
10866
	this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6);
10867
	this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6);
10868
	this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6);
10869
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, DefaultCodeFormatterConstants.FALSE);
10870
	String source =
10871
		"@Deprecated package pack;\n" + 
10872
		"public class Test {\n" + 
10873
		"    @Deprecated Test(String s) {}\n" + 
10874
		"    @Deprecated String label;\n" + 
10875
		"    @Deprecated void foo() {}\n" + 
10876
		"    @Deprecated interface I {}\n" + 
10877
		"}\n";
10878
	formatSource(source,
10879
		"@Deprecated package pack;\n" + 
10880
		"\n" + 
10881
		"public class Test {\n" + 
10882
		"	@Deprecated Test(String s) {\n" + 
10883
		"	}\n" + 
10884
		"\n" + 
10885
		"	@Deprecated String label;\n" + 
10886
		"\n" + 
10887
		"	@Deprecated void foo() {\n" + 
10888
		"	}\n" + 
10889
		"\n" + 
10890
		"	@Deprecated interface I {\n" + 
10891
		"	}\n" + 
10892
		"}\n"
10893
	);
10894
}
10895
10729
}
10896
}

Return to bug 308000