J2K: Remove special conversion for String.format.
This commit is contained in:
@@ -355,31 +355,6 @@ enum class SpecialMethod(val qualifiedClassName: String?, val methodName: String
|
|||||||
= MethodCallExpression.buildNotNull(codeConverter.convertExpression(qualifier), "toCharArray", codeConverter.convertExpressions(arguments.slice(listOf(2, 3, 0, 1))))
|
= MethodCallExpression.buildNotNull(codeConverter.convertExpression(qualifier), "toCharArray", codeConverter.convertExpressions(arguments.slice(listOf(2, 3, 0, 1))))
|
||||||
},
|
},
|
||||||
|
|
||||||
STRING_FORMAT_WITH_LOCALE(JAVA_LANG_STRING, "format", null) {
|
|
||||||
override fun matches(method: PsiMethod, superMethodsSearcher: SuperMethodsSearcher): Boolean
|
|
||||||
= super.matches(method, superMethodsSearcher) &&
|
|
||||||
method.parameterList.parametersCount == 3 &&
|
|
||||||
method.parameterList.parameters.let { it.first().type.canonicalText == "java.util.Locale" && it.last().isVarArgs }
|
|
||||||
|
|
||||||
override fun convertCall(qualifier: PsiExpression?, arguments: Array<PsiExpression>, typeArgumentsConverted: List<Type>, codeConverter: CodeConverter): Expression? {
|
|
||||||
if (arguments.size < 2) return null // incorrect call
|
|
||||||
return MethodCallExpression.build(codeConverter.convertExpression(arguments[1], true), "format", codeConverter.convertExpressions(listOf(arguments[0]) + arguments.drop(2)), emptyList(), false)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
STRING_FORMAT(JAVA_LANG_STRING, "format", null) {
|
|
||||||
override fun matches(method: PsiMethod, superMethodsSearcher: SuperMethodsSearcher): Boolean {
|
|
||||||
return super.matches(method, superMethodsSearcher) &&
|
|
||||||
method.parameterList.parametersCount == 2 &&
|
|
||||||
method.parameterList.parameters.last().isVarArgs
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun convertCall(qualifier: PsiExpression?, arguments: Array<PsiExpression>, typeArgumentsConverted: List<Type>, codeConverter: CodeConverter): Expression? {
|
|
||||||
if (arguments.isEmpty()) return null // incorrect call
|
|
||||||
return MethodCallExpression.build(codeConverter.convertExpression(arguments.first(), true), "format", codeConverter.convertExpressions(arguments.drop(1)), emptyList(), false)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
STRING_VALUE_OF_CHAR_ARRAY(JAVA_LANG_STRING, "valueOf", null) {
|
STRING_VALUE_OF_CHAR_ARRAY(JAVA_LANG_STRING, "valueOf", null) {
|
||||||
override fun matches(method: PsiMethod, superMethodsSearcher: SuperMethodsSearcher): Boolean {
|
override fun matches(method: PsiMethod, superMethodsSearcher: SuperMethodsSearcher): Boolean {
|
||||||
return super.matches(method, superMethodsSearcher)
|
return super.matches(method, superMethodsSearcher)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
//method
|
//method
|
||||||
public static void adjust(String name, int maxLen) {
|
public static void adjust(String name, int maxLen) {
|
||||||
String.format("%-" + maxLen + "s", name);
|
|
||||||
String.valueOf(1 + 1);
|
String.valueOf(1 + 1);
|
||||||
"a".split("\\s+" + "\\s+", 2)
|
"a".split("\\s+" + "\\s+", 2)
|
||||||
kotlinApi.KotlinApiKt.extensionFunction(1 + 1)
|
kotlinApi.KotlinApiKt.extensionFunction(1 + 1)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
fun adjust(name: String, maxLen: Int) {
|
fun adjust(name: String, maxLen: Int) {
|
||||||
("%-" + maxLen + "s").format(name)
|
|
||||||
(1 + 1).toString()
|
(1 + 1).toString()
|
||||||
"a".split(("\\s+" + "\\s+").toRegex(), 2).toTypedArray()
|
"a".split(("\\s+" + "\\s+").toRegex(), 2).toTypedArray()
|
||||||
(1 + 1).extensionFunction()
|
(1 + 1).extensionFunction()
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ internal class A {
|
|||||||
3.14.toString()
|
3.14.toString()
|
||||||
Object().toString()
|
Object().toString()
|
||||||
|
|
||||||
"Je ne mange pas %d jours".format(Locale.FRENCH, 6)
|
String.format(Locale.FRENCH, "Je ne mange pas %d jours", 6)
|
||||||
"Operation completed with %s".format("success")
|
String.format("Operation completed with %s", "success")
|
||||||
|
|
||||||
val chars = charArrayOf('a', 'b', 'c')
|
val chars = charArrayOf('a', 'b', 'c')
|
||||||
String(chars)
|
String(chars)
|
||||||
|
|||||||
Reference in New Issue
Block a user