本文整理汇总了Java中com.intellij.psi.codeStyle.CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED属性的典型用法代码示例。如果您正苦于以下问题:Java CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED属性的具体用法?Java CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED怎么用?Java CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.psi.codeStyle.CommonCodeStyleSettings
的用法示例。
在下文中一共展示了CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSpaceBeforeMethodLBrace
@NotNull
private Spacing getSpaceBeforeMethodLBrace(@NotNull PsiMethod method) {
final int space = mySettings.SPACE_BEFORE_METHOD_LBRACE ? 1 : 0;
final int methodBraceStyle = mySettings.METHOD_BRACE_STYLE;
if (methodBraceStyle == CommonCodeStyleSettings.END_OF_LINE) {
return createNonLFSpace(space, null, false);
}
else if (methodBraceStyle == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
TextRange headerRange = new TextRange(getMethodHeaderStartOffset(method), getMethodHeaderEndOffset(method));
return createNonLFSpace(space, headerRange, false);
}
else if (shouldHandleAsSimpleMethod(method)) {
TextRange rangeWithoutAnnotations = new TextRange(getMethodHeaderStartOffset(method), method.getTextRange().getEndOffset());
return createNonLFSpace(space, rangeWithoutAnnotations, false);
}
return Spacing.createSpacing(space, space, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
示例2: getSpaceBeforeClassLBrace
@NotNull
private Spacing getSpaceBeforeClassLBrace(@NotNull PsiClass aClass) {
final int space = mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0;
final int classBraceStyle = mySettings.CLASS_BRACE_STYLE;
if (classBraceStyle == CommonCodeStyleSettings.END_OF_LINE || shouldHandleAsSimpleClass(aClass)) {
return createNonLFSpace(space, null, false);
}
else if (classBraceStyle == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
final PsiIdentifier nameIdentifier = aClass.getNameIdentifier();
final int startOffset = nameIdentifier == null ? myParent.getTextRange().getStartOffset() : nameIdentifier.getTextRange().getStartOffset();
TextRange range = new TextRange(startOffset, myChild1.getTextRange().getEndOffset());
return createNonLFSpace(space, range, false);
}
return Spacing.createSpacing(space, space, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
示例3: testBraceOnNewLineIfWrapped
public void testBraceOnNewLineIfWrapped() throws Exception {
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
getSettings().RIGHT_MARGIN = 35;
getSettings().ALIGN_MULTILINE_BINARY_OPERATION = true;
doTextTest("class Foo {\n" +
" void foo(){\n" +
" if (veryLongCondition || veryVeryVeryVeryLongCondition) {\n" +
" foo();\n" +
" }\n" +
" if (a) {\n" +
" }" +
" }\n" +
"}", "class Foo {\n" +
" void foo() {\n" +
" if (veryLongCondition ||\n" +
" veryVeryVeryVeryLongCondition)\n" +
" {\n" +
" foo();\n" +
" }\n" +
" if (a) {\n" +
" }\n" +
" }\n" +
"}");
}
示例4: testSCR1795
public void testSCR1795() throws Exception {
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
doTextTest("public class Test {\n" +
" public static void main(String[] args) {\n" +
" do {\n" +
" // ...\n" +
" } while (true);\n" +
" }\n" +
"}", "public class Test {\n" +
" public static void main(String[] args) {\n" +
" do {\n" +
" // ...\n" +
" } while (true);\n" +
" }\n" +
"}");
}
示例5: testSCR2132
public void testSCR2132() throws Exception {
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
getSettings().ELSE_ON_NEW_LINE = true;
doTextTest("class Foo {\n" +
" void foo() {\n" +
" if (!rightPanel.isAncestorOf(validationPanel)) \n" +
" {\n" +
" splitPane.setDividerLocation(1.0);\n" +
" }\n" +
" else\n" +
" {\n" +
" splitPane.setDividerLocation(0.7);\n" +
" }" +
" }\n" +
"}", "class Foo {\n" +
" void foo() {\n" +
" if (!rightPanel.isAncestorOf(validationPanel)) {\n" +
" splitPane.setDividerLocation(1.0);\n" +
" }\n" +
" else {\n" +
" splitPane.setDividerLocation(0.7);\n" +
" }\n" +
" }\n" +
"}");
}
示例6: getCodeBlockExternalIndent
protected Indent getCodeBlockExternalIndent() {
final int braceStyle = getBraceStyle();
if (braceStyle == CommonCodeStyleSettings.END_OF_LINE || braceStyle == CommonCodeStyleSettings.NEXT_LINE ||
braceStyle == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
return Indent.getNoneIndent();
}
return Indent.getNormalIndent();
}
示例7: getCodeBlockChildExternalIndent
protected Indent getCodeBlockChildExternalIndent(final int newChildIndex) {
final int braceStyle = getBraceStyle();
if (!isAfterCodeBlock(newChildIndex)) {
return Indent.getNormalIndent();
}
if (braceStyle == CommonCodeStyleSettings.NEXT_LINE ||
braceStyle == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED ||
braceStyle == CommonCodeStyleSettings.END_OF_LINE) {
return Indent.getNoneIndent();
}
return Indent.getNormalIndent();
}
示例8: getSpaceBeforeLBrace
private Spacing getSpaceBeforeLBrace(@NotNull ASTNode lBraceBlock, boolean spaceBeforeLbrace, @Nullable TextRange nextLineIfWrappedOptionRange) {
int space = spaceBeforeLbrace ? 1 : 0;
if (mySettings.BRACE_STYLE == CommonCodeStyleSettings.END_OF_LINE) {
return createNonLFSpace(space, null, false);
}
else if (mySettings.BRACE_STYLE == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
return createNonLFSpace(space, nextLineIfWrappedOptionRange, false);
}
else if (shouldHandleAsSimpleBlock(lBraceBlock)) {
return createNonLFSpace(space, lBraceBlock.getTextRange(), false);
}
return Spacing.createSpacing(space, space, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
示例9: 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" +
"}");
}
示例10: testMethodBraceOnNextLineIfWrapped
public void testMethodBraceOnNextLineIfWrapped() {
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
getSettings().METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().RIGHT_MARGIN = 50;
doClassTest(
"public static void main(int state, int column, int width, int rate) {\n" +
"}\n",
"public static void main(int state, int column,\n" +
" int width, int rate)\n" +
"{\n" +
"}\n"
);
}
示例11: testIDEA127110
public void testIDEA127110() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
doMethodTest(
"if ( 1 > 2) {\n" +
"\n" +
"} else {\n" +
"\n" +
"}\n" +
"\n" +
"try {\n" +
"\n" +
"} catch ( Exception e) {\n" +
"\n" +
"} finally {\n" +
"\n" +
"}",
"if (1 > 2) {\n" +
"\n" +
"} else {\n" +
"\n" +
"}\n" +
"\n" +
"try {\n" +
"\n" +
"} catch (Exception e) {\n" +
"\n" +
"} finally {\n" +
"\n" +
"}"
);
}
示例12: testConstructorLeftBraceWithComment
public void testConstructorLeftBraceWithComment() {
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
doClassTest(
"/**\n" +
" *\n" +
" */\n" +
" public Test() {\n" +
"}\n",
"/**\n" +
" *\n" +
" */\n" +
"public Test() {\n" +
"}\n"
);
}
示例13: testConstructorLeftBraceWithAnnotation
public void testConstructorLeftBraceWithAnnotation() {
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
doClassTest(
" @Deprecated\n" +
"public Test() {\n" +
"}\n",
"@Deprecated\n" +
"public Test() {\n" +
"}\n"
);
}
示例14: testConstructorLeftBraceWithEndLineComment
public void testConstructorLeftBraceWithEndLineComment() {
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
doClassTest(
"// comment\n" +
" public Test() {\n" +
"}\n",
"// comment\n" +
"public Test() {\n" +
"}\n"
);
}
示例15: 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);
}