1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 14:15:23 +02:00

Fallback formatting of function declarations and calls.

This commit is contained in:
Sergey Prigogin 2011-03-03 21:42:56 +00:00
parent 8ed19fb591
commit 1502e06ab7
7 changed files with 205 additions and 127 deletions

View file

@ -114,7 +114,7 @@ public class DefaultCodeFormatterConstants {
* FORMATTER / Option for alignment of assignment
* - option id: "org.eclipse.cdt.core.formatter.alignment_for_assignment"
* - possible values: values returned by <code>createAlignmentValue(boolean, int, int)</code> call
* - default: createAlignmentValue(false, M_NO_ALIGNMENT, INDENT_DEFAULT)
* - default: createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
* </pre>
* @see #createAlignmentValue(boolean, int, int)
* @since 5.3

View file

@ -169,18 +169,19 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
}
private static class ListOptions {
public final int fMode;
public boolean fSpaceBeforeComma;
public boolean fSpaceAfterComma= true;
public boolean fSpaceAfterOpeningParen;
public boolean fSpaceBeforeClosingParen;
public boolean fSpaceBetweenEmptyParen;
public boolean fSpaceBeforeOpeningParen;
public int fContinuationIndentation= -1;
public int fTieBreakRule = Alignment.R_INNERMOST;
final int fMode;
boolean fUseFallbackMode;
boolean fSpaceBeforeComma;
boolean fSpaceAfterComma = true;
boolean fSpaceAfterOpeningParen;
boolean fSpaceBeforeClosingParen;
boolean fSpaceBetweenEmptyParen;
boolean fSpaceBeforeOpeningParen;
int fContinuationIndentation = -1;
int fTieBreakRule = Alignment.R_INNERMOST;
public ListOptions(int mode) {
fMode= mode;
ListOptions(int mode) {
this.fMode = mode;
}
}
@ -1339,7 +1340,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
private int visit(ICPPASTFunctionDeclarator node) {
final List<ICPPASTParameterDeclaration> parameters = Arrays.asList(node.getParameters());
final ListOptions options = createListOptionsForFunctionParameters();
final ListOptions options = createListOptionsForFunctionDeclarationParameters();
formatList(parameters, options, true, node.takesVarArgs(),
new CPPFunctionDeclaratorTailFormatter(node, scribe.getTailFormatter()));
@ -1416,13 +1417,14 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
private int visit(IASTStandardFunctionDeclarator node) {
final List<IASTParameterDeclaration> parameters = Arrays.asList(node.getParameters());
final ListOptions options = createListOptionsForFunctionParameters();
final ListOptions options = createListOptionsForFunctionDeclarationParameters();
formatList(parameters, options, true, node.takesVarArgs(), new TrailingSemicolonFormatter(node));
return PROCESS_SKIP;
}
private ListOptions createListOptionsForFunctionParameters() {
private ListOptions createListOptionsForFunctionDeclarationParameters() {
final ListOptions options= new ListOptions(preferences.alignment_for_parameters_in_method_declaration);
options.fUseFallbackMode= true;
options.fSpaceBeforeOpeningParen= preferences.insert_space_before_opening_paren_in_method_declaration;
options.fSpaceAfterOpeningParen= preferences.insert_space_after_opening_paren_in_method_declaration;
options.fSpaceBeforeClosingParen= preferences.insert_space_before_closing_paren_in_method_declaration;
@ -1484,12 +1486,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
private int visit(ICASTKnRFunctionDeclarator node) {
final List<IASTName> parameters= Arrays.asList(node.getParameterNames());
ListOptions options= new ListOptions(preferences.alignment_for_parameters_in_method_declaration);
options.fSpaceAfterOpeningParen= preferences.insert_space_after_opening_paren_in_method_declaration;
options.fSpaceBeforeClosingParen= preferences.insert_space_before_closing_paren_in_method_declaration;
options.fSpaceBetweenEmptyParen= preferences.insert_space_between_empty_parens_in_method_declaration;
options.fSpaceBeforeComma= preferences.insert_space_before_comma_in_method_declaration_parameters;
options.fSpaceAfterComma= preferences.insert_space_after_comma_in_method_declaration_parameters;
ListOptions options= createListOptionsForFunctionDeclarationParameters();
formatList(parameters, options, true, false, null);
IASTDeclaration[] parameterDecls= node.getParameterDeclarations();
@ -1567,12 +1564,22 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
scribe.space();
}
}
final ListOptions options= new ListOptions(preferences.alignment_for_declarator_list);
options.fSpaceAfterComma= preferences.insert_space_after_comma_in_declarator_list;
options.fSpaceBeforeComma= preferences.insert_space_before_comma_in_declarator_list;
Runnable tailFormatter = fExpectSemicolonAfterDeclaration ?
new TrailingSemicolonFormatter(node) : null;
formatList(declarators, options, false, false, tailFormatter);
if (declarators.size() == 1) {
scribe.setTailFormatter(tailFormatter);
try {
visit(declarators.get(0));
scribe.runTailFormatter();
} finally {
scribe.setTailFormatter(null);
}
} else {
final ListOptions options= new ListOptions(preferences.alignment_for_declarator_list);
options.fSpaceAfterComma= preferences.insert_space_after_comma_in_declarator_list;
options.fSpaceBeforeComma= preferences.insert_space_before_comma_in_declarator_list;
formatList(declarators, options, false, false, tailFormatter);
}
}
return PROCESS_SKIP;
}
@ -1963,66 +1970,106 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
if (options.fSpaceAfterOpeningParen) {
scribe.space();
}
final int continuationIndentation= options.fContinuationIndentation >= 0 ?
options.fContinuationIndentation : preferences.continuation_indentation;
Alignment alignment = scribe.createAlignment(
Alignment.LIST_ELEMENTS_PREFIX +
(elements.isEmpty() ? "ellipsis" : elements.get(0).getClass().getSimpleName()), //$NON-NLS-1$
options.fMode,
options.fTieBreakRule,
elementsLength + (addEllipsis ? 1 : 0),
scribe.scanner.getCurrentPosition(),
continuationIndentation,
false);
scribe.enterAlignment(alignment);
boolean ok = false;
Alignment retryAlignment = null;
int fallbackMode = options.fUseFallbackMode ?
getFallbackAlignmentMode(options.fMode) : options.fMode;
if (fallbackMode != options.fMode) {
retryAlignment = scribe.createAlignment(
Alignment.LIST_FALLBACK_TRAP,
Alignment.M_ONE_PER_LINE_SPLIT,
Alignment.R_INNERMOST,
1,
scribe.scanner.getCurrentPosition(),
0,
false);
scribe.enterAlignment(retryAlignment);
}
boolean success = false;
int mode = options.fMode;
do {
if (retryAlignment != null)
scribe.alignFragment(retryAlignment, 0);
try {
int i;
for (i = 0; i < elementsLength; i++) {
final IASTNode node= elements.get(i);
if (i < alignment.fragmentCount - 1) {
scribe.setTailFormatter(
new TrailingCommaFormatter(options.fSpaceBeforeComma,
options.fSpaceAfterComma));
} else {
scribe.setTailFormatter(tailFormatter);
}
scribe.alignFragment(alignment, i);
if (node instanceof ICPPASTConstructorChainInitializer) {
// Constructor chain initializer is a special case.
visit((ICPPASTConstructorChainInitializer) node);
} else {
node.accept(this);
}
if (i < alignment.fragmentCount - 1) {
final int continuationIndentation= options.fContinuationIndentation >= 0 ?
options.fContinuationIndentation : preferences.continuation_indentation;
Alignment alignment = scribe.createAlignment(
Alignment.LIST_ELEMENTS_PREFIX +
(elements.isEmpty() ? "ellipsis" : elements.get(0).getClass().getSimpleName()), //$NON-NLS-1$
mode,
options.fTieBreakRule,
elementsLength + (addEllipsis ? 1 : 0),
scribe.scanner.getCurrentPosition(),
continuationIndentation,
false);
scribe.enterAlignment(alignment);
boolean ok = false;
do {
try {
int i;
for (i = 0; i < elementsLength; i++) {
final IASTNode node= elements.get(i);
if (i < alignment.fragmentCount - 1) {
scribe.setTailFormatter(
new TrailingCommaFormatter(options.fSpaceBeforeComma,
options.fSpaceAfterComma));
} else {
scribe.setTailFormatter(tailFormatter);
}
scribe.alignFragment(alignment, i);
if (node instanceof ICPPASTConstructorChainInitializer) {
// Constructor chain initializer is a special case.
visit((ICPPASTConstructorChainInitializer) node);
} else {
node.accept(this);
}
if (i < alignment.fragmentCount - 1) {
scribe.runTailFormatter();
}
}
if (addEllipsis) {
if (i > 0) {
scribe.printNextToken(Token.tCOMMA, options.fSpaceBeforeComma);
scribe.printTrailingComment();
}
scribe.alignFragment(alignment, i);
if (i > 0 && options.fSpaceAfterComma) {
scribe.space();
}
scribe.printNextToken(Token.tELIPSE);
}
scribe.runTailFormatter();
ok = true;
} catch (AlignmentException e) {
scribe.redoAlignment(e);
} catch (ASTProblemException e) {
}
}
if (addEllipsis) {
if (i > 0) {
scribe.printNextToken(Token.tCOMMA, options.fSpaceBeforeComma);
scribe.printTrailingComment();
}
scribe.alignFragment(alignment, i);
if (i > 0 && options.fSpaceAfterComma) {
scribe.space();
}
scribe.printNextToken(Token.tELIPSE);
}
scribe.runTailFormatter();
ok = true;
} while (!ok);
scribe.exitAlignment(alignment, true);
success = true;
} catch (AlignmentException e) {
if (retryAlignment == null)
throw e;
scribe.redoAlignment(e);
} catch (ASTProblemException e) {
}
} while (!ok);
scribe.exitAlignment(alignment, true);
mode = fallbackMode;
} while (!success);
if (retryAlignment != null)
scribe.exitAlignment(retryAlignment, true);
} else if (tailFormatter != null) {
tailFormatter.run();
}
}
private int getFallbackAlignmentMode(int alignmentMode) {
switch (alignmentMode & Alignment.SPLIT_MASK) {
case Alignment.M_COMPACT_SPLIT:
alignmentMode = Alignment.M_COMPACT_FIRST_BREAK_SPLIT | (alignmentMode & ~Alignment.SPLIT_MASK);
}
return alignmentMode & ~Alignment.M_INDENT_ON_COLUMN;
}
private int visit(ICPPASTTryBlockStatement node) {
scribe.printNextToken(Token.t_try, scribe.printComment());
final IASTStatement tryBody= node.getTryBody();
@ -2176,6 +2223,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
expressions= Collections.emptyList();
}
final ListOptions options= new ListOptions(preferences.alignment_for_arguments_in_method_invocation);
options.fUseFallbackMode= true;
options.fSpaceBeforeOpeningParen= preferences.insert_space_before_opening_paren_in_method_invocation;
options.fSpaceAfterOpeningParen= preferences.insert_space_after_opening_paren_in_method_invocation;
options.fSpaceBeforeClosingParen= preferences.insert_space_before_closing_paren_in_method_invocation;
@ -2273,7 +2321,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
Alignment expressionAlignment= scribe.createAlignment(
Alignment.DECLARATION_INITIALIZER,
preferences.alignment_for_assignment,
Alignment.R_OUTERMOST,
Alignment.R_INNERMOST,
1,
scribe.scanner.getCurrentPosition());
@ -2851,6 +2899,15 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
final int line = scribe.line;
scribe.printNextToken(Token.tLPAREN, preferences.insert_space_before_opening_paren_in_for);
fInsideFor= true;
if (preferences.insert_space_after_opening_paren_in_for) {
scribe.space();
}
IASTStatement initializerStmt= node.getInitializerStatement();
initializerStmt.accept(this);
if (peekNextToken() == Token.tSEMI) {
scribe.printNextToken(Token.tSEMI, preferences.insert_space_before_semicolon_in_for);
}
Alignment alignment = scribe.createAlignment(
Alignment.FOR,
Alignment.M_COMPACT_SPLIT,
@ -2863,15 +2920,6 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
do {
try {
try {
if (preferences.insert_space_after_opening_paren_in_for) {
scribe.space();
}
IASTStatement initializerStmt= node.getInitializerStatement();
initializerStmt.accept(this);
if (peekNextToken() == Token.tSEMI) {
scribe.printNextToken(Token.tSEMI, preferences.insert_space_before_semicolon_in_for);
}
scribe.alignFragment(alignment, 0);
final IASTExpression condition = node.getConditionExpression();
if (condition != null) {

View file

@ -496,9 +496,9 @@ public class DefaultCodeFormatterOptions {
try {
this.alignment_for_assignment = Integer.parseInt((String) alignmentForAssignmentOption);
} catch (NumberFormatException e) {
this.alignment_for_assignment = Alignment.M_ONE_PER_LINE_SPLIT;
this.alignment_for_assignment = Alignment.M_COMPACT_SPLIT;
} catch (ClassCastException e) {
this.alignment_for_assignment = Alignment.M_ONE_PER_LINE_SPLIT;
this.alignment_for_assignment = Alignment.M_COMPACT_SPLIT;
}
}
final Object alignmentForBinaryExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION);
@ -1468,7 +1468,7 @@ public class DefaultCodeFormatterOptions {
public void setDefaultSettings() {
// this.alignment_for_arguments_in_allocation_expression = Alignment.M_COMPACT_SPLIT;
this.alignment_for_arguments_in_method_invocation = Alignment.M_COMPACT_SPLIT;
this.alignment_for_assignment = Alignment.M_NO_ALIGNMENT;
this.alignment_for_assignment = Alignment.M_COMPACT_SPLIT;
this.alignment_for_base_clause_in_type_declaration = Alignment.M_NEXT_PER_LINE_SPLIT;
this.alignment_for_binary_expression = Alignment.M_COMPACT_SPLIT;
this.alignment_for_compact_if = Alignment.M_COMPACT_SPLIT;

View file

@ -242,23 +242,27 @@ public class Scribe {
return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart);
}
public Alignment createAlignment(String name, int mode, int count, int sourceRestart, boolean adjust) {
public Alignment createAlignment(String name, int mode, int count, int sourceRestart,
boolean adjust) {
return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, adjust);
}
public Alignment createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart) {
public Alignment createAlignment(String name, int mode, int tieBreakRule, int count,
int sourceRestart) {
return createAlignment(name, mode, tieBreakRule, count, sourceRestart,
preferences.continuation_indentation, false);
}
public Alignment createAlignment(String name, int mode, int count, int sourceRestart, int continuationIndent,
boolean adjust) {
return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart, continuationIndent, adjust);
public Alignment createAlignment(String name, int mode, int count, int sourceRestart,
int continuationIndent, boolean adjust) {
return createAlignment(name, mode, Alignment.R_INNERMOST, count, sourceRestart,
continuationIndent, adjust);
}
public Alignment createAlignment(String name, int mode, int tieBreakRule, int count, int sourceRestart,
int continuationIndent, boolean adjust) {
Alignment alignment= new Alignment(name, mode, tieBreakRule, this, count, sourceRestart, continuationIndent);
public Alignment createAlignment(String name, int mode, int tieBreakRule, int count,
int sourceRestart, int continuationIndent, boolean adjust) {
Alignment alignment= new Alignment(name, mode, tieBreakRule, this, count, sourceRestart,
continuationIndent);
// adjust break indentation
if (adjust && memberAlignment != null) {
Alignment current= memberAlignment;
@ -273,7 +277,8 @@ public class Scribe {
if ((mode & Alignment.M_INDENT_BY_ONE) != 0) {
alignment.breakIndentationLevel= indentationLevel + indentSize;
} else {
alignment.breakIndentationLevel= indentationLevel + continuationIndent * indentSize;
alignment.breakIndentationLevel= indentationLevel +
continuationIndent * indentSize;
}
alignment.update();
break;
@ -281,8 +286,8 @@ public class Scribe {
if ((mode & Alignment.M_INDENT_BY_ONE) != 0) {
alignment.breakIndentationLevel= current.originalIndentationLevel + indentSize;
} else {
alignment.breakIndentationLevel= current.originalIndentationLevel + continuationIndent
* indentSize;
alignment.breakIndentationLevel= current.originalIndentationLevel +
continuationIndent * indentSize;
}
alignment.update();
break;
@ -301,16 +306,18 @@ public class Scribe {
if ((mode & Alignment.M_INDENT_BY_ONE) != 0) {
alignment.breakIndentationLevel= indentationLevel + indentSize;
} else {
alignment.breakIndentationLevel= indentationLevel + continuationIndent * indentSize;
alignment.breakIndentationLevel= indentationLevel +
continuationIndent * indentSize;
}
alignment.update();
break;
case Alignment.CHUNK_FIELD:
if ((mode & Alignment.M_INDENT_BY_ONE) != 0) {
alignment.breakIndentationLevel= current.originalIndentationLevel + indentSize;
alignment.breakIndentationLevel= current.originalIndentationLevel +
indentSize;
} else {
alignment.breakIndentationLevel= current.originalIndentationLevel + continuationIndent
* indentSize;
alignment.breakIndentationLevel= current.originalIndentationLevel +
continuationIndent * indentSize;
}
alignment.update();
break;
@ -573,8 +580,8 @@ public class Scribe {
}
public void handleLineTooLong() {
// search for closest breakable alignment, using tiebreak rules
// look for outermost breakable one
// Search for closest breakable alignment, using tie break rules
// look for outermost breakable one.
int relativeDepth= 0;
int outerMostDepth= -1;
Alignment targetAlignment= currentAlignment;
@ -588,7 +595,7 @@ public class Scribe {
if (outerMostDepth >= 0) {
throwAlignmentException(AlignmentException.LINE_TOO_LONG, outerMostDepth);
}
// look for innermost breakable one
// Look for innermost breakable one
relativeDepth= 0;
targetAlignment= currentAlignment;
while (targetAlignment != null) {
@ -598,7 +605,7 @@ public class Scribe {
targetAlignment= targetAlignment.enclosing;
relativeDepth++;
}
// did not find any breakable location - proceed
// Did not find any breakable location - proceed
}
private void throwAlignmentException(int kind, int relativeDepth) {
@ -771,7 +778,8 @@ public class Scribe {
switch (currentToken.type) {
case Token.tLBRACE: {
scanner.resetTo(scanner.getCurrentTokenStartPosition(), scannerEndPosition - 1);
formatOpeningBrace(preferences.brace_position_for_block, preferences.insert_space_before_opening_brace_in_block);
formatOpeningBrace(preferences.brace_position_for_block,
preferences.insert_space_before_opening_brace_in_block);
if (preferences.indent_statements_compare_to_block) {
indent();
}
@ -936,8 +944,9 @@ public class Scribe {
if (isNewLine) {
if (Character.isWhitespace((char) currentCharacter)) {
int previousStartPosition= scanner.getCurrentPosition();
while (currentCharacter != -1 && currentCharacter != '\r' && currentCharacter != '\n'
&& Character.isWhitespace((char) currentCharacter)) {
while (currentCharacter != -1 && currentCharacter != '\r' &&
currentCharacter != '\n' &&
Character.isWhitespace((char) currentCharacter)) {
previousStart= nextCharacterStart;
previousStartPosition= scanner.getCurrentPosition();
currentCharacter= scanner.getNextChar();
@ -984,7 +993,8 @@ public class Scribe {
pendingSpace= false;
int previousStart= currentTokenStartPosition;
while (nextCharacterStart <= currentTokenEndPosition && (currentCharacter= scanner.getNextChar()) != -1) {
while (nextCharacterStart <= currentTokenEndPosition &&
(currentCharacter= scanner.getNextChar()) != -1) {
nextCharacterStart= scanner.getCurrentPosition();
switch (currentCharacter) {
@ -1050,8 +1060,10 @@ public class Scribe {
if (skipOverInactive) {
Position inactivePos= getInactivePosAt(scanner.getCurrentTokenStartPosition());
if (inactivePos != null) {
int startOffset= Math.min(scanner.getCurrentTokenStartPosition(), inactivePos.getOffset());
int endOffset= Math.min(scannerEndPosition, inactivePos.getOffset() + inactivePos.getLength());
int startOffset= Math.min(scanner.getCurrentTokenStartPosition(),
inactivePos.getOffset());
int endOffset= Math.min(scannerEndPosition,
inactivePos.getOffset() + inactivePos.getLength());
if (startOffset < endOffset) {
int savedIndentLevel= indentationLevel;
scanner.resetTo(scanner.getCurrentTokenStartPosition(), scanner.eofPosition - 1);
@ -1098,7 +1110,8 @@ public class Scribe {
// to change the trailing flag.
if (trailing == BASIC_TRAILING_COMMENT && hasLineComment) {
int currentCommentIndentation = computeIndentation(whiteSpaces, 0);
int relativeIndentation = currentCommentIndentation - lastLineComment.currentIndentation;
int relativeIndentation =
currentCommentIndentation - lastLineComment.currentIndentation;
if (tabLength == 0) {
canChangeTrailing = relativeIndentation == 0;
} else {

View file

@ -32,7 +32,8 @@ public class Alignment {
public static final String FOR = "for"; //$NON-NLS-1$
public static final String MACRO_ARGUMENTS = "macroArguments"; //$NON-NLS-1$
public static final String LIST_ELEMENTS_PREFIX = "listElements_"; //$NON-NLS-1$
public static final String LIST_FALLBACK_TRAP = "listFallbackTrap"; //$NON-NLS-1$
/** The name of the alignment */
public String name;
@ -173,7 +174,7 @@ public class Alignment {
// indent broken fragments at next indentation level, based on current column
this.breakIndentationLevel = this.scribe.getNextIndentationLevel(currentColumn);
if (this.breakIndentationLevel == this.location.outputIndentationLevel) {
this.breakIndentationLevel += (continuationIndent * indentSize);
this.breakIndentationLevel += continuationIndent * indentSize;
}
} else if ((mode & M_INDENT_BY_ONE) != 0) {
// indent broken fragments exactly one level deeper than current indentation
@ -318,8 +319,7 @@ public class Alignment {
*/
case M_NEXT_PER_LINE_SPLIT:
if (this.fragmentBreaks[0] == NONE) {
if (this.fragmentCount > 1
&& this.fragmentBreaks[1] == NONE) {
if (this.fragmentCount > 1 && this.fragmentBreaks[1] == NONE) {
if ((this.mode & M_INDENT_ON_COLUMN) != 0) {
this.fragmentIndentations[0] = this.breakIndentationLevel;
}

View file

@ -65,8 +65,8 @@ template<class Bar> void Foo::fum(int i) {
}
// TEMPLATE_VARIABLES
template<bool threads, int inst> char
* default_alloc_template<threads, inst>::S_start_free = 0;
template<bool threads, int inst> char* default_alloc_template<threads, inst>::S_start_free =
0;
// an instantiation, not a template:
complex<float> cf(0, 0);

View file

@ -227,8 +227,8 @@ public class CodeFormatterTest extends BaseUITestCase {
//
//void test() {
// ClassWithALongName* variable_with_a_long_name;
// for (ClassWithALongName::Iterator
// iter_for_class_with_a_long_name = variable_with_a_long_name->getIterator();
// for (ClassWithALongName::Iterator iter_for_class_with_a_long_name =
// variable_with_a_long_name->getIterator();
// !iter_for_class_with_a_long_name.isDone();
// iter_for_class_with_a_long_name.next()) {
// }
@ -627,9 +627,8 @@ public class CodeFormatterTest extends BaseUITestCase {
//
//void test() {
// ClassWithALongName* variable_with_a_long_name;
// ClassWithALongName* another_variable =
// variable_with_a_long_name->methodWithALongName()
// ->anotherMethodWithALongName();
// ClassWithALongName* another_variable = variable_with_a_long_name
// ->methodWithALongName()->anotherMethodWithALongName();
//}
public void testMemberAccess() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
@ -969,8 +968,26 @@ public class CodeFormatterTest extends BaseUITestCase {
// int very_looong_parameter_name);
public void testFunctionDeclaration() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION,
Integer.toString(Alignment.M_NEXT_PER_LINE_SPLIT | Alignment.M_INDENT_ON_COLUMN));
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION,
Integer.toString(Alignment.M_COMPACT_SPLIT | Alignment.M_INDENT_ON_COLUMN));
assertFormatterResult();
}
//const char* function_name1(const char* parameter_name, const char* another_parameter_name,
//int very_loooooooooooooooooooooooong_parameter_name);
//const char* function_name2(const char* parameter_name, const char* another_parameter_name,
//int very_looooooooooooooooooooooooong_parameter_name);
//const char* function_name1(const char* parameter_name,
// const char* another_parameter_name,
// int very_loooooooooooooooooooooooong_parameter_name);
//const char* function_name2(
// const char* parameter_name, const char* another_parameter_name,
// int very_looooooooooooooooooooooooong_parameter_name);
public void testFunctionDeclarationFallbackFormat() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION,
Integer.toString(Alignment.M_COMPACT_SPLIT | Alignment.M_INDENT_ON_COLUMN));
assertFormatterResult();
}
@ -984,8 +1001,8 @@ public class CodeFormatterTest extends BaseUITestCase {
//}
public void testFunctionDefinition() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION,
Integer.toString(Alignment.M_NEXT_PER_LINE_SPLIT | Alignment.M_INDENT_ON_COLUMN));
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION,
Integer.toString(Alignment.M_COMPACT_SPLIT | Alignment.M_INDENT_ON_COLUMN));
assertFormatterResult();
}