[java-inspections] IDEA-274033: Inspection to convert instanceof pattern to old school instanceof. add tests

GitOrigin-RevId: 393b56ff099abd3a02ffceb425309d1bbad51bdc
This commit is contained in:
Mikhail Pyltsin
2023-01-11 15:34:29 +00:00
committed by intellij-monorepo-bot
parent 4ac4c28a09
commit 5d52119cc6
5 changed files with 22 additions and 1 deletions
@@ -98,7 +98,8 @@ public class PatternVariablesCanBeReplacedWithCastInspection extends AbstractBas
PsiElement parent = current.getParent();
while (parent instanceof PsiParenthesizedExpression ||
parent instanceof PsiPolyadicExpression ||
parent instanceof PsiPrefixExpression) {
parent instanceof PsiPrefixExpression ||
parent instanceof PsiConditionalExpression) {
current = parent;
parent = current.getParent();
}
@@ -275,4 +275,9 @@ public class Simple{
System.out.println(s);
}
}
public static void ternary(Object object) {
String result = object instanceof String ? (String) object : "1";
String result2 = object instanceof String text ? text = "2" : "1";
}
}
@@ -234,4 +234,9 @@ public class Simple{
System.out.println(s);
}
}
public static void ternary(Object object) {
String result = object instanceof String text ? text : "1";
String result2 = object instanceof String text ? text = "2" : "1";
}
}
@@ -265,4 +265,9 @@ public class Simple{
System.out.println(s);
}
}
public static void ternary(Object object) {
String result = object instanceof String ? (String) object : "1";
String result2 = object instanceof String text ? text = "2" : "1";
}
}
@@ -234,4 +234,9 @@ public class Simple{
System.out.println(s);
}
}
public static void ternary(Object object) {
String result = object instanceof String text ? text : "1";
String result2 = object instanceof String text ? text = "2" : "1";
}
}