根据IntelliJ IDEA中的优先级格式化条件语句

时间:2018-04-19 09:20:18

标签: java eclipse intellij-idea code-formatting

有没有办法像Eclipse那样制作IntelliJ IDEA格式的条件语句(根据条件优先级)?

的Eclipse

public boolean apply(NewsDocument document) {
  return "EDG".equalsIgnoreCase(document.getFeedShortName())
      && (isNullOrEmpty(document.getEdgarFormType())
          || "10-K".equalsIgnoreCase(document.getEdgarFormType())
          || "20-F".equalsIgnoreCase(document.getEdgarFormType()))
      && documentWithinRecentFiscalYear(document);
}

return accessLevel == inFeature.getAccessLevel()
    || accessLevel != AccessLevel.NO_ACCESS
        && inFeature.getAccessLevel() == AccessLevel.NOT_SET;

return hasConnectionHolder() && getConnectionHolder().isRollbackOnly()
    || getHibernateSessionHolder() != null
        && getHibernateSessionHolder().isRollbackOnly()
    || getTxContextHolder() != null
        && getTxContextHolder().isRollbackOnly();

IntelliJ IDEA (设置|代码样式| Java |包装和大括号|二进制表达式|在多行= false 时将对齐括号

public boolean apply(NewsDocument document) {
  return "EDG".equalsIgnoreCase(document.getFeedShortName())
      && (isNullOrEmpty(document.getEdgarFormType())
      || "10-K".equalsIgnoreCase(document.getEdgarFormType())
      || "20-F".equalsIgnoreCase(document.getEdgarFormType()))
      && documentWithinRecentFiscalYear(document);
}

return accessLevel == inFeature.getAccessLevel()
    || accessLevel != AccessLevel.NO_ACCESS
    && inFeature.getAccessLevel() == AccessLevel.NOT_SET;

return hasConnectionHolder() && getConnectionHolder().isRollbackOnly()
    || getHibernateSessionHolder() != null
    && getHibernateSessionHolder().isRollbackOnly()
    || getTxContextHolder() != null
    && getTxContextHolder().isRollbackOnly();

IntelliJ IDEA (设置|代码样式| Java |包装和大括号|二进制表达式|在多行= 为真时将对齐括号

public boolean apply(NewsDocument document) {
  return "EDG".equalsIgnoreCase(document.getFeedShortName())
      && (isNullOrEmpty(document.getEdgarFormType())
              || "10-K".equalsIgnoreCase(document.getEdgarFormType())
              || "20-F".equalsIgnoreCase(document.getEdgarFormType()))
      && documentWithinRecentFiscalYear(document);
}

return accessLevel == inFeature.getAccessLevel()
    || accessLevel != AccessLevel.NO_ACCESS
    && inFeature.getAccessLevel() == AccessLevel.NOT_SET;

return hasConnectionHolder() && getConnectionHolder().isRollbackOnly()
    || getHibernateSessionHolder() != null
    && getHibernateSessionHolder().isRollbackOnly()
    || getTxContextHolder() != null
    && getTxContextHolder().isRollbackOnly();

IntelliJ IDEA版本:2017.3.5

1 个答案:

答案 0 :(得分:0)

您只需从Eclipse导入代码格式化程序设置

  • 您只需从Eclipse导出设置(转到Eclipse的首选项→Java→代码样式→格式化程序,然后通过“全部导出”按钮将设置导出到XML文件。),
  • 打开IntelliJ IDEA设置→代码样式→Java,单击管理,然后只需单击导入即可导入该XML文件。