本文整理汇总了Java中com.intellij.psi.codeStyle.CommonCodeStyleSettings.NEXT_LINE_SHIFTED2属性的典型用法代码示例。如果您正苦于以下问题:Java CommonCodeStyleSettings.NEXT_LINE_SHIFTED2属性的具体用法?Java CommonCodeStyleSettings.NEXT_LINE_SHIFTED2怎么用?Java CommonCodeStyleSettings.NEXT_LINE_SHIFTED2使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.psi.codeStyle.CommonCodeStyleSettings
的用法示例。
在下文中一共展示了CommonCodeStyleSettings.NEXT_LINE_SHIFTED2属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIndentForCodeBlock
private Indent getIndentForCodeBlock(ASTNode child, int childrenIndent) {
if (child.getElementType() == JavaElementType.CODE_BLOCK
&& (getBraceStyle() == CommonCodeStyleSettings.NEXT_LINE_SHIFTED
|| getBraceStyle() == CommonCodeStyleSettings.NEXT_LINE_SHIFTED2))
{
return Indent.getNormalIndent();
}
return isRBrace(child) ? Indent.getNoneIndent() : getCodeBlockInternalIndent(childrenIndent, false);
}
示例2: testShiftedChainedIfElse
public void testShiftedChainedIfElse() throws Exception {
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED2;
getSettings().ELSE_ON_NEW_LINE = true;
getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA).INDENT_SIZE = 4;
doMethodTest(
"long a = System.currentTimeMillis();\n" +
" if (a == 0){\n" +
" }else if (a > 1){\n" +
" }else if (a > 2){\n" +
" }else if (a > 3){\n" +
" }else if (a > 4){\n" +
" }else if (a > 5){\n" +
" }else{\n" +
" }",
"long a = System.currentTimeMillis();\n" +
"if (a == 0)\n" +
" {\n" +
" }\n" +
"else if (a > 1)\n" +
" {\n" +
" }\n" +
"else if (a > 2)\n" +
" {\n" +
" }\n" +
"else if (a > 3)\n" +
" {\n" +
" }\n" +
"else if (a > 4)\n" +
" {\n" +
" }\n" +
"else if (a > 5)\n" +
" {\n" +
" }\n" +
"else\n" +
" {\n" +
" }"
);
}
示例3: 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" +
"}");
}
示例4: testSCR524
public void testSCR524() throws Exception {
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false;
doTextTest("class Foo {\n" + " void foo() { return;}" + "}", "class Foo {\n" + " void foo() { return;}\n" + "}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED2;
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = false;
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doTextTest("class Foo{\n" +
"void foo() {\n" +
"if(a) {return;}\n" +
"for(a = 0; a < 10; a++) {return;}\n" +
"switch(a) {case 1: return;}\n" +
"do{return;} while (a);\n" +
"while(a){return;}\n" +
"try{return;} catch(Ex e){return;} finally{return;}\n" +
"}\n" +
"}", "class Foo {\n" +
" void foo() {\n" +
" if (a) {return;}\n" +
" for (a = 0; a < 10; a++) {return;}\n" +
" switch (a)\n" +
" {\n" +
" case 1:\n" +
" return;\n" +
" }\n" +
" do {return;} while (a);\n" +
" while (a) {return;}\n" +
" try {return;} catch (Ex e) {return;} finally {return;}\n" +
" }\n" +
"}");
}
示例5: testBraces
public void testBraces() throws Exception {
final CommonCodeStyleSettings settings = getSettings();
@NonNls final String text =
"class Foo {\n" +
"void foo () {\n" +
"if (a) {\n" +
"int i = 0;\n" +
"}\n" +
"}\n" +
"}";
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doTextTest(text, "class Foo {\n" +
" void foo() {\n" +
" if (a) {\n" +
" int i = 0;\n" +
" }\n" +
" }\n" +
"}");
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTextTest(text, "class Foo {\n" +
" void foo()\n" +
" {\n" +
" if (a)\n" +
" {\n" +
" int i = 0;\n" +
" }\n" +
" }\n" +
"}");
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
doTextTest(text, "class Foo {\n" +
" void foo()\n" +
" {\n" +
" if (a)\n" +
" {\n" +
" int i = 0;\n" +
" }\n" +
" }\n" +
"}");
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doTextTest(text, "class Foo {\n" +
" void foo()\n" +
" {\n" +
" if (a) {\n" +
" int i = 0;\n" +
" }\n" +
" }\n" +
"}");
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED2;
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED2;
doTextTest(text, "class Foo {\n" +
" void foo()\n" +
" {\n" +
" if (a)\n" +
" {\n" +
" int i = 0;\n" +
" }\n" +
" }\n" +
"}");
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTextTest("class Foo {\n" + " static{\n" + "foo();\n" + "}" + "}",
"class Foo {\n" + " static\n" + " {\n" + " foo();\n" + " }\n" + "}");
}
示例6: testSynchronized
public void testSynchronized() throws Exception {
getSettings().BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doTextTest("class Foo {\n" + " void foo() {\n" + "synchronized (this) {foo();\n" + "}\n" + " }\n" + "}", "class Foo {\n" +
" void foo() {\n" +
" synchronized (this) {\n" +
" foo();\n" +
" }\n" +
" }\n" +
"}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTextTest("class Foo {\n" + " void foo() {\n" + "synchronized (this) {foo();\n" + "}\n" + " }\n" + "}", "class Foo {\n" +
" void foo() {\n" +
" synchronized (this)\n" +
" {\n" +
" foo();\n" +
" }\n" +
" }\n" +
"}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
doTextTest("class Foo {\n" + " void foo() {\n" + "synchronized (this) {foo();\n" + "}\n" + " }\n" + "}", "class Foo {\n" +
" void foo() {\n" +
" synchronized (this)\n" +
" {\n" +
" foo();\n" +
" }\n" +
" }\n" +
"}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED2;
doTextTest("class Foo {\n" + " void foo() {\n" + "synchronized (this) {\n" + "foo();\n" + "}\n" + " }\n" + "}", "class Foo {\n" +
" void foo() {\n" +
" synchronized (this)\n" +
" {\n" +
" foo();\n" +
" }\n" +
" }\n" +
"}");
}