Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/redundantStringOperation/afterSubstringOneCharInEquals.java
Nikita Eshkeev 565443bca4 [codeInsight] IDEA-219640 Inspection to detect some pointless String.substring
This patch fixes the notes from the review, it contains:

1. fixing the javadoc for ExpressionUtils#isConversionToStringNecessary
2. properly handling JavaTokenType.MINUS in ExpressionUtils#isDifference
3. properly handling complex PsiPolyadicExpression values in ExpressionUtils#isDifference
4. changing ProblemHighlightType to GENERIC_ERROR_OR_WARNING for
inspecitons like these
5. fixing the comments duplication problem when replacing the old string
with a new one for inspections like stringValue.substring(0, 1).equals("_")

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

GitOrigin-RevId: 907524c9026e2d1d7cd6f0bd7b988e478e73298d
2020-04-20 20:10:15 +00:00

22 lines
766 B
Java

// "Fix all 'Redundant String operation' problems in file" "true"
class Foo {
public static void main(String[] args) {
int i = Integer.parseInt(args[2]);
int j = Integer.parseInt(args[4]);
boolean value = args[0].charAt(4) == '_';
if (args[0].charAt(4) == '_') { }
if (args[0].charAt(4) != '_') { }
if (args[0].charAt(4) == '_') { }
if (args[0].charAt(4) != '_') { }
if (/* one */args/* two */[/* three */ 0 /* four */].charAt(i /* five */ + 1) == 'x') { }
/* one */
if (args/* two */[/* three */ 0 /* four */].charAt(i /* five */ + 1) != 'x') { }
/* one */
if (args/* two */[/* three */ 0 /* four */].charAt(i /* five */ + 1) != 'x') { }
if (args[0].charAt(i - ((j - 1) - (j + 1))) == '\'') {}
}
}