This patch removes StringUtil.isEmpty("%n") from RedundantStringFormatCallInspection#joinWithNewlineToken as it is always true. In addition to that it also includes:
- inlining the getMethodNameRange method since the createProblemDescriptor method accepts a nullable parameter
- moving RedundantStringFormatCallInspection#joinWithNewlineToken inside of StringFormatToPrintfQuickFix to reduce its visibility scope
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: e70f0b6be7eb158910016ac2bb31bb5667186c91
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
We should not use container annotation for top-level local variable type, but may use it for nested ones.
GitOrigin-RevId: 507cfd221f073dffc78ccec3fd9ba6b79b888c76
JLS 15.25 says: ...has return type boolean or Boolean. or ...is convertible to a numeric type.
JLS 5.1.8 says:
A type is said to be convertible to a numeric type if it is a numeric type (§4.2), or it is a reference type that may be converted to a numeric type by unboxing conversion.
Nothing about bounds
PolyConditionalExpressionWithTargetPrimitive test behavior matches Java 9+ now (with --release=8)
GitOrigin-RevId: fa14e909ad623a3ab6bb8355bbbe396003cd782c
This patch fixes notes from the latest code review, the changes include:
- Moving RedundantStringOperationVisitor#getTargetString to SubstringEqualsToCharAtEqualsQuickFix#getTargetString
to reduce the complexity of the visitor
- Making `textExtactor` from SubstringEqualsToCharAtEqualsQuickFix#getTargetString
NotNull
- Adding the check that the length of the input string should be greater
than 1 in order to perform the transformation in PsiLiteralUtil#charLiteralForCharString
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: 2a11f8691bab082da39d2763ab7d96a41b7ce09a
This patch fixes the notes from the review, it includes:
- restoring annotation.naming.convention.display.name
- using com.intellij.openapi.util.Pair instead of custom private objects
- using EquivalenceChecker.expressionsMatch in order to extract
difference between two PsiBinaryExpression
- using BoolUtils.findNegation to properly deduce the sign of the equals
clause
- restoring comments while replacing substring with charAt
- properly handling special characters (e.g. '\\', '\n', '\"', etc.) in
equals clause when it is converted to charAt + "=="
- eliminating the imperative form of a message for the inspection of
substring + equals
Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>
GitOrigin-RevId: be1dfd53a6af10979485cd172af39653faafb744
starting with javac 1.9+ such code starting to compile, javac 8 rejects the code with the same language level used
GitOrigin-RevId: 87a1e4d475927af0ee71cd74f5a66e130908ed82
Fixes IDEA-235214 Highlighting freezes when captured wildcard used on the type with cyclic dependency in type variable
GitOrigin-RevId: 16d114ccab944d55dfbbdc29c227d60756e2ba1a