mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Wrapped long lines.
This commit is contained in:
parent
101bcadce5
commit
3452064a2f
1 changed files with 58 additions and 29 deletions
|
@ -67,7 +67,8 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
|
|
||||||
private void assertFormatterResult(String original, String expected) throws BadLocationException {
|
private void assertFormatterResult(String original, String expected) throws BadLocationException {
|
||||||
IDocument document= new Document(original);
|
IDocument document= new Document(original);
|
||||||
TextEdit edit= CodeFormatterUtil.format(CodeFormatter.K_TRANSLATION_UNIT, original, 0, TextUtilities.getDefaultLineDelimiter(document), fOptions);
|
TextEdit edit= CodeFormatterUtil.format(CodeFormatter.K_TRANSLATION_UNIT, original, 0,
|
||||||
|
TextUtilities.getDefaultLineDelimiter(document), fOptions);
|
||||||
assertNotNull(edit);
|
assertNotNull(edit);
|
||||||
edit.apply(document);
|
edit.apply(document);
|
||||||
assertEquals(expected, document.get());
|
assertEquals(expected, document.get());
|
||||||
|
@ -80,7 +81,8 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
//void foo (int arg) {
|
//void foo (int arg) {
|
||||||
//}
|
//}
|
||||||
public void testInsertSpaceBeforeOpeningParen_Bug190184() throws Exception {
|
public void testInsertSpaceBeforeOpeningParen_Bug190184() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, CCorePlugin.INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION,
|
||||||
|
CCorePlugin.INSERT);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +286,8 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
//int verylooooooooooooooooooooooooooooooooooongname =
|
//int verylooooooooooooooooooooooooooooooooooongname =
|
||||||
// 0000000000000000000000000000000;
|
// 0000000000000000000000000000000;
|
||||||
public void testLineWrappingOfInitializerExpression_Bug200961() throws Exception {
|
public void testLineWrappingOfInitializerExpression_Bug200961() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, Integer.toString(Alignment.M_COMPACT_SPLIT));
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT,
|
||||||
|
Integer.toString(Alignment.M_COMPACT_SPLIT));
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,8 +311,10 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
// };
|
// };
|
||||||
public void testWhiteSmithsAccessSpecifierIndentation1_Bug204575() throws Exception {
|
public void testWhiteSmithsAccessSpecifierIndentation1_Bug204575() throws Exception {
|
||||||
fOptions.putAll(DefaultCodeFormatterOptions.getWhitesmithsSettings().getMap());
|
fOptions.putAll(DefaultCodeFormatterOptions.getWhitesmithsSettings().getMap());
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER, DefaultCodeFormatterConstants.FALSE);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER,
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER, DefaultCodeFormatterConstants.TRUE);
|
DefaultCodeFormatterConstants.FALSE);
|
||||||
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER,
|
||||||
|
DefaultCodeFormatterConstants.TRUE);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,8 +330,10 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
// };
|
// };
|
||||||
public void testWhiteSmithsAccessSpecifierIndentation2_Bug204575() throws Exception {
|
public void testWhiteSmithsAccessSpecifierIndentation2_Bug204575() throws Exception {
|
||||||
fOptions.putAll(DefaultCodeFormatterOptions.getWhitesmithsSettings().getMap());
|
fOptions.putAll(DefaultCodeFormatterOptions.getWhitesmithsSettings().getMap());
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER, DefaultCodeFormatterConstants.TRUE);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER,
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER, DefaultCodeFormatterConstants.FALSE);
|
DefaultCodeFormatterConstants.TRUE);
|
||||||
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER,
|
||||||
|
DefaultCodeFormatterConstants.FALSE);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,8 +349,10 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
// };
|
// };
|
||||||
public void testWhiteSmithsAccessSpecifierIndentation3_Bug204575() throws Exception {
|
public void testWhiteSmithsAccessSpecifierIndentation3_Bug204575() throws Exception {
|
||||||
fOptions.putAll(DefaultCodeFormatterOptions.getWhitesmithsSettings().getMap());
|
fOptions.putAll(DefaultCodeFormatterOptions.getWhitesmithsSettings().getMap());
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER, DefaultCodeFormatterConstants.TRUE);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER,
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER, DefaultCodeFormatterConstants.TRUE);
|
DefaultCodeFormatterConstants.TRUE);
|
||||||
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER,
|
||||||
|
DefaultCodeFormatterConstants.TRUE);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,14 +562,22 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
// Bar(); // should not have space between parens
|
// Bar(); // should not have space between parens
|
||||||
// }
|
// }
|
||||||
public void testSpaceBetweenParen_Bug217918() throws Exception {
|
public void testSpaceBetweenParen_Bug217918() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION,
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, DefaultCodeFormatterConstants.FALSE);
|
DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED);
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, CCorePlugin.INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY,
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, CCorePlugin.INSERT);
|
DefaultCodeFormatterConstants.FALSE);
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, CCorePlugin.DO_NOT_INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION,
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, CCorePlugin.INSERT);
|
CCorePlugin.INSERT);
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, CCorePlugin.INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION,
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, CCorePlugin.DO_NOT_INSERT);
|
CCorePlugin.INSERT);
|
||||||
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION,
|
||||||
|
CCorePlugin.DO_NOT_INSERT);
|
||||||
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION,
|
||||||
|
CCorePlugin.INSERT);
|
||||||
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION,
|
||||||
|
CCorePlugin.INSERT);
|
||||||
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION,
|
||||||
|
CCorePlugin.DO_NOT_INSERT);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -837,7 +854,8 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
|
|
||||||
//int a = 0,b = 1,c = 2,d = 3;
|
//int a = 0,b = 1,c = 2,d = 3;
|
||||||
public void testSpaceAfterCommaInDeclaratorList_Bug234915() throws Exception {
|
public void testSpaceAfterCommaInDeclaratorList_Bug234915() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST, CCorePlugin.DO_NOT_INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST,
|
||||||
|
CCorePlugin.DO_NOT_INSERT);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -845,7 +863,8 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
|
|
||||||
//int a = 0, b = 1, c = 2, d = 3;
|
//int a = 0, b = 1, c = 2, d = 3;
|
||||||
public void testSpaceAfterCommaInDeclaratorList2_Bug234915() throws Exception {
|
public void testSpaceAfterCommaInDeclaratorList2_Bug234915() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST, CCorePlugin.INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST,
|
||||||
|
CCorePlugin.INSERT);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -924,8 +943,10 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
// return x or x and not (not x);
|
// return x or x and not (not x);
|
||||||
//}
|
//}
|
||||||
public void testSpaceBeforeAndAfterAlternativeLogicalOperator_Bug239461() throws Exception {
|
public void testSpaceBeforeAndAfterAlternativeLogicalOperator_Bug239461() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, CCorePlugin.DO_NOT_INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR,
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, CCorePlugin.DO_NOT_INSERT);
|
CCorePlugin.DO_NOT_INSERT);
|
||||||
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR,
|
||||||
|
CCorePlugin.DO_NOT_INSERT);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1180,7 +1201,8 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
//int x = static_cast<int> (0);
|
//int x = static_cast<int> (0);
|
||||||
public void testCppCast_2() throws Exception {
|
public void testCppCast_2() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, CCorePlugin.INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION,
|
||||||
|
CCorePlugin.INSERT);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1217,7 +1239,8 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
//}
|
//}
|
||||||
public void testTemplateFunctionCall_2() throws Exception {
|
public void testTemplateFunctionCall_2() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, CCorePlugin.INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION,
|
||||||
|
CCorePlugin.INSERT);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1321,7 +1344,8 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
public void testSpaceBeforeSemicolonInFor_Bug242232() throws Exception {
|
public void testSpaceBeforeSemicolonInFor_Bug242232() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, CCorePlugin.INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR,
|
||||||
|
CCorePlugin.INSERT);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1607,9 +1631,12 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
|
|
||||||
//void foo() throw ( E1, E2 );
|
//void foo() throw ( E1, E2 );
|
||||||
public void testWhitespaceOptionsForExceptionSpecification_Bug243567() throws Exception {
|
public void testWhitespaceOptionsForExceptionSpecification_Bug243567() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION, CCorePlugin.INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION,
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION, CCorePlugin.INSERT);
|
CCorePlugin.INSERT);
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_EXCEPTION_SPECIFICATION, CCorePlugin.INSERT);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION,
|
||||||
|
CCorePlugin.INSERT);
|
||||||
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_EXCEPTION_SPECIFICATION,
|
||||||
|
CCorePlugin.INSERT);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1985,7 +2012,8 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
// { 1, 2, 3, 4 }
|
// { 1, 2, 3, 4 }
|
||||||
//};
|
//};
|
||||||
public void testKeepWrappedLines_Bug322776() throws Exception {
|
public void testKeepWrappedLines_Bug322776() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, DefaultCodeFormatterConstants.FALSE);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES,
|
||||||
|
DefaultCodeFormatterConstants.FALSE);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2007,7 +2035,8 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
// z();
|
// z();
|
||||||
//}
|
//}
|
||||||
public void testKeepWrappedLines_Bug322776_2() throws Exception {
|
public void testKeepWrappedLines_Bug322776_2() throws Exception {
|
||||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, DefaultCodeFormatterConstants.FALSE);
|
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES,
|
||||||
|
DefaultCodeFormatterConstants.FALSE);
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue