3 Commits

Author SHA1 Message Date
Tagir Valeev
7e1064ea3c [java-intentions] More preview tests; minor fixes
GitOrigin-RevId: 22a46c15d8900d8a31514846755a013f6a67ad42
2022-07-29 17:55:13 +00:00
Nikita Eshkeev
7b6e636c13 [codeInsight] IDEA-219640 Inspection to detect some pointless String.substring
IDEA didn't use to report pointless String.substring invocations for
cases when only one character in the string is extracted. In such cases
it makes more sense to use the String#charAt method because it is
allocation free.

IDEA didn't use to suggest to refactor for the code when String.substring
selects a single character and is followed by the equals method(e.g.
args[0].substring(0, 1).equals("_")) to more readable version e.g.
args[0].charAt(0) == '_'.

This patch adds such refactorings to both of the cases. It also adds
the possiblity to handle expressions like "i+1" and "i+2" to
com.siyeh.ig.psiutils.ExpressionUtils#isDifference.

Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>

GitOrigin-RevId: 6d179c7c9c605f08b4d4468712f8468fd68045a1
2020-04-15 21:31:10 +00:00
Tagir Valeev
2f547ca38f RedundantStringOperationInspection: warn about append(s.substring(x, y))
Replaceable with append(s, x, y)
Fixes IDEA-185652 Improve StringBulder.append(s.substring(1,2)) intention
Also optimization of new expression resolution
2018-01-29 13:34:55 +07:00