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


Java CommonCodeStyleSettings.NEXT_LINE_SHIFTED属性代码示例

本文整理汇总了Java中com.intellij.psi.codeStyle.CommonCodeStyleSettings.NEXT_LINE_SHIFTED属性的典型用法代码示例。如果您正苦于以下问题:Java CommonCodeStyleSettings.NEXT_LINE_SHIFTED属性的具体用法?Java CommonCodeStyleSettings.NEXT_LINE_SHIFTED怎么用?Java CommonCodeStyleSettings.NEXT_LINE_SHIFTED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.intellij.psi.codeStyle.CommonCodeStyleSettings的用法示例。


在下文中一共展示了CommonCodeStyleSettings.NEXT_LINE_SHIFTED属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSCR1615

public void testSCR1615() throws Exception {
  getSettings().CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
  getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
  getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;

  doTextTest(
    "public class ZZZZ \n" +
    "   { \n" +
    "   public ZZZZ() \n" +
    "      { \n" +
    "      if (a){\n" +
    "foo();}\n" +
    "      } \n" +
    "   }",
    "public class ZZZZ\n" +
    "    {\n" +
    "    public ZZZZ()\n" +
    "        {\n" +
    "        if (a)\n" +
    "            {\n" +
    "            foo();\n" +
    "            }\n" +
    "        }\n" +
    "    }");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JavaFormatterTest.java

示例2: testSCR2241

public void testSCR2241() throws Exception {
    getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
    getSettings().SPECIAL_ELSE_IF_TREATMENT = true;
    getSettings().ELSE_ON_NEW_LINE = true;
    doTextTest("class Foo {\n" +
               "    void foo() {\n" +
               "        if (a)\n" +
               "        {\n" +
               "        }\n" +
               "        else\n" +
               "        {\n" +
               "        }\n" +
               "    }\n" +
"}", "class Foo {\n" +
     "    void foo() {\n" +
     "        if (a)\n" +
     "            {\n" +
     "            }\n" +
     "        else\n" +
     "            {\n" +
     "            }\n" +
     "    }\n" +
     "}");
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:JavaFormatterTest.java

示例3: getCodeBlockInternalIndent

protected Indent getCodeBlockInternalIndent(final int baseChildrenIndent, boolean enforceParentIndent) {
  if (isTopLevelClass() && mySettings.DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS) {
    return Indent.getNoneIndent();
  }

  final int braceStyle = getBraceStyle();
  return braceStyle == CommonCodeStyleSettings.NEXT_LINE_SHIFTED ?
         createNormalIndent(baseChildrenIndent - 1, enforceParentIndent)
         : createNormalIndent(baseChildrenIndent, enforceParentIndent);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:AbstractJavaBlock.java

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

示例5: testBracesShiftedOnNextLineOnMethodWithJavadoc

public void testBracesShiftedOnNextLineOnMethodWithJavadoc() throws Exception {
  // Inspired by IDEA-62997
  getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
  
  String precededByJavadoc =
    "/**\n" +
    " * test\n" +
    " */\n" +
    "public int getFoo()\n" +
    "    {\n" +
    "    return foo;\n" +
    "    }";
  
  String precededBySingleLineComment =
    "// test\n" +
    "public int getFoo()\n" +
    "    {\n" +
    "    return foo;\n" +
    "    }";

  String precededByMultiLineComment =
    "/*\n" +
    "test\n" +
    "*/\n" +
    "public int getFoo()\n" +
    "    {\n" +
    "    return foo;\n" +
    "    }";
  
  doClassTest(precededByJavadoc, precededByJavadoc);
  doClassTest(precededBySingleLineComment, precededBySingleLineComment);
  doClassTest(precededByMultiLineComment, precededByMultiLineComment);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:JavaFormatterIndentationTest.java

示例6: 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

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

示例8: testAnonClassCodeBlock_BracesIndented

public void testAnonClassCodeBlock_BracesIndented() {
  getSettings().CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
  doTextTest(
    "class X {\n" +
    "    public void run() {\n" +
    "        Runnable a = new Runnable() {\n" +
    "            @Override\n" +
    "            public void run() {\n" +
    "                \n" +
    "            }\n" +
    "        };\n" +
    "    }\n" +
    "}",

    "class X\n" +
    "    {\n" +
    "    public void run() {\n" +
    "        Runnable a = new Runnable()\n" +
    "            {\n" +
    "            @Override\n" +
    "            public void run() {\n" +
    "\n" +
    "            }\n" +
    "            };\n" +
    "    }\n" +
    "    }"
  );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:JavaFormatterBracesTest.java

示例9: 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

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

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

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

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

示例12: testNextLineShiftedForBlockStatement

public void testNextLineShiftedForBlockStatement() throws Exception {
  getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;

  doTextTest("class Foo {\n" + "    void foo() {\n" + "        if (a)\n" + "        foo();\n" + "    }\n" + "}",
             "class Foo {\n" + "    void foo() {\n" + "        if (a)\n" + "            foo();\n" + "    }\n" + "}");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:JavaFormatterTest.java


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