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


Java CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM属性代码示例

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


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

示例1: testFirstArgumentWrapping

public void testFirstArgumentWrapping() throws Exception {
  getSettings().RIGHT_MARGIN = 20;
  getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
  doTextTest("class Foo {\n" + "    void foo() {\n" + "        fooFooFooFoo(1);" + "    }\n" + "}",
             "class Foo {\n" + "    void foo() {\n" + "        fooFooFooFoo(\n" + "                1);\n" + "    }\n" + "}");

  getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
  doTextTest("class Foo {\n" + "    void foo() {\n" + "        fooFooFooFoo(1,2);" + "    }\n" + "}", "class Foo {\n" +
                                                                                                      "    void foo() {\n" +
                                                                                                      "        fooFooFooFoo(\n" +
                                                                                                      "                1,\n" +
                                                                                                      "                2);\n" +
                                                                                                      "    }\n" +
                                                                                                      "}");

  doTextTest("class Foo {\n" + "    void foo() {\n" + "        fooFooFoo(1,2);" + "    }\n" + "}",
             "class Foo {\n" + "    void foo() {\n" + "        fooFooFoo(1,\n" + "                2);\n" + "    }\n" + "}");

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

示例2: test1980

public void test1980() throws Exception {
    getSettings().RIGHT_MARGIN = 144;
    getSettings().TERNARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
    getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
    getSettings().ALIGN_MULTILINE_TERNARY_OPERATION = true;
    getSettings().TERNARY_OPERATION_SIGNS_ON_NEXT_LINE = true;
    doTextTest("class Foo{\n" +
               "    void foo() {\n" +
               "final VirtualFile moduleRoot = moduleRelativePath.equals(\"\") ? projectRootDirAfter : projectRootDirAfter.findFileByRelativePath(moduleRelativePath);\n" +
               "    }\n" +
"}", "class Foo {\n" +
     "    void foo() {\n" +
     "        final VirtualFile moduleRoot = moduleRelativePath.equals(\"\")\n" +
     "                                       ? projectRootDirAfter\n" +
     "                                       : projectRootDirAfter.findFileByRelativePath(moduleRelativePath);\n" +
     "    }\n" +
     "}");
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaFormatterTest.java

示例3: testIDEADEV_23551

public void testIDEADEV_23551() throws IncorrectOperationException {
  getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;

  getSettings().RIGHT_MARGIN = 60;
  doTextTest("public class Wrapping {\n" +
             "public static void sample() {\n" +
             "System.out.println(\".\" + File.separator + \"..\" + File.separator + \"some-directory-name\" + File.separator + \"more-file-name\");\n" +
             "}\n" +
             "}", "public class Wrapping {\n" +
                  "    public static void sample() {\n" +
                  "        System.out.println(\".\" +\n" +
                  "                File.separator +\n" +
                  "                \"..\" +\n" +
                  "                File.separator +\n" +
                  "                \"some-directory-name\" +\n" +
                  "                File.separator +\n" +
                  "                \"more-file-name\");\n" +
                  "    }\n" +
                  "}");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:JavaFormatterTest.java

示例4: testChainedMethodCalls_WithChopDownIfLongOption

public void testChainedMethodCalls_WithChopDownIfLongOption() throws Exception {
  getSettings().ALIGN_MULTILINE_CHAINED_METHODS = true;
  getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM; // it's equal to "Chop down if long"
  getSettings().RIGHT_MARGIN = 50;

  String before = "a.current.current.getThis().getThis().getThis().getThis().getThis();";
  doMethodTest(
    before,
    "a.current.current.getThis()\n" +
    "                 .getThis()\n" +
    "                 .getThis()\n" +
    "                 .getThis()\n" +
    "                 .getThis();"
  );

  getSettings().RIGHT_MARGIN = 80;
  doMethodTest(before, before);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:JavaFormatterAlignmentTest.java

示例5: testDoNotWrapMethodsWithMethodCallAsParameters

@SuppressWarnings("SpellCheckingInspection")
public void testDoNotWrapMethodsWithMethodCallAsParameters() {
  getSettings().WRAP_LONG_LINES = true;
  getSettings().RIGHT_MARGIN = 140;
  getSettings().PREFER_PARAMETERS_WRAP = true;
  getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
  getSettings().CALL_PARAMETERS_RPAREN_ON_NEXT_LINE = true;
  getSettings().CALL_PARAMETERS_LPAREN_ON_NEXT_LINE = true;

  String before = "   processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage());";
  String after = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage());";

  doMethodTest(before, after);

  before = "   processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage(loooooooooooooooooongParamName));";
  after = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage(loooooooooooooooooongParamName));";

  doMethodTest(before, after);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaFormatterWrapTest.java

示例6: testLongFinalParameterList

public void testLongFinalParameterList() {
  CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()).clone();
  try {
    CommonCodeStyleSettings javaSettings = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE);
    javaSettings.RIGHT_MARGIN = 80;
    javaSettings.KEEP_LINE_BREAKS = true;
    codeStyleSettings.GENERATE_FINAL_PARAMETERS = true;
    javaSettings.METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
    CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(codeStyleSettings);
    doTest(false);
  }
  finally {
    CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:OverrideImplement15Test.java

示例7: testLongParameterList

public void testLongParameterList() {
  CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()).clone();
  try {
    CommonCodeStyleSettings javaSettings = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE);
    javaSettings.RIGHT_MARGIN = 80;
    javaSettings.KEEP_LINE_BREAKS = false;
    codeStyleSettings.GENERATE_FINAL_PARAMETERS = false;
    javaSettings.METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
    CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(codeStyleSettings);
    doTest(false);
  }
  finally {
    CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:OverrideImplement15Test.java

示例8: testWrapExtendsList

public void testWrapExtendsList() throws Exception {
  getSettings().RIGHT_MARGIN = 50;
  getSettings().EXTENDS_LIST_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
  getSettings().EXTENDS_KEYWORD_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;

  doTextTest("class ColtreDataProvider extends DataProvider, AgentEventListener, ParameterDataEventListener {\n}",
             "class ColtreDataProvider extends DataProvider,\n" +
             "        AgentEventListener,\n" +
             "        ParameterDataEventListener {\n}");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JavaFormatterTest.java

示例9: testWrapParamsOnEveryItem

public void testWrapParamsOnEveryItem() throws Exception {
  CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject());

  int oldMargin = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE).RIGHT_MARGIN;
  boolean oldKeep = codeStyleSettings.KEEP_LINE_BREAKS;
  int oldWrap = codeStyleSettings.METHOD_PARAMETERS_WRAP;

  try {
    codeStyleSettings.setRightMargin(JavaLanguage.INSTANCE, 80);
    codeStyleSettings.KEEP_LINE_BREAKS = false;
    codeStyleSettings.METHOD_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;

    doClassTest(
      "public void foo(String p1,\n" +
      "                String p2,\n" +
      "                String p3,\n" +
      "                String p4,\n" +
      "                String p5,\n" +
      "                String p6,\n" +
      "                String p7) {\n" +
      "    //To change body of implemented methods use File | Settings | File Templates.\n" +
      "}",
      "public void foo(String p1,\n" +
      "                String p2,\n" +
      "                String p3,\n" +
      "                String p4,\n" +
      "                String p5,\n" +
      "                String p6,\n" +
      "                String p7) {\n" +
      "    //To change body of implemented methods use File | Settings | File Templates.\n" +
      "}");
  }
  finally {
    codeStyleSettings.setRightMargin(JavaLanguage.INSTANCE, oldMargin);
    codeStyleSettings.KEEP_LINE_BREAKS = oldKeep;
    codeStyleSettings.METHOD_PARAMETERS_WRAP = oldWrap;
  }

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

示例10: getWrapType

public int getWrapType() {
  switch (getEclipseWrap()) {
    case WRAP_WHERE_NECESSARY:
    case WRAP_FIRST_OTHERS_WHERE_NECESSARY:
      return CommonCodeStyleSettings.WRAP_AS_NEEDED;
    case WRAP_ALL_EXCEPT_FIRST:
    case WRAP_ALL_INDENT_EXCEPT_FIRST:
    case WRAP_ALL_ON_NEW_LINE_EACH:
      return CommonCodeStyleSettings.WRAP_AS_NEEDED | CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
  }
  return CommonCodeStyleSettings.DO_NOT_WRAP;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:EclipseCodeStyleImportWorker.java

示例11: testEnforceIndentMethodCallParamWrap

public void testEnforceIndentMethodCallParamWrap() {
  getSettings().WRAP_LONG_LINES = true;
  getSettings().RIGHT_MARGIN = 140;
  getSettings().PREFER_PARAMETERS_WRAP = true;
  getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;

  String before = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, " +
                  "String.format(\"Could not process annotations: %s%n%s\", e.toString(), writer.toString()));";

  String afterFirstReformat = "processingEnv.getMessenger().printMessage(\n" +
                              "        Diagnostic.Kind.ERROR, String.format(\n" +
                              "        \"Could not process annotations: %s%n%s\",\n" +
                              "        e.toString(),\n" +
                              "        writer.toString()\n" +
                              ")\n" +
                              ");";

  String after = "processingEnv.getMessenger().printMessage(\n" +
                 "        Diagnostic.Kind.ERROR, String.format(\n" +
                 "                \"Could not process annotations: %s%n%s\",\n" +
                 "                e.toString(),\n" +
                 "                writer.toString()\n" +
                 "        )\n" +
                 ");";

  doMethodTest(afterFirstReformat, after);

  getSettings().CALL_PARAMETERS_RPAREN_ON_NEXT_LINE = true;
  getSettings().CALL_PARAMETERS_LPAREN_ON_NEXT_LINE = true;
  doMethodTest(before,
               "processingEnv.getMessenger().printMessage(\n" +
               "        Diagnostic.Kind.ERROR,\n" +
               "        String.format(\"Could not process annotations: %s%n%s\", e.toString(), writer.toString())\n" +
               ");");

  String literal = "\"" + StringUtil.repeatSymbol('A', 128) + "\"";
  before = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, call(" + literal + "));\n";
  after = "processingEnv.getMessenger().printMessage(\n" +
          "        Diagnostic.Kind.ERROR,\n" +
          "        call(" + literal + ")\n" +
          ");\n";

  doMethodTest(before, after);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:JavaFormatterWrapTest.java

示例12: testChopDownArrays

public void testChopDownArrays() {
  getCustomCodeStyleSettings().ARRAY_WRAPPING = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
  getCodeStyleSettings().setRightMargin(JsonLanguage.INSTANCE, 40);
  doTest();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:JsonFormattingTest.java

示例13: testManifest7

public void testManifest7() throws Exception {
  deleteManifest();
  final XmlCodeStyleSettings xmlSettings = mySettings.getCustomSettings(XmlCodeStyleSettings.class);
  xmlSettings.XML_ATTRIBUTE_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
  doTestManifest("manifest1.xml");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:AndroidXmlFormatterTest.java


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