6 Commits

Author SHA1 Message Date
Bas Leijdekkers
df2af98547 IG: don't warn on call to .formatted() when qualifier contains %n (IDEA-284569)
GitOrigin-RevId: e1b9a826f67e0209f82810ed19f907b2d0161605
2022-01-06 20:08:21 +00:00
Nikita Eshkeev
ec420ec3d4 [codeInsight] IDEA-113640 Provide intention to combine System.out.println(String.format(...)) into System.out.printf
This patch cleans up the code

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

GitOrigin-RevId: f90c1f9af167102b3b57daf43c144973e9502a6f
2020-05-08 01:22:39 +00:00
Nikita Eshkeev
8db5967f7b [codeInsight] IDEA-113640 Provide intention to combine System.out.println(String.format(...)) into System.out.printf
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
2020-05-08 00:38:22 +00:00
Nikita Eshkeev
299e3d31e1 [codeInsight] IDEA-113640 Provide intention to combine System.out.println(String.format(...)) into System.out.printf
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
2020-05-06 13:46:11 +00:00
Nikita Eshkeev
fcd7fac054 [codeInsight] IDEA-113640 Provide intention to combine System.out.println(String.format(...)) into System.out.printf
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
2020-05-04 17:09:45 +00:00
Nikita Eshkeev
d605adb8d1 [codeInsight] IDEA-113640 Provide intention to combine System.out.println(String.format(...)) into System.out.printf
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
2020-05-01 14:07:13 +00:00