mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[codeInsight] IDEA-240288 Inspection for StringBuilder.toString().substring()
This patch replaces the excessive extraction of a qualifier via `ExpressionUtils.getEffectiveQualifier` with a simple `call.getMethodExpression().getQualifierExpression` Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com> GitOrigin-RevId: 4a4f1c6b218c63691fa2bd4610e9901874d3c712
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b12dfe5539
commit
ce7dae26b1
+2
@@ -27,6 +27,8 @@ class StringBuilderToString {
|
||||
System.out.println(new StringBuilder().substring(1, 3).length());
|
||||
|
||||
"hello".substring(sb.toString());
|
||||
System.out.println((((new StringBuilder()))).substring(1, 3));
|
||||
System.out.println((new StringBuilder()).substring(1, 3).length());
|
||||
}
|
||||
|
||||
void builder(StringBuilder sb) {
|
||||
|
||||
+2
@@ -20,6 +20,8 @@ class StringBuilderToString {
|
||||
System.out.println(new StringBuilder().substring(1, 3).length());
|
||||
|
||||
"hello".substring(sb.toString());
|
||||
System.out.println((((new StringBuilder()))).substring(1, 3));
|
||||
System.out.println((new StringBuilder()).substring(1, 3).length());
|
||||
}
|
||||
|
||||
void builder(StringBuilder sb) {
|
||||
|
||||
+1
-1
@@ -282,7 +282,7 @@ public class RedundantStringOperationInspection extends AbstractBaseJavaLocalIns
|
||||
final PsiMethodCallExpression substringCall = PsiTreeUtil.getParentOfType(call, PsiMethodCallExpression.class);
|
||||
if (substringCall == null) return null;
|
||||
|
||||
final PsiExpression qualifier = ExpressionUtils.getEffectiveQualifier(substringCall.getMethodExpression());
|
||||
final PsiExpression qualifier = PsiUtil.skipParenthesizedExprDown(substringCall.getMethodExpression().getQualifierExpression());
|
||||
if (qualifier != call || !STRING_SUBSTRING.test(substringCall)) return null;
|
||||
|
||||
return getProblem(call, "inspection.redundant.string.call.message");
|
||||
|
||||
Reference in New Issue
Block a user