当前位置: 首页>>代码示例>>Java>>正文


Java CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED属性代码示例

本文整理汇总了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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaSpacePropertyProcessor.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaSpacePropertyProcessor.java

示例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" +
     "}");
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:JavaFormatterTest.java

示例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" +
     "}");
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:JavaFormatterTest.java

示例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" +
     "}");
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:JavaFormatterTest.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:AbstractJavaBlock.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:AbstractJavaBlock.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JavaSpacePropertyProcessor.java

示例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" +
                                                                                                                    "}");


}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:JavaFormatterTest.java

示例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"
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JavaFormatterBracesTest.java

示例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" +
    "}"
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:JavaFormatterBracesTest.java

示例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"
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JavaFormatterBracesTest.java

示例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"
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JavaFormatterBracesTest.java

示例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"
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JavaFormatterBracesTest.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:EclipseCodeStyleImportWorker.java


注:本文中的com.intellij.psi.codeStyle.CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。