1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 192656: [Formatter] Indentation of class definition

and 191980: [Formatter] Identation of exception specification
This commit is contained in:
Anton Leherbauer 2008-02-27 13:07:54 +00:00
parent 8c248ed68b
commit 928c56b35e
7 changed files with 201 additions and 202 deletions

View file

@ -131,16 +131,16 @@ public class DefaultCodeFormatterConstants {
// * @see #createAlignmentValue(boolean, int, int) // * @see #createAlignmentValue(boolean, int, int)
// */ // */
// public static final String FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_binary_expression"; //$NON-NLS-1$ // public static final String FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_binary_expression"; //$NON-NLS-1$
// /** /**
// * <pre> * <pre>
// * FORMATTER / Option for alignment of compact if * FORMATTER / Option for alignment of compact if
// * - option id: "org.eclipse.cdt.core.formatter.alignment_for_compact_if" * - option id: "org.eclipse.cdt.core.formatter.alignment_for_compact_if"
// * - possible values: values returned by <code>createAlignmentValue(boolean, int, int)</code> call * - possible values: values returned by <code>createAlignmentValue(boolean, int, int)</code> call
// * - default: createAlignmentValue(false, WRAP_ONE_PER_LINE, INDENT_BY_ONE) * - default: createAlignmentValue(false, WRAP_ONE_PER_LINE, INDENT_BY_ONE)
// * </pre> * </pre>
// * @see #createAlignmentValue(boolean, int, int) * @see #createAlignmentValue(boolean, int, int)
// */ */
// public static final String FORMATTER_ALIGNMENT_FOR_COMPACT_IF = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_compact_if"; //$NON-NLS-1$ public static final String FORMATTER_ALIGNMENT_FOR_COMPACT_IF = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_compact_if"; //$NON-NLS-1$
/** /**
* <pre> * <pre>
* FORMATTER / Option for alignment of conditional expression * FORMATTER / Option for alignment of conditional expression
@ -211,26 +211,26 @@ public class DefaultCodeFormatterConstants {
// * @see #createAlignmentValue(boolean, int, int) // * @see #createAlignmentValue(boolean, int, int)
// */ // */
// public static final String FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_selector_in_method_invocation"; //$NON-NLS-1$ // public static final String FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_selector_in_method_invocation"; //$NON-NLS-1$
// /** /**
// * <pre> * <pre>
// * FORMATTER / Option for alignment of superclass in type declaration * FORMATTER / Option for alignment of base-clause in type declaration
// * - option id: "org.eclipse.cdt.core.formatter.alignment_for_superclass_in_type_declaration" * - option id: "org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration"
// * - possible values: values returned by <code>createAlignmentValue(boolean, int, int)</code> call * - possible values: values returned by <code>createAlignmentValue(boolean, int, int)</code> call
// * - default: createAlignmentValue(false, WRAP_NEXT_SHIFTED, INDENT_DEFAULT) * - default: createAlignmentValue(false, WRAP_NEXT_SHIFTED, INDENT_DEFAULT)
// * </pre> * </pre>
// * @see #createAlignmentValue(boolean, int, int) * @see #createAlignmentValue(boolean, int, int)
// */ */
// public static final String FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_superclass_in_type_declaration"; //$NON-NLS-1$ public static final String FORMATTER_ALIGNMENT_FOR_BASE_CLAUSE_IN_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_base_clause_in_type_declaration"; //$NON-NLS-1$
// /** /**
// * <pre> * <pre>
// * FORMATTER / Option for alignment of throws clause in method declaration * FORMATTER / Option for alignment of throws clause in method declaration
// * - option id: "org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration" * - option id: "org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration"
// * - possible values: values returned by <code>createAlignmentValue(boolean, int, int)</code> call * - possible values: values returned by <code>createAlignmentValue(boolean, int, int)</code> call
// * - default: createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT) * - default: createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
// * </pre> * </pre>
// * @see #createAlignmentValue(boolean, int, int) * @see #createAlignmentValue(boolean, int, int)
// */ */
// public static final String FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_throws_clause_in_method_declaration"; //$NON-NLS-1$ public static final String FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_throws_clause_in_method_declaration"; //$NON-NLS-1$
// //
// /** // /**
// * <pre> // * <pre>
@ -916,17 +916,17 @@ public class DefaultCodeFormatterConstants {
* @see CCorePlugin#DO_NOT_INSERT * @see CCorePlugin#DO_NOT_INSERT
*/ */
public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_declaration_parameters"; //$NON-NLS-1$ public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_declaration_parameters"; //$NON-NLS-1$
// /** /**
// * <pre> * <pre>
// * FORMATTER / Option to insert a space after the comma in the exception names in a throws clause of a method declaration * FORMATTER / Option to insert a space after the comma in the exception names in a throws clause of a method declaration
// * - option id: "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" * - option id: "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws"
// * - possible values: { INSERT, DO_NOT_INSERT } * - possible values: { INSERT, DO_NOT_INSERT }
// * - default: INSERT * - default: INSERT
// * </pre> * </pre>
// * @see CCorePlugin#INSERT * @see CCorePlugin#INSERT
// * @see CCorePlugin#DO_NOT_INSERT * @see CCorePlugin#DO_NOT_INSERT
// */ */
// public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_declaration_throws"; //$NON-NLS-1$ public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_declaration_throws"; //$NON-NLS-1$
/** /**
* <pre> * <pre>
* FORMATTER / Option to insert a space after the comma in the arguments of a method invocation * FORMATTER / Option to insert a space after the comma in the arguments of a method invocation
@ -1488,17 +1488,17 @@ public class DefaultCodeFormatterConstants {
* @see CCorePlugin#DO_NOT_INSERT * @see CCorePlugin#DO_NOT_INSERT
*/ */
public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_declaration_parameters"; //$NON-NLS-1$ public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_declaration_parameters"; //$NON-NLS-1$
// /** /**
// * <pre> * <pre>
// * FORMATTER / Option to insert a space before comma in the exception names of the throws clause of a method declaration * FORMATTER / Option to insert a space before comma in the exception names of the throws clause of a method declaration
// * - option id: "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" * - option id: "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws"
// * - possible values: { INSERT, DO_NOT_INSERT } * - possible values: { INSERT, DO_NOT_INSERT }
// * - default: DO_NOT_INSERT * - default: DO_NOT_INSERT
// * </pre> * </pre>
// * @see CCorePlugin#INSERT * @see CCorePlugin#INSERT
// * @see CCorePlugin#DO_NOT_INSERT * @see CCorePlugin#DO_NOT_INSERT
// */ */
// public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_declaration_throws"; //$NON-NLS-1$ public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_declaration_throws"; //$NON-NLS-1$
/** /**
* <pre> * <pre>
* FORMATTER / Option to insert a space before comma in the arguments of a method invocation * FORMATTER / Option to insert a space before comma in the arguments of a method invocation

View file

@ -949,12 +949,8 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
final IASTName member= node.getMemberInitializerId(); final IASTName member= node.getMemberInitializerId();
if (member!= null) { if (member!= null) {
member.accept(this); member.accept(this);
scribe.printNextToken(Token.tLPAREN, false); // format like a function call
final IASTExpression value= node.getInitializerValue(); formatFunctionCallArguments(node.getInitializerValue());
if (value != null) {
value.accept(this);
}
scribe.printNextToken(Token.tRPAREN, false);
} else { } else {
formatRaw(node); formatRaw(node);
} }
@ -1052,12 +1048,10 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
} }
private void formatExceptionSpecification(final IASTTypeId[] exceptionSpecification) { private void formatExceptionSpecification(final IASTTypeId[] exceptionSpecification) {
// TLETODO [formatter] need special alignment for exception specification
if (exceptionSpecification.length > 0) { if (exceptionSpecification.length > 0) {
Alignment alignment =scribe.createAlignment( Alignment alignment =scribe.createAlignment(
"exceptionSpecification", //$NON-NLS-1$ "exceptionSpecification", //$NON-NLS-1$
// need configurable alignment preferences.alignment_for_throws_clause_in_method_declaration,
Alignment.M_COMPACT_SPLIT,
exceptionSpecification.length, exceptionSpecification.length,
scribe.scanner.getCurrentPosition()); scribe.scanner.getCurrentPosition());
@ -1067,19 +1061,23 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
try { try {
scribe.alignFragment(alignment, 0); scribe.alignFragment(alignment, 0);
scribe.printNextToken(Token.t_throw, true); scribe.printNextToken(Token.t_throw, true);
// preferences.insert_space_before_opening_paren_in_exception_specification_throw
scribe.printNextToken(Token.tLPAREN, scribe.printComment()); scribe.printNextToken(Token.tLPAREN, scribe.printComment());
if (false /* preferences.insert_space_after_opening_paren_in_exception_specification_throw */ ) {
scribe.space();
}
exceptionSpecification[0].accept(this); exceptionSpecification[0].accept(this);
for (int i = 1; i < exceptionSpecification.length; i++) { for (int i = 1; i < exceptionSpecification.length; i++) {
// insert_space_before_comma_in_method_declaration_throws // insert_space_before_comma_in_method_declaration_throws
scribe.printNextToken(Token.tCOMMA, preferences.insert_space_before_comma_in_initializer_list); scribe.printNextToken(Token.tCOMMA, preferences.insert_space_before_comma_in_method_declaration_throws);
scribe.printTrailingComment(); scribe.printTrailingComment();
// insert_space_after_comma_in_method_declaration_throws if (preferences.insert_space_after_comma_in_method_declaration_throws) {
if (preferences.insert_space_after_comma_in_initializer_list) {
scribe.space(); scribe.space();
} }
scribe.alignFragment(alignment, i); scribe.alignFragment(alignment, i);
exceptionSpecification[i].accept(this); exceptionSpecification[i].accept(this);
} }
// preferences.insert_space_before_closing_paren_in_exception_specification_throw
scribe.printNextToken(Token.tRPAREN, scribe.printComment()); scribe.printNextToken(Token.tRPAREN, scribe.printComment());
ok = true; ok = true;
} catch (AlignmentException e) { } catch (AlignmentException e) {
@ -1385,7 +1383,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
if (preferences.insert_space_after_colon_in_base_clause) { if (preferences.insert_space_after_colon_in_base_clause) {
scribe.space(); scribe.space();
} }
final ListAlignment align= new ListAlignment(Alignment.M_COMPACT_SPLIT); final ListAlignment align= new ListAlignment(preferences.alignment_for_base_clause_in_type_declaration);
align.fSpaceAfterComma= preferences.insert_space_after_comma_in_base_types; align.fSpaceAfterComma= preferences.insert_space_after_comma_in_base_types;
align.fSpaceBeforeComma= preferences.insert_space_before_comma_in_base_types; align.fSpaceBeforeComma= preferences.insert_space_before_comma_in_base_types;
formatList(baseSpecifiers, align, false, false); formatList(baseSpecifiers, align, false, false);
@ -2346,7 +2344,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
scribe.printNextToken(Token.tRBRACE, true); scribe.printNextToken(Token.tRBRACE, true);
scribe.printTrailingComment(); scribe.printTrailingComment();
} else { } else {
formatLeftCurlyBrace(line, preferences.brace_position_for_block); formatLeftCurlyBrace(line, preferences.brace_position_for_block);
thenStatement.accept(this); thenStatement.accept(this);
if (elseStatement != null && (preferences.insert_new_line_before_else_in_if_statement)) { if (elseStatement != null && (preferences.insert_new_line_before_else_in_if_statement)) {
scribe.startNewLine(); scribe.startNewLine();

View file

@ -65,8 +65,8 @@ public class DefaultCodeFormatterOptions {
public int alignment_for_enumerator_list; public int alignment_for_enumerator_list;
public int alignment_for_expression_list; public int alignment_for_expression_list;
public int alignment_for_parameters_in_method_declaration; public int alignment_for_parameters_in_method_declaration;
// public int alignment_for_superclass_in_type_declaration; public int alignment_for_base_clause_in_type_declaration;
// public int alignment_for_throws_clause_in_method_declaration; public int alignment_for_throws_clause_in_method_declaration;
// public boolean align_type_members_on_columns; // public boolean align_type_members_on_columns;
@ -137,7 +137,7 @@ public class DefaultCodeFormatterOptions {
// public boolean insert_space_after_comma_in_for_inits; // public boolean insert_space_after_comma_in_for_inits;
public boolean insert_space_after_comma_in_method_invocation_arguments; public boolean insert_space_after_comma_in_method_invocation_arguments;
public boolean insert_space_after_comma_in_method_declaration_parameters; public boolean insert_space_after_comma_in_method_declaration_parameters;
// public boolean insert_space_after_comma_in_method_declaration_throws; public boolean insert_space_after_comma_in_method_declaration_throws;
public boolean insert_space_after_comma_in_declarator_list; public boolean insert_space_after_comma_in_declarator_list;
public boolean insert_space_after_comma_in_expression_list; public boolean insert_space_after_comma_in_expression_list;
public boolean insert_space_after_comma_in_base_types; public boolean insert_space_after_comma_in_base_types;
@ -189,7 +189,7 @@ public class DefaultCodeFormatterOptions {
// public boolean insert_space_before_comma_in_for_inits; // public boolean insert_space_before_comma_in_for_inits;
public boolean insert_space_before_comma_in_method_invocation_arguments; public boolean insert_space_before_comma_in_method_invocation_arguments;
public boolean insert_space_before_comma_in_method_declaration_parameters; public boolean insert_space_before_comma_in_method_declaration_parameters;
// public boolean insert_space_before_comma_in_method_declaration_throws; public boolean insert_space_before_comma_in_method_declaration_throws;
public boolean insert_space_before_comma_in_declarator_list; public boolean insert_space_before_comma_in_declarator_list;
public boolean insert_space_before_comma_in_expression_list; public boolean insert_space_before_comma_in_expression_list;
public boolean insert_space_before_comma_in_base_types; public boolean insert_space_before_comma_in_base_types;
@ -259,7 +259,7 @@ public class DefaultCodeFormatterOptions {
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_arguments_in_method_invocation)); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_arguments_in_method_invocation));
// options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, getAlignment(this.alignment_for_assignment)); // options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, getAlignment(this.alignment_for_assignment));
// options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION, getAlignment(this.alignment_for_binary_expression)); // options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION, getAlignment(this.alignment_for_binary_expression));
// options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF, getAlignment(this.alignment_for_compact_if)); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF, getAlignment(this.alignment_for_compact_if));
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, getAlignment(this.alignment_for_conditional_expression)); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, getAlignment(this.alignment_for_conditional_expression));
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST, getAlignment(this.alignment_for_expressions_in_initializer_list)); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST, getAlignment(this.alignment_for_expressions_in_initializer_list));
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_DECLARATOR_LIST, getAlignment(this.alignment_for_declarator_list)); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_DECLARATOR_LIST, getAlignment(this.alignment_for_declarator_list));
@ -267,8 +267,8 @@ public class DefaultCodeFormatterOptions {
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSION_LIST, getAlignment(this.alignment_for_expression_list)); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSION_LIST, getAlignment(this.alignment_for_expression_list));
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_parameters_in_method_declaration)); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_parameters_in_method_declaration));
// options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_selector_in_method_invocation)); // options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_selector_in_method_invocation));
// options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION, getAlignment(this.alignment_for_superclass_in_type_declaration)); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BASE_CLAUSE_IN_TYPE_DECLARATION, getAlignment(this.alignment_for_base_clause_in_type_declaration));
// options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_throws_clause_in_method_declaration)); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_throws_clause_in_method_declaration));
// options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, this.align_type_members_on_columns ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); // options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, this.align_type_members_on_columns ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST, this.brace_position_for_initializer_list); options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST, this.brace_position_for_initializer_list);
options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, this.brace_position_for_block); options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, this.brace_position_for_block);
@ -332,7 +332,7 @@ public class DefaultCodeFormatterOptions {
// options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, this.insert_space_after_comma_in_for_inits? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); // options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, this.insert_space_after_comma_in_for_inits? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, this.insert_space_after_comma_in_method_invocation_arguments? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, this.insert_space_after_comma_in_method_invocation_arguments? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, this.insert_space_after_comma_in_method_declaration_parameters? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, this.insert_space_after_comma_in_method_declaration_parameters? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
// options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, this.insert_space_after_comma_in_method_declaration_throws? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, this.insert_space_after_comma_in_method_declaration_throws? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST, this.insert_space_after_comma_in_declarator_list? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST, this.insert_space_after_comma_in_declarator_list? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPRESSION_LIST, this.insert_space_after_comma_in_expression_list? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPRESSION_LIST, this.insert_space_after_comma_in_expression_list? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_BASE_TYPES, this.insert_space_after_comma_in_base_types? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_BASE_TYPES, this.insert_space_after_comma_in_base_types? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
@ -384,7 +384,7 @@ public class DefaultCodeFormatterOptions {
// options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, this.insert_space_before_comma_in_for_inits? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); // options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, this.insert_space_before_comma_in_for_inits? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, this.insert_space_before_comma_in_method_invocation_arguments? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, this.insert_space_before_comma_in_method_invocation_arguments? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, this.insert_space_before_comma_in_method_declaration_parameters? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, this.insert_space_before_comma_in_method_declaration_parameters? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
// options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, this.insert_space_before_comma_in_method_declaration_throws? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, this.insert_space_before_comma_in_method_declaration_throws? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST, this.insert_space_before_comma_in_declarator_list? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST, this.insert_space_before_comma_in_declarator_list? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPRESSION_LIST, this.insert_space_before_comma_in_expression_list? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPRESSION_LIST, this.insert_space_before_comma_in_expression_list? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_BASE_TYPES, this.insert_space_before_comma_in_base_types? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_BASE_TYPES, this.insert_space_before_comma_in_base_types? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
@ -485,16 +485,16 @@ public class DefaultCodeFormatterOptions {
// this.alignment_for_binary_expression = Alignment.M_COMPACT_SPLIT; // this.alignment_for_binary_expression = Alignment.M_COMPACT_SPLIT;
// } // }
// } // }
// final Object alignmentForCompactIfOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF); final Object alignmentForCompactIfOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF);
// if (alignmentForCompactIfOption != null) { if (alignmentForCompactIfOption != null) {
// try { try {
// this.alignment_for_compact_if = Integer.parseInt((String) alignmentForCompactIfOption); this.alignment_for_compact_if = Integer.parseInt((String) alignmentForCompactIfOption);
// } catch (NumberFormatException e) { } catch (NumberFormatException e) {
// this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE; this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE;
// } catch (ClassCastException e) { } catch (ClassCastException e) {
// this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE; this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE;
// } }
// } }
final Object alignmentForConditionalExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION); final Object alignmentForConditionalExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
if (alignmentForConditionalExpressionOption != null) { if (alignmentForConditionalExpressionOption != null) {
try { try {
@ -555,26 +555,26 @@ public class DefaultCodeFormatterOptions {
this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT; this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT;
} }
} }
// final Object alignmentForSuperclassInTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION); final Object alignmentForBaseClauseInTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BASE_CLAUSE_IN_TYPE_DECLARATION);
// if (alignmentForSuperclassInTypeDeclarationOption != null) { if (alignmentForBaseClauseInTypeDeclarationOption != null) {
// try { try {
// this.alignment_for_superclass_in_type_declaration = Integer.parseInt((String) alignmentForSuperclassInTypeDeclarationOption); this.alignment_for_base_clause_in_type_declaration = Integer.parseInt((String) alignmentForBaseClauseInTypeDeclarationOption);
// } catch (NumberFormatException e) { } catch (NumberFormatException e) {
// this.alignment_for_superclass_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT; this.alignment_for_base_clause_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
// } catch(ClassCastException e) { } catch(ClassCastException e) {
// this.alignment_for_superclass_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT; this.alignment_for_base_clause_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
// } }
// } }
// final Object alignmentForThrowsClauseInMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION); final Object alignmentForThrowsClauseInMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION);
// if (alignmentForThrowsClauseInMethodDeclarationOption != null) { if (alignmentForThrowsClauseInMethodDeclarationOption != null) {
// try { try {
// this.alignment_for_throws_clause_in_method_declaration = Integer.parseInt((String) alignmentForThrowsClauseInMethodDeclarationOption); this.alignment_for_throws_clause_in_method_declaration = Integer.parseInt((String) alignmentForThrowsClauseInMethodDeclarationOption);
// } catch (NumberFormatException e) { } catch (NumberFormatException e) {
// this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT; this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
// } catch(ClassCastException e) { } catch(ClassCastException e) {
// this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT; this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
// } }
// } }
// final Object alignTypeMembersOnColumnsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS); // final Object alignTypeMembersOnColumnsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS);
// if (alignTypeMembersOnColumnsOption != null) { // if (alignTypeMembersOnColumnsOption != null) {
// this.align_type_members_on_columns = DefaultCodeFormatterConstants.TRUE.equals(alignTypeMembersOnColumnsOption); // this.align_type_members_on_columns = DefaultCodeFormatterConstants.TRUE.equals(alignTypeMembersOnColumnsOption);
@ -937,10 +937,10 @@ public class DefaultCodeFormatterOptions {
if (insertSpaceAfterCommaInMethodDeclarationParametersOption != null) { if (insertSpaceAfterCommaInMethodDeclarationParametersOption != null) {
this.insert_space_after_comma_in_method_declaration_parameters = CCorePlugin.INSERT.equals(insertSpaceAfterCommaInMethodDeclarationParametersOption); this.insert_space_after_comma_in_method_declaration_parameters = CCorePlugin.INSERT.equals(insertSpaceAfterCommaInMethodDeclarationParametersOption);
} }
// final Object insertSpaceAfterCommaInMethodDeclarationThrowsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS); final Object insertSpaceAfterCommaInMethodDeclarationThrowsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS);
// if (insertSpaceAfterCommaInMethodDeclarationThrowsOption != null) { if (insertSpaceAfterCommaInMethodDeclarationThrowsOption != null) {
// this.insert_space_after_comma_in_method_declaration_throws = CCorePlugin.INSERT.equals(insertSpaceAfterCommaInMethodDeclarationThrowsOption); this.insert_space_after_comma_in_method_declaration_throws = CCorePlugin.INSERT.equals(insertSpaceAfterCommaInMethodDeclarationThrowsOption);
// } }
final Object insertSpaceAfterCommaInMultipleFieldDeclarationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST); final Object insertSpaceAfterCommaInMultipleFieldDeclarationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST);
if (insertSpaceAfterCommaInMultipleFieldDeclarationsOption != null) { if (insertSpaceAfterCommaInMultipleFieldDeclarationsOption != null) {
this.insert_space_after_comma_in_declarator_list = CCorePlugin.INSERT.equals(insertSpaceAfterCommaInMultipleFieldDeclarationsOption); this.insert_space_after_comma_in_declarator_list = CCorePlugin.INSERT.equals(insertSpaceAfterCommaInMultipleFieldDeclarationsOption);
@ -1149,10 +1149,10 @@ public class DefaultCodeFormatterOptions {
if (insertSpaceBeforeCommaInMethodDeclarationParametersOption != null) { if (insertSpaceBeforeCommaInMethodDeclarationParametersOption != null) {
this.insert_space_before_comma_in_method_declaration_parameters = CCorePlugin.INSERT.equals(insertSpaceBeforeCommaInMethodDeclarationParametersOption); this.insert_space_before_comma_in_method_declaration_parameters = CCorePlugin.INSERT.equals(insertSpaceBeforeCommaInMethodDeclarationParametersOption);
} }
// final Object insertSpaceBeforeCommaInMethodDeclarationThrowsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS); final Object insertSpaceBeforeCommaInMethodDeclarationThrowsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS);
// if (insertSpaceBeforeCommaInMethodDeclarationThrowsOption != null) { if (insertSpaceBeforeCommaInMethodDeclarationThrowsOption != null) {
// this.insert_space_before_comma_in_method_declaration_throws = CCorePlugin.INSERT.equals(insertSpaceBeforeCommaInMethodDeclarationThrowsOption); this.insert_space_before_comma_in_method_declaration_throws = CCorePlugin.INSERT.equals(insertSpaceBeforeCommaInMethodDeclarationThrowsOption);
// } }
final Object insertSpaceBeforeCommaInMultipleFieldDeclarationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST); final Object insertSpaceBeforeCommaInMultipleFieldDeclarationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST);
if (insertSpaceBeforeCommaInMultipleFieldDeclarationsOption != null) { if (insertSpaceBeforeCommaInMultipleFieldDeclarationsOption != null) {
this.insert_space_before_comma_in_declarator_list = CCorePlugin.INSERT.equals(insertSpaceBeforeCommaInMultipleFieldDeclarationsOption); this.insert_space_before_comma_in_declarator_list = CCorePlugin.INSERT.equals(insertSpaceBeforeCommaInMultipleFieldDeclarationsOption);
@ -1375,8 +1375,8 @@ public class DefaultCodeFormatterOptions {
this.alignment_for_enumerator_list = Alignment.M_ONE_PER_LINE_SPLIT; this.alignment_for_enumerator_list = Alignment.M_ONE_PER_LINE_SPLIT;
this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT; this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT;
// this.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT; // this.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT;
// this.alignment_for_superclass_in_type_declaration = Alignment.M_COMPACT_SPLIT; this.alignment_for_base_clause_in_type_declaration = Alignment.M_NEXT_PER_LINE_SPLIT;
// this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT; this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
// this.align_type_members_on_columns = false; // this.align_type_members_on_columns = false;
this.brace_position_for_initializer_list = DefaultCodeFormatterConstants.END_OF_LINE; this.brace_position_for_initializer_list = DefaultCodeFormatterConstants.END_OF_LINE;
this.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE; this.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE;
@ -1442,7 +1442,7 @@ public class DefaultCodeFormatterOptions {
this.insert_space_after_comma_in_enum_declarations = true; this.insert_space_after_comma_in_enum_declarations = true;
this.insert_space_after_comma_in_method_invocation_arguments = true; this.insert_space_after_comma_in_method_invocation_arguments = true;
this.insert_space_after_comma_in_method_declaration_parameters = true; this.insert_space_after_comma_in_method_declaration_parameters = true;
// this.insert_space_after_comma_in_method_declaration_throws = true; this.insert_space_after_comma_in_method_declaration_throws = true;
this.insert_space_after_comma_in_declarator_list = true; this.insert_space_after_comma_in_declarator_list = true;
this.insert_space_after_comma_in_expression_list = true; this.insert_space_after_comma_in_expression_list = true;
this.insert_space_after_comma_in_base_types = true; this.insert_space_after_comma_in_base_types = true;
@ -1495,7 +1495,7 @@ public class DefaultCodeFormatterOptions {
// this.insert_space_before_comma_in_for_inits = false; // this.insert_space_before_comma_in_for_inits = false;
this.insert_space_before_comma_in_method_invocation_arguments = false; this.insert_space_before_comma_in_method_invocation_arguments = false;
this.insert_space_before_comma_in_method_declaration_parameters = false; this.insert_space_before_comma_in_method_declaration_parameters = false;
// this.insert_space_before_comma_in_method_declaration_throws = false; this.insert_space_before_comma_in_method_declaration_throws = false;
this.insert_space_before_comma_in_declarator_list = false; this.insert_space_before_comma_in_declarator_list = false;
this.insert_space_before_comma_in_expression_list = false; this.insert_space_before_comma_in_expression_list = false;
this.insert_space_before_comma_in_base_types = false; this.insert_space_before_comma_in_base_types = false;

View file

@ -28,6 +28,7 @@ import org.eclipse.cdt.ui.tests.BaseUITestCase;
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil; import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
import org.eclipse.cdt.internal.formatter.DefaultCodeFormatterOptions; import org.eclipse.cdt.internal.formatter.DefaultCodeFormatterOptions;
import org.eclipse.cdt.internal.formatter.align.Alignment;
/** /**
* Tests for the CodeFormatter. * Tests for the CodeFormatter.
@ -491,4 +492,43 @@ public class CodeFormatterTest extends BaseUITestCase {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, CCorePlugin.DO_NOT_INSERT); fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, CCorePlugin.DO_NOT_INSERT);
assertFormatterResult(); assertFormatterResult();
} }
//class Example: public FooClass, public virtual BarClass {};
//class Example:
// public FooClass,
// public virtual BarClass {
//};
public void testAlignmentOfClassDefinitionBaseClause1_Bug192656() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BASE_CLAUSE_IN_TYPE_DECLARATION,
Integer.toString(Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_FORCE));
assertFormatterResult();
}
//class Example: public FooClass, public virtual BarClass {};
//class Example: public FooClass,
// public virtual BarClass {
//};
public void testAlignmentOfClassDefinitionBaseClause2_Bug192656() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BASE_CLAUSE_IN_TYPE_DECLARATION,
Integer.toString(Alignment.M_NEXT_PER_LINE_SPLIT | Alignment.M_FORCE | Alignment.M_INDENT_ON_COLUMN));
assertFormatterResult();
}
//class Example: { void foo() throw(int); };
//void Example::foo()throw(int){}
//class Example: {
// void foo()
// throw(int);
//};
//void Example::foo()
// throw(int) {
//}
public void testAlignmentOfExceptionSpecificationInMethodDeclaration_Bug191980() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION,
Integer.toString(Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_FORCE | Alignment.M_INDENT_BY_ONE));
assertFormatterResult();
}
} }

View file

@ -207,29 +207,23 @@ final class FormatterMessages extends NLS {
public static String WhiteSpaceOptions_after_ellipsis; public static String WhiteSpaceOptions_after_ellipsis;
public static String WhiteSpaceOptions_return_with_parenthesized_expression; public static String WhiteSpaceOptions_return_with_parenthesized_expression;
public static String WhiteSpaceOptions_throw_with_parenthesized_expression; public static String WhiteSpaceOptions_throw_with_parenthesized_expression;
// public static String LineWrappingTabPage_compact_if_else; public static String LineWrappingTabPage_base_clause;
public static String LineWrappingTabPage_compact_if_else;
public static String LineWrappingTabPage_parameters; public static String LineWrappingTabPage_parameters;
public static String LineWrappingTabPage_parameters_description;
public static String LineWrappingTabPage_arguments; public static String LineWrappingTabPage_arguments;
public static String LineWrappingTabPage_arguments_description; public static String LineWrappingTabPage_throws_clause;
// public static String LineWrappingTabPage_throws_clause;
public static String LineWrappingTabPage_initializer_list; public static String LineWrappingTabPage_initializer_list;
public static String LineWrappingTabPage_initializer_list_description;
public static String LineWrappingTabPage_conditionals; public static String LineWrappingTabPage_conditionals;
public static String LineWrappingTabPage_conditionals_description;
// public static String LineWrappingTabPage_binary_exprs; // public static String LineWrappingTabPage_binary_exprs;
public static String LineWrappingTabPage_indentation_default; public static String LineWrappingTabPage_indentation_default;
public static String LineWrappingTabPage_indentation_on_column; public static String LineWrappingTabPage_indentation_on_column;
public static String LineWrappingTabPage_indentation_by_one; public static String LineWrappingTabPage_indentation_by_one;
// public static String LineWrappingTabPage_class_decls; public static String LineWrappingTabPage_class_decls;
public static String LineWrappingTabPage_method_decls; public static String LineWrappingTabPage_method_decls;
public static String LineWrappingTabPage_method_decls_description;
// public static String LineWrappingTabPage_constructor_decls; // public static String LineWrappingTabPage_constructor_decls;
public static String LineWrappingTabPage_function_calls; public static String LineWrappingTabPage_function_calls;
public static String LineWrappingTabPage_function_calls_description;
public static String LineWrappingTabPage_expressions; public static String LineWrappingTabPage_expressions;
public static String LineWrappingTabPage_expressions_description; public static String LineWrappingTabPage_statements;
// public static String LineWrappingTabPage_statements;
public static String LineWrappingTabPage_wrapping_policy_label_text; public static String LineWrappingTabPage_wrapping_policy_label_text;
public static String LineWrappingTabPage_indentation_policy_label_text; public static String LineWrappingTabPage_indentation_policy_label_text;
public static String LineWrappingTabPage_force_split_checkbox_text; public static String LineWrappingTabPage_force_split_checkbox_text;

View file

@ -237,30 +237,24 @@ WhiteSpaceOptions_after_ellipsis=After Ellipsis
WhiteSpaceTabPage_insert_space=&Insert space: WhiteSpaceTabPage_insert_space=&Insert space:
#LineWrappingTabPage_compact_if_else=Compact 'if else' LineWrappingTabPage_base_clause=Base-clause
LineWrappingTabPage_compact_if_else=Compact 'if else'
LineWrappingTabPage_parameters=Parameters LineWrappingTabPage_parameters=Parameters
LineWrappingTabPage_parameters_description=parameters
LineWrappingTabPage_arguments=Arguments LineWrappingTabPage_arguments=Arguments
LineWrappingTabPage_arguments_description=arguments LineWrappingTabPage_throws_clause=Exception specification
#LineWrappingTabPage_throws_clause='throws' clause
#LineWrappingTabPage_object_allocation=Object allocation arguments #LineWrappingTabPage_object_allocation=Object allocation arguments
LineWrappingTabPage_initializer_list=Initializer List LineWrappingTabPage_initializer_list=Initializer List
LineWrappingTabPage_initializer_list_description=initializer list
LineWrappingTabPage_conditionals=Conditionals LineWrappingTabPage_conditionals=Conditionals
LineWrappingTabPage_conditionals_description=conditionals
#LineWrappingTabPage_binary_exprs=Binary expressions #LineWrappingTabPage_binary_exprs=Binary expressions
LineWrappingTabPage_indentation_default=Default indentation LineWrappingTabPage_indentation_default=Default indentation
LineWrappingTabPage_indentation_on_column=Indent on column LineWrappingTabPage_indentation_on_column=Indent on column
LineWrappingTabPage_indentation_by_one=Indent by one LineWrappingTabPage_indentation_by_one=Indent by one
#LineWrappingTabPage_class_decls=Class Declarations LineWrappingTabPage_class_decls=Class Declarations
LineWrappingTabPage_method_decls=Function Declarations LineWrappingTabPage_method_decls=Function Declarations
LineWrappingTabPage_method_decls_description=function declarations
#LineWrappingTabPage_constructor_decls=Constructor declarations #LineWrappingTabPage_constructor_decls=Constructor declarations
LineWrappingTabPage_function_calls=Function Calls LineWrappingTabPage_function_calls=Function Calls
LineWrappingTabPage_function_calls_description=function calls
LineWrappingTabPage_expressions=Expressions LineWrappingTabPage_expressions=Expressions
LineWrappingTabPage_expressions_description=expressions LineWrappingTabPage_statements=Statements
#LineWrappingTabPage_statements=Statements
LineWrappingTabPage_wrapping_policy_label_text=Lin&e wrapping policy: LineWrappingTabPage_wrapping_policy_label_text=Lin&e wrapping policy:
LineWrappingTabPage_indentation_policy_label_text=Indent&ation policy: LineWrappingTabPage_indentation_policy_label_text=Indent&ation policy:
LineWrappingTabPage_force_split_checkbox_text=&Force split LineWrappingTabPage_force_split_checkbox_text=&Force split

View file

@ -61,16 +61,14 @@ public class LineWrappingTabPage extends FormatterTabPage {
private final static class Category { private final static class Category {
public final String key; public final String key;
public final String name; public final String name;
public final String description;
public final String previewText; public final String previewText;
public final List children; public final List children;
public int index; public int index;
public Category(String _key, String _previewText, String _name, String _description) { public Category(String _key, String _previewText, String _name) {
this.key= _key; this.key= _key;
this.name= _name; this.name= _name;
this.description = _description;
this.previewText= _previewText != null ? createPreviewHeader(_name) + _previewText : null; this.previewText= _previewText != null ? createPreviewHeader(_name) + _previewText : null;
children= new ArrayList(); children= new ArrayList();
} }
@ -78,8 +76,8 @@ public class LineWrappingTabPage extends FormatterTabPage {
/** /**
* @param _name Category name * @param _name Category name
*/ */
public Category(String _name, String _description) { public Category(String _name) {
this(null, null, _name, _description); this(null, null, _name);
} }
public String toString() { public String toString() {
@ -139,8 +137,8 @@ public class LineWrappingTabPage extends FormatterTabPage {
private String getGroupLabel(Category category) { private String getGroupLabel(Category category) {
if (fSelection.size() == 1) { if (fSelection.size() == 1) {
if (fSelectionState.getElements().size() == 1) if (fSelectionState.getElements().size() == 1)
return Messages.format(FormatterMessages.LineWrappingTabPage_group, category.description); return Messages.format(FormatterMessages.LineWrappingTabPage_group, category.name.toLowerCase());
return Messages.format(FormatterMessages.LineWrappingTabPage_multi_group, new String[] {category.description, Integer.toString(fSelectionState.getElements().size())}); return Messages.format(FormatterMessages.LineWrappingTabPage_multi_group, new String[] {category.name.toLowerCase(), Integer.toString(fSelectionState.getElements().size())});
} }
return Messages.format(FormatterMessages.LineWrappingTabPage_multiple_selections, new String[] {Integer.toString(fSelectionState.getElements().size())}); return Messages.format(FormatterMessages.LineWrappingTabPage_multiple_selections, new String[] {Integer.toString(fSelectionState.getElements().size())});
} }
@ -356,29 +354,21 @@ public class LineWrappingTabPage extends FormatterTabPage {
// private final Category fCompactIfCategory= new Category( // private final Category fCompactIfCategory= new Category(
// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF, // DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF,
// "class Example {" + //$NON-NLS-1$
// "int foo(int argument) {" + //$NON-NLS-1$ // "int foo(int argument) {" + //$NON-NLS-1$
// " if (argument==0) return 0;" + //$NON-NLS-1$ // " if (argument==0) return 0;" + //$NON-NLS-1$
// " if (argument==1) return 42; else return 43;" + //$NON-NLS-1$ // " if (argument==1) return 42; else return 43;" + //$NON-NLS-1$
// "}}", //$NON-NLS-1$ // "}", //$NON-NLS-1$
// FormatterMessages.LineWrappingTabPage_compact_if_else // FormatterMessages.LineWrappingTabPage_compact_if_else
// ); // );
//
//
// private final Category fTypeDeclarationSuperclassCategory= new Category( private final Category fTypeDeclarationBaseClauseCategory= new Category(
// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION, DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BASE_CLAUSE_IN_TYPE_DECLARATION,
// "class Example extends OtherClass {}", //$NON-NLS-1$ "class Example : public FooClass, virtual protected BarClass {};", //$NON-NLS-1$
// FormatterMessages.LineWrappingTabPage_extends_clause FormatterMessages.LineWrappingTabPage_base_clause
// ); );
//
//
// private final Category fTypeDeclarationSuperinterfacesCategory= new Category(
// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION,
// "class Example implements I1, I2, I3 {}", //$NON-NLS-1$
// FormatterMessages.LineWrappingTabPage_implements_clause
// );
//
//
// private final Category fConstructorDeclarationsParametersCategory= new Category( // private final Category fConstructorDeclarationsParametersCategory= new Category(
// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, // DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION,
// "class Example {Example(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { this();}" + //$NON-NLS-1$ // "class Example {Example(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { this();}" + //$NON-NLS-1$
@ -389,32 +379,24 @@ public class LineWrappingTabPage extends FormatterTabPage {
private final Category fMethodDeclarationsParametersCategory= new Category( private final Category fMethodDeclarationsParametersCategory= new Category(
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION,
"class Example {void foo(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) {}};", //$NON-NLS-1$ "class Example {void foo(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) {}};", //$NON-NLS-1$
FormatterMessages.LineWrappingTabPage_parameters, FormatterMessages.LineWrappingTabPage_parameters
FormatterMessages.LineWrappingTabPage_parameters_description
); );
private final Category fMessageSendArgumentsCategory= new Category( private final Category fMessageSendArgumentsCategory= new Category(
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION,
"class Other {static void bar(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9) {}};"+ //$NON-NLS-1$ "class Other {static void bar(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9) {}};"+ //$NON-NLS-1$
"void foo() {Other::bar(100, 200, 300, 400, 500, 600, 700, 800, 900);}", //$NON-NLS-1$ "void foo() {Other::bar(100, 200, 300, 400, 500, 600, 700, 800, 900);}", //$NON-NLS-1$
FormatterMessages.LineWrappingTabPage_arguments, FormatterMessages.LineWrappingTabPage_arguments
FormatterMessages.LineWrappingTabPage_arguments_description );
private final Category fMethodThrowsClauseCategory= new Category(
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION,
"class Example {" + //$NON-NLS-1$
"int foo() throw(FirstException, SecondException, ThirdException) {" + //$NON-NLS-1$
" return Other::doSomething();}};", //$NON-NLS-1$
FormatterMessages.LineWrappingTabPage_throws_clause
); );
// private final Category fMessageSendSelectorCategory= new Category(
// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION,
// "class Example {int foo(Some a) {return a.getFirst();}}", //$NON-NLS-1$
// FormatterMessages.LineWrappingTabPage_qualified_invocations
// );
//
// private final Category fMethodThrowsClauseCategory= new Category(
// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION,
// "class Example {" + //$NON-NLS-1$
// "int foo() throws FirstException, SecondException, ThirdException {" + //$NON-NLS-1$
// " return Other.doSomething();}}", //$NON-NLS-1$
// FormatterMessages.LineWrappingTabPage_throws_clause
// );
//
// private final Category fConstructorThrowsClauseCategory= new Category( // private final Category fConstructorThrowsClauseCategory= new Category(
// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION, // DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION,
// "class Example {" + //$NON-NLS-1$ // "class Example {" + //$NON-NLS-1$
@ -428,19 +410,12 @@ public class LineWrappingTabPage extends FormatterTabPage {
// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION, // DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION,
// "class Example {SomeClass foo() {return new SomeClass(100, 200, 300, 400, 500, 600, 700, 800, 900 );}}", //$NON-NLS-1$ // "class Example {SomeClass foo() {return new SomeClass(100, 200, 300, 400, 500, 600, 700, 800, 900 );}}", //$NON-NLS-1$
// FormatterMessages.LineWrappingTabPage_object_allocation // FormatterMessages.LineWrappingTabPage_object_allocation
// );
//
// private final Category fQualifiedAllocationExpressionCategory= new Category (
// DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION,
// "class Example {SomeClass foo() {return SomeOtherClass.new SomeClass(100, 200, 300, 400, 500 );}}", //$NON-NLS-1$
// FormatterMessages.LineWrappingTabPage_qualified_object_allocation
// ); // );
private final Category fArrayInitializerExpressionsCategory= new Category( private final Category fInitializerListExpressionsCategory= new Category(
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST, DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST,
"int array[]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};", //$NON-NLS-1$ "int array[]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};", //$NON-NLS-1$
FormatterMessages.LineWrappingTabPage_initializer_list, FormatterMessages.LineWrappingTabPage_initializer_list
FormatterMessages.LineWrappingTabPage_initializer_list_description
); );
// private final Category fExplicitConstructorArgumentsCategory= new Category( // private final Category fExplicitConstructorArgumentsCategory= new Category(
@ -452,8 +427,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
private final Category fConditionalExpressionCategory= new Category( private final Category fConditionalExpressionCategory= new Category(
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION,
"int compare(int argument, int argument2) {return argument > argument2 ? 100000 : 200000;}", //$NON-NLS-1$ "int compare(int argument, int argument2) {return argument > argument2 ? 100000 : 200000;}", //$NON-NLS-1$
FormatterMessages.LineWrappingTabPage_conditionals, FormatterMessages.LineWrappingTabPage_conditionals
FormatterMessages.LineWrappingTabPage_conditionals_description
); );
// private final Category fBinaryExpressionCategory= new Category( // private final Category fBinaryExpressionCategory= new Category(
@ -582,41 +556,40 @@ public class LineWrappingTabPage extends FormatterTabPage {
*/ */
protected List createCategories() { protected List createCategories() {
// final Category classDeclarations= new Category(FormatterMessages.LineWrappingTabPage_class_decls); final Category classDeclarations= new Category(FormatterMessages.LineWrappingTabPage_class_decls);
// classDeclarations.children.add(fTypeDeclarationSuperclassCategory); classDeclarations.children.add(fTypeDeclarationBaseClauseCategory);
// classDeclarations.children.add(fTypeDeclarationSuperinterfacesCategory);
// final Category constructorDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_constructor_decls); // final Category constructorDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_constructor_decls);
// constructorDeclarations.children.add(fConstructorDeclarationsParametersCategory); // constructorDeclarations.children.add(fConstructorDeclarationsParametersCategory);
// constructorDeclarations.children.add(fConstructorThrowsClauseCategory); // constructorDeclarations.children.add(fConstructorThrowsClauseCategory);
final Category methodDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_method_decls, FormatterMessages.LineWrappingTabPage_method_decls_description); final Category methodDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_method_decls);
methodDeclarations.children.add(fMethodDeclarationsParametersCategory); methodDeclarations.children.add(fMethodDeclarationsParametersCategory);
// methodDeclarations.children.add(fMethodThrowsClauseCategory); methodDeclarations.children.add(fMethodThrowsClauseCategory);
// final Category enumDeclarations= new Category(FormatterMessages.LineWrappingTabPage_enum_decls); // final Category enumDeclarations= new Category(FormatterMessages.LineWrappingTabPage_enum_decls);
// enumDeclarations.children.add(fEnumConstantsCategory); // enumDeclarations.children.add(fEnumConstantsCategory);
// enumDeclarations.children.add(fEnumDeclInterfacesCategory); // enumDeclarations.children.add(fEnumDeclInterfacesCategory);
// enumDeclarations.children.add(fEnumConstArgumentsCategory); // enumDeclarations.children.add(fEnumConstArgumentsCategory);
final Category functionCalls= new Category(FormatterMessages.LineWrappingTabPage_function_calls, FormatterMessages.LineWrappingTabPage_function_calls_description); final Category functionCalls= new Category(FormatterMessages.LineWrappingTabPage_function_calls);
functionCalls.children.add(fMessageSendArgumentsCategory); functionCalls.children.add(fMessageSendArgumentsCategory);
// functionCalls.children.add(fMessageSendSelectorCategory); // functionCalls.children.add(fMessageSendSelectorCategory);
// functionCalls.children.add(fExplicitConstructorArgumentsCategory); // functionCalls.children.add(fExplicitConstructorArgumentsCategory);
// functionCalls.children.add(fAllocationExpressionArgumentsCategory); // functionCalls.children.add(fAllocationExpressionArgumentsCategory);
// functionCalls.children.add(fQualifiedAllocationExpressionCategory); // functionCalls.children.add(fQualifiedAllocationExpressionCategory);
final Category expressions= new Category(FormatterMessages.LineWrappingTabPage_expressions, FormatterMessages.LineWrappingTabPage_expressions_description); final Category expressions= new Category(FormatterMessages.LineWrappingTabPage_expressions);
// expressions.children.add(fBinaryExpressionCategory); // expressions.children.add(fBinaryExpressionCategory);
expressions.children.add(fConditionalExpressionCategory); expressions.children.add(fConditionalExpressionCategory);
expressions.children.add(fArrayInitializerExpressionsCategory); expressions.children.add(fInitializerListExpressionsCategory);
// expressions.children.add(fAssignmentCategory); // expressions.children.add(fAssignmentCategory);
// final Category statements= new Category(FormatterMessages.LineWrappingTabPage_statements); // final Category statements= new Category(FormatterMessages.LineWrappingTabPage_statements);
// statements.children.add(fCompactIfCategory); // statements.children.add(fCompactIfCategory);
final List root= new ArrayList(); final List root= new ArrayList();
// root.add(classDeclarations); root.add(classDeclarations);
// root.add(constructorDeclarations); // root.add(constructorDeclarations);
root.add(methodDeclarations); root.add(methodDeclarations);
// root.add(enumDeclarations); // root.add(enumDeclarations);