本文整理汇总了Java中com.intellij.psi.codeStyle.CommonCodeStyleSettings.NEXT_LINE属性的典型用法代码示例。如果您正苦于以下问题:Java CommonCodeStyleSettings.NEXT_LINE属性的具体用法?Java CommonCodeStyleSettings.NEXT_LINE怎么用?Java CommonCodeStyleSettings.NEXT_LINE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.psi.codeStyle.CommonCodeStyleSettings
的用法示例。
在下文中一共展示了CommonCodeStyleSettings.NEXT_LINE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSCR1703
public void testSCR1703() throws Exception {
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTextTest("class Foo{\n" +
" void foo() {\n" +
" for (Object o : localizations) {\n" +
" //do something \n" +
" }\n" +
" }\n" +
"}", "class Foo {\n" +
" void foo() {\n" +
" for (Object o : localizations)\n" +
" {\n" +
" //do something \n" +
" }\n" +
" }\n" +
"}");
}
示例2: testIfStatementElseBranchIsOnNewLine
public void testIfStatementElseBranchIsOnNewLine() throws Exception {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
String before = "if (2 > 3) {\n" +
" System.out.println(\"AA!\");\n" +
"} else {\n" +
" int a = 3;\n" +
"}";
String after = "if (2 > 3)\n" +
"{\n" +
" System.out.println(\"AA!\");\n" +
"} else\n" +
"{\n" +
" int a = 3;\n" +
"}";
doMethodTest(before, after);
}
示例3: testLongCallChainAfterElse
public void testLongCallChainAfterElse() throws Exception {
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
getSettings().KEEP_CONTROL_STATEMENT_IN_ONE_LINE = true;
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
getSettings().ELSE_ON_NEW_LINE = false;
getSettings().RIGHT_MARGIN = 110;
getSettings().KEEP_LINE_BREAKS = false;
doTextTest("class Foo {\n" +
" void foo() {\n" +
" if (types.length > 1) // returns multiple columns\n" +
" {\n" +
" } else\n" +
" result.add(initializeObject(os, types[0], initializeCollections, initializeAssociations, initializeChildren));" +
" }\n" +
"}", "class Foo {\n" +
" void foo() {\n" +
" if (types.length > 1) // returns multiple columns\n" +
" {\n" +
" } else\n" +
" result.add(initializeObject(os, types[0], initializeCollections, initializeAssociations, initializeChildren));\n" +
" }\n" +
"}");
}
示例4: testMoveBraceOnNextLineForAnnotatedMethod
public void testMoveBraceOnNextLineForAnnotatedMethod() throws Exception {
// Inspired by IDEA-59336
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
doClassTest(
"@Override\n" +
"public int hashCode() {\n" +
"}\n" +
"@Deprecated\n" +
"void foo() {\n" +
"}",
"@Override\n" +
"public int hashCode()\n" +
"{\n" +
"}\n" +
"\n" +
"@Deprecated\n" +
"void foo()\n" +
"{\n" +
"}"
);
}
示例5: testSCR1535
public void testSCR1535() throws Exception {
final CommonCodeStyleSettings settings = getSettings();
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTextTest("public class Foo {\n" +
" public int foo() {\n" +
" if (a) {\n" +
" return;\n" +
" }\n" +
" }\n" +
"}", "public class Foo\n" +
"{\n" +
" public int foo()\n" +
" {\n" +
" if (a)\n" +
" {\n" +
" return;\n" +
" }\n" +
" }\n" +
"}");
}
示例6: testKeepSimpleBlocksInOneLine_OnIfStatementsThenBlock
public void testKeepSimpleBlocksInOneLine_OnIfStatementsThenBlock() throws Exception {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
String singleLine = "if (2 > 3) { System.out.println(\"AA!\"); }";
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doMethodTest(singleLine, singleLine);
getSettings().BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doMethodTest(singleLine, singleLine);
}
示例7: valueToInt
private static int valueToInt(@NotNull String value) {
if (VALUE_END_OF_LINE.equals(value)) return CommonCodeStyleSettings.END_OF_LINE;
if (VALUE_NEXT_LINE.equals(value)) return CommonCodeStyleSettings.NEXT_LINE;
if (VALUE_NEXT_LINE_SHIFTED.equals(value)) return CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
if (VALUE_NEXT_LINE_IF_WRAPPED.equals(value)) return CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
return Integer.parseInt(value);
}
示例8: testAlreadyCompleteCatch
public void testAlreadyCompleteCatch() throws Exception {
CommonCodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
int old = settings.BRACE_STYLE;
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
try {
doTest();
}
finally {
settings.BRACE_STYLE = old;
}
}
示例9: doTestBracesNextLineStyle
private void doTestBracesNextLineStyle() throws Exception {
CommonCodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
try {
doTest();
}
finally {
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
}
}
示例10: testReformatInsertsNewlines
public void testReformatInsertsNewlines() throws Exception {
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
final Element root = new Element("fake");
settings.writeExternal(root);
try {
settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true;
settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true;
settings.IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTest();
} finally {
settings.readExternal(root);
}
}
示例11: testSpacesBeforeResourceList
public void testSpacesBeforeResourceList() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
getSettings().SPACE_BEFORE_TRY_PARENTHESES = true;
getSettings().SPACE_BEFORE_TRY_LBRACE = true;
doMethodTest("try(AutoCloseable r = null){ }",
"try (AutoCloseable r = null) { }");
getSettings().SPACE_BEFORE_TRY_PARENTHESES = false;
getSettings().SPACE_BEFORE_TRY_LBRACE = false;
doMethodTest("try (AutoCloseable r = null) { }",
"try(AutoCloseable r = null){ }");
}
示例12: testIf
public void testIf() throws Exception {
final CommonCodeStyleSettings settings = getSettings();
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTest();
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doTest("If.java", "If.java");
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
settings.KEEP_LINE_BREAKS = false;
doTest("If_after.java", "If.java");
}
示例13: testStaticBlockBraces
public void testStaticBlockBraces() throws Exception {
getSettings().BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doTextTest("class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}",
"class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
doTextTest("class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}",
"class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTextTest("class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}",
"class Foo {\n" + " static\n" + " {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
doTextTest("class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}",
"class Foo {\n" + " static\n" + " {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED2;
doTextTest("class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}", "class Foo {\n" +
" static\n" +
" {\n" +
" //comment\n" +
" i = foo();\n" +
" }\n" +
"}");
}
示例14: testSCR11799
public void testSCR11799() throws Exception {
final CommonCodeStyleSettings settings = getSettings();
settings.getRootSettings().getIndentOptions(StdFileTypes.JAVA).CONTINUATION_INDENT_SIZE = 4;
settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTest();
}
示例15: testIfStatement_WhenBraceOnNextLine_AndKeepSimpleBlockInOneLineEnabled
public void testIfStatement_WhenBraceOnNextLine_AndKeepSimpleBlockInOneLineEnabled() throws Exception {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
String before = "if (2 > 3) {\n" +
" System.out.println(\"AA!\");\n" +
"}";
String after = "if (2 > 3)\n" +
"{\n" +
" System.out.println(\"AA!\");\n" +
"}";
doMethodTest(before, after);
}