summaryrefslogtreecommitdiff
path: root/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java')
-rw-r--r--java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java69
1 files changed, 35 insertions, 34 deletions
diff --git a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java
index c00db0fc77ad..0831f555fa29 100644
--- a/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java
+++ b/java/java-tests/testSrc/com/intellij/psi/formatter/java/JavaFormatterTest.java
@@ -15,6 +15,7 @@
*/
package com.intellij.psi.formatter.java;
+import com.intellij.lang.java.JavaLanguage;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.fileTypes.StdFileTypes;
@@ -664,7 +665,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
public void testParametersAlignment() throws Exception {
final CommonCodeStyleSettings settings = getSettings();
settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
- settings.getRootSettings().RIGHT_MARGIN = 140;
+ settings.RIGHT_MARGIN = 140;
doTest();
}
@@ -903,7 +904,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
public void testBraceOnNewLineIfWrapped() throws Exception {
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
- getSettings().getRootSettings().RIGHT_MARGIN = 35;
+ getSettings().RIGHT_MARGIN = 35;
getSettings().ALIGN_MULTILINE_BINARY_OPERATION = true;
doTextTest("class Foo {\n" +
@@ -928,7 +929,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
}
public void testFirstArgumentWrapping() throws Exception {
- getSettings().getRootSettings().RIGHT_MARGIN = 20;
+ getSettings().RIGHT_MARGIN = 20;
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
doTextTest("class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(1);" + " }\n" + "}",
"class Foo {\n" + " void foo() {\n" + " fooFooFooFoo(\n" + " 1);\n" + " }\n" + "}");
@@ -956,7 +957,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
public void testAssertStatementWrapping() throws Exception {
getSettings().ASSERT_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
- getSettings().getRootSettings().RIGHT_MARGIN = 40;
+ getSettings().RIGHT_MARGIN = 40;
final JavaPsiFacade facade = getJavaFacade();
final LanguageLevel effectiveLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
try {
@@ -1001,7 +1002,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
public void testAssertStatementWrapping2() throws Exception {
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
getSettings().ASSERT_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
- getSettings().getRootSettings().RIGHT_MARGIN = 37;
+ getSettings().RIGHT_MARGIN = 37;
final CommonCodeStyleSettings.IndentOptions options = getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA);
options.INDENT_SIZE = 2;
@@ -1044,7 +1045,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
public void test() throws Exception {
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 2;
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 2;
- getSettings().getRootSettings().RIGHT_MARGIN = 37;
+ getSettings().RIGHT_MARGIN = 37;
getSettings().ALIGN_MULTILINE_EXTENDS_LIST = true;
getSettings().EXTENDS_KEYWORD_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
@@ -1081,7 +1082,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
public void testLBrace() throws Exception {
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
- getSettings().getRootSettings().RIGHT_MARGIN = 14;
+ getSettings().RIGHT_MARGIN = 14;
doTextTest("class Foo {\n" + " void foo() {\n" + " \n" + " }\n" + "}",
"class Foo {\n" + " void foo() {\n" + "\n" + " }\n" + "}");
}
@@ -1194,7 +1195,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
public void testArrayInitializerWrapping() throws Exception {
getSettings().ARRAY_INITIALIZER_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION = false;
- getSettings().getRootSettings().RIGHT_MARGIN = 37;
+ getSettings().RIGHT_MARGIN = 37;
doTextTest("class Foo{\n" +
" public int[] i = new int[]{1,2,3,4,5,6,7,8,9};\n" +
@@ -1537,7 +1538,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
getSettings().KEEP_CONTROL_STATEMENT_IN_ONE_LINE = true;
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
getSettings().ELSE_ON_NEW_LINE = false;
- getSettings().getRootSettings().RIGHT_MARGIN = 110;
+ getSettings().RIGHT_MARGIN = 110;
getSettings().KEEP_LINE_BREAKS = false;
doTextTest("class Foo {\n" +
" void foo() {\n" +
@@ -1698,7 +1699,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
public void testDoNotWrapLBrace() throws IncorrectOperationException {
getSettings().BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
- getSettings().getRootSettings().RIGHT_MARGIN = 66;
+ getSettings().RIGHT_MARGIN = 66;
doTextTest("public class Test {\n" +
" void foo(){\n" +
" if (veryLongIdentifier1 == 1 && veryLongIdentifier2 == 2) {\n" +
@@ -1718,7 +1719,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
getSettings().ARRAY_INITIALIZER_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE = true;
getSettings().ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE = true;
- getSettings().getRootSettings().RIGHT_MARGIN = 40;
+ getSettings().RIGHT_MARGIN = 40;
doTextTest("class Foo {\n" + " int[] a = new int[]{1,2,0x0052,0x0053,0x0054,0x0054,0x0054};\n" + "}", "class Foo {\n" +
" int[] a = new int[]{\n" +
" 1, 2, 0x0052, 0x0053,\n" +
@@ -1768,7 +1769,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
}
public void testWrapExtendsList() throws Exception {
- getSettings().getRootSettings().RIGHT_MARGIN = 50;
+ getSettings().RIGHT_MARGIN = 50;
getSettings().EXTENDS_LIST_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
getSettings().EXTENDS_KEYWORD_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
@@ -1779,7 +1780,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
}
public void testWrapLongExpression() throws Exception {
- getSettings().getRootSettings().RIGHT_MARGIN = 80;
+ getSettings().RIGHT_MARGIN = 80;
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().ALIGN_MULTILINE_BINARY_OPERATION = true;
doTextTest("class Foo {\n" +
@@ -1797,7 +1798,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
}
public void testDoNotWrapCallChainIfParametersWrapped() throws Exception {
- getSettings().getRootSettings().RIGHT_MARGIN = 87;
+ getSettings().RIGHT_MARGIN = 87;
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
@@ -1831,7 +1832,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
}
public void testRightMargin_2() throws Exception {
- getSettings().getRootSettings().RIGHT_MARGIN = 65;
+ getSettings().RIGHT_MARGIN = 65;
getSettings().ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE = true;
getSettings().KEEP_LINE_BREAKS = false;
@@ -1844,7 +1845,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
}
public void testRightMargin_3() throws Exception {
- getSettings().getRootSettings().RIGHT_MARGIN = 65;
+ getSettings().RIGHT_MARGIN = 65;
getSettings().ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE = false;
getSettings().KEEP_LINE_BREAKS = false;
@@ -1902,12 +1903,12 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
public void testWrapParamsOnEveryItem() throws Exception {
CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject());
- int oldMargin = codeStyleSettings.RIGHT_MARGIN;
+ int oldMargin = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE).RIGHT_MARGIN;
boolean oldKeep = codeStyleSettings.KEEP_LINE_BREAKS;
int oldWrap = codeStyleSettings.METHOD_PARAMETERS_WRAP;
try {
- codeStyleSettings.RIGHT_MARGIN = 80;
+ codeStyleSettings.setRightMargin(JavaLanguage.INSTANCE, 80);
codeStyleSettings.KEEP_LINE_BREAKS = false;
codeStyleSettings.METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
@@ -1932,7 +1933,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
"}");
}
finally {
- codeStyleSettings.RIGHT_MARGIN = oldMargin;
+ codeStyleSettings.setRightMargin(JavaLanguage.INSTANCE, oldMargin);
codeStyleSettings.KEEP_LINE_BREAKS = oldKeep;
codeStyleSettings.METHOD_PARAMETERS_WRAP = oldWrap;
}
@@ -1942,10 +1943,10 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
public void testCommentAfterDeclaration() throws Exception {
CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject());
- int oldMargin = codeStyleSettings.RIGHT_MARGIN;
+ int oldMargin = codeStyleSettings.getDefaultRightMargin();
try {
- codeStyleSettings.RIGHT_MARGIN = 20;
+ codeStyleSettings.setDefaultRightMargin(20);
codeStyleSettings.ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
doMethodTest(
"int i=0; //comment comment",
@@ -1955,7 +1956,7 @@ public class JavaFormatterTest extends AbstractJavaFormatterTest {
}
finally {
- codeStyleSettings.RIGHT_MARGIN = oldMargin;
+ codeStyleSettings.setDefaultRightMargin(oldMargin);
}
}
@@ -2106,7 +2107,7 @@ public void testSCR260() throws Exception {
public void testSCR479() throws Exception {
final CommonCodeStyleSettings settings = getSettings();
- settings.getRootSettings().RIGHT_MARGIN = 80;
+ settings.RIGHT_MARGIN = 80;
settings.TERNARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
doTextTest("public class Foo {\n" +
" public static void main(String[] args) {\n" +
@@ -2190,7 +2191,7 @@ public void testSCR260() throws Exception {
}
public void test1607() throws Exception {
- getSettings().getRootSettings().RIGHT_MARGIN = 30;
+ getSettings().RIGHT_MARGIN = 30;
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
getSettings().ALIGN_MULTILINE_PARAMETERS = true;
@@ -2271,7 +2272,7 @@ public void testSCR260() throws Exception {
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
- getSettings().getRootSettings().RIGHT_MARGIN = 80;
+ getSettings().RIGHT_MARGIN = 80;
getSettings().PREFER_PARAMETERS_WRAP = true;
@@ -2392,7 +2393,7 @@ public void testSCR260() throws Exception {
}
public void test1980() throws Exception {
- getSettings().getRootSettings().RIGHT_MARGIN = 144;
+ getSettings().RIGHT_MARGIN = 144;
getSettings().TERNARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().ALIGN_MULTILINE_TERNARY_OPERATION = true;
@@ -2523,7 +2524,7 @@ public void testSCR260() throws Exception {
public void testSCRIDEA_4783() throws IncorrectOperationException {
getSettings().ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
- getSettings().getRootSettings().RIGHT_MARGIN = 80;
+ getSettings().RIGHT_MARGIN = 80;
doTextTest("class Foo{\n" +
" void foo() {\n" +
@@ -2655,7 +2656,7 @@ public void testSCR260() throws Exception {
doTextTest("class Foo {\n" + " void foo() {\n" + " while(true) foo();\n" + " }\n" + "}",
"class Foo {\n" + " void foo() {\n" + " while (true) foo();\n" + " }\n" + "}");
- getSettings().getRootSettings().RIGHT_MARGIN = 17;
+ getSettings().RIGHT_MARGIN = 17;
doTextTest("class Foo {\n" + " void foo() {\n" + " if (a) foo();\n" + " else bar();\n" + " }\n" + "}",
"class Foo {\n" +
@@ -2667,7 +2668,7 @@ public void testSCR260() throws Exception {
" }\n" +
"}");
- getSettings().getRootSettings().RIGHT_MARGIN = 30;
+ getSettings().RIGHT_MARGIN = 30;
doTextTest("class Foo {\n" + " void foo() {\n" + " for (int i = 0; i < 10; i++) foo();\n" + " }\n" + "}",
"class Foo {\n" +
@@ -2677,12 +2678,12 @@ public void testSCR260() throws Exception {
" }\n" +
"}");
- getSettings().getRootSettings().RIGHT_MARGIN = 32;
+ getSettings().RIGHT_MARGIN = 32;
doTextTest("class Foo {\n" + " void foo() {\n" + " for (int var : vars) foo();\n" + " }\n" + "}",
"class Foo {\n" + " void foo() {\n" + " for (int var : vars)\n" + " foo();\n" + " }\n" + "}");
- getSettings().getRootSettings().RIGHT_MARGIN = 12;
+ getSettings().RIGHT_MARGIN = 12;
doTextTest("class Foo {\n" + " void foo() {\n" + " do foo(); while (true);\n" + " }\n" + "}", "class Foo {\n" +
" void foo() {\n" +
" do\n" +
@@ -2691,7 +2692,7 @@ public void testSCR260() throws Exception {
" }\n" +
"}");
- getSettings().getRootSettings().RIGHT_MARGIN = 23;
+ getSettings().RIGHT_MARGIN = 23;
doTextTest("class Foo {\n" + " void foo() {\n" + " while(true) foo();\n" + " }\n" + "}",
"class Foo {\n" + " void foo() {\n" + " while (true)\n" + " foo();\n" + " }\n" + "}");
@@ -2807,7 +2808,7 @@ public void testSCR260() throws Exception {
public void testIDEADEV_12836() throws IncorrectOperationException {
getSettings().SPECIAL_ELSE_IF_TREATMENT = true;
- getSettings().getRootSettings().RIGHT_MARGIN = 80;
+ getSettings().RIGHT_MARGIN = 80;
doTextTest("class Foo {\n" +
"void foo(){\n" +
"if (true){\n" +
@@ -2886,7 +2887,7 @@ public void testSCR260() throws Exception {
public void testIDEADEV_23551() throws IncorrectOperationException {
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
- getSettings().getRootSettings().RIGHT_MARGIN = 60;
+ getSettings().RIGHT_MARGIN = 60;
doTextTest("public class Wrapping {\n" +
"public static void sample() {\n" +
"System.out.println(\".\" + File.separator + \"..\" + File.separator + \"some-directory-name\" + File.separator + \"more-file-name\");\n" +