dubreuia / intellij-plugin-save-actions

Supports configurable, Eclipse like, save actions, including "organize imports", "reformat code" and "rearrange code".
MIT License
531 stars 101 forks source link

codecleanup produces java compile error #338

Closed k3b closed 3 years ago

k3b commented 3 years ago

this code is optimized to something that cannot be compiled

 String all  = "12345678901234567"
 // ...
 String other = all.substring(12, 13) + all.substring(14, 15);

will be "optimized" to

 other = all.charAt(12) + all.charAt(14);

which cannot be comiled: Wrong expression type String = char + char

This would work:

other = "" + all.charAt(12) + all.charAt(14);

String = String + char + char

I am using IntelliJ-ultimate 2020.2 with SaveActions 2.2.0 and jdk11

dubreuia commented 3 years ago

Hello @k3b, thank you for your bug report, but I'm unsure this is a Save Actions problem. AFAIK there's no quick fix implemented in Save Actions that will optimize from String other = all.substring(12, 13) + all.substring(14, 15); to other = all.charAt(12) + all.charAt(14);. Can you disable Save Actions and see if the problem persists? If it doesn't, reopen this issue.