expected type (available after removing type cast) may add bounds for inference variables which would lead to errors after applying the fix
GitOrigin-RevId: 24a97411b7175cacabd8e81ed5711509195dfd4d
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 patch removes the detection of redundant calls to `StringBuilder#toString` from the `RedundantStringOperationInspection` since there is a more general inspection called `UnnecessaryToStringCallInspection` which handles all the redundant `Object#toString` calls. All the related tests were moved to the test data of `UnnecessaryToStringCallInspectionTest`
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: 1fe7723fa4369b797120c5bbc6a6b24947c84a94
This patch fixes the syntax error in testData
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: 90aae74914c4143dcb1ebff9e7d0c585f373718b
This patch simplifies the `RedundantStringOperationInspection#isOperandOfStringType` method by checking if the type of the passed operand is java.lang.String. The check is the same for any passed operand since they are of the `PsiExpression` type and hence poses the `PsiExpression#getType` method.
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: bcd489d41d1272877a1bbf6032ef837a228a18e1
This patch alters the `getRedundantStringBuilderToStringProblem` method with more sophisticated algorithm to detect unnecessary freestanding `StringBuilder#toString` calls. If the call is a part of a polyadic expression it checks if there is at least one string operand (either a constant literal or a local variable or a constant variable or a method call) and based on that information it detects redundant `StringBuilder#toString` calls.
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: e09ea8b8829ad9e28e8ff1bcfad34cf6b191aa6b
This patch enhances RedundantStringOperationInspection with detecting either unnecessary naked calls StringBuilder.toString or redundant toString in StringBuilder.toString.substring.
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: 3cd7e964c0acc73fb1ac38061ef31264035f82dc
This patch adds processing of Java 14's text blocks to RedundantStringFormatCallInspection and fixes the problems from the code review
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: 126cfc001e7b201b62060333de7f71480403fb93
This patch fixes the notes from the code review, it inclues:
- renaming method to methodNameReference for variables that contain the name of a method that is being called, i.e. either `println` or `print` or `format`
- using a different overloaded createProblemDescriptor method that does not accept a `TextRange`
- using `getParent` in quick fixes to get the `PsiMethodExpressionCall`
- proper handling arguments with parenthesis
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: ea1e335372bf7b1ce3e6c87a3816baa0ab54e11e
This patch fixes the notes from the code review, it includes:
- Renaming the testData files so their titles are more informative
- Moving `PsiLiteralUtil#append` to `RedundantStringFormatCallInspection` and renaming it to `joinWithNewlineToken` so it does not have to deal with the escape characters' problems
- `RedundantStringFormatCallInspection` only highlights the "`format`" word in `String.format` in order to reduce the warnings area in code visually
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: 07b3b3b2d24e500774928d406e274dd4cb20bd5d
The RedundantStringFormatCallInspection inspection used to be able to
detect excessive String.format calls and get rid of them not changing
the callsite at all. This patch enhances the inspection's capabilities
with changing the callsite if it is either PrintStream#print or
PrintStream#println and converting it to PrintStream#printf adding "%n"
if necessary.
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: 7edc5b0a84fb6c7b9caf504b1afb8905c5684985