如何让eclipse代码格式化程序将赋值语句包装起来=运算符

时间:2018-05-04 08:38:55

标签: java eclipse formatter eclipse-formatter

我使用的是eclipse代码格式化程序,并且我已将最大行长度设置为120。 如果赋值语句超过120个字符,例如

private Map<Instruction, LocalRegisterAssignmentInformation> instructionRegisterMap = new IdentityHashMap<Instruction, LocalRegisterAssignmentInformation>();

我希望格式化程序包装这一行并使语句看起来像这样:

private Map<Instruction, LocalRegisterAssignmentInformation> instructionRegisterMap
  = new IdentityHashMap<Instruction, LocalRegisterAssignmentInformation>();

但格式化程序似乎并没有包装它。我尝试在eclipse格式化程序配置文件设置中找到相关选项,但无法找到任何选项。

1 个答案:

答案 0 :(得分:1)

编辑Java格式化程序配置文件,如下所示:

  1. 换行 中选择 表达式&gt;分配
  2. 换行政策 设置为 必要时换行
  3. 选中 操作员前的
  4. 复选框