kh-bd / interp4j-intellij-plugin

Intellij plugin to support interp4j library
3 stars 1 forks source link

Wrong `String.format` replacement #21

Closed KhadanovichSergey closed 1 year ago

KhadanovichSergey commented 1 year ago

If format argument is variable access, generated replacement will be without curly braces. For example,

String params = "Params";
String result = String.format("%s123", params);

Such code will be transformed into

String params = "Params";
String result = s("$params123");

As you can see, it's wrong way. Variable name with remaining string can be valid java literal. In such cases, generated code is wrong and doesn't compile.

The simplest way to fix it, insert curly braces in any case.