mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-99725 "Constant conditions & exceptions" inspection produces invalid code
This commit is contained in:
@@ -49,7 +49,15 @@ public class ReplaceWithTernaryOperatorFix implements LocalQuickFix {
|
||||
|
||||
@Override
|
||||
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
|
||||
final PsiElement element = descriptor.getPsiElement();
|
||||
PsiElement element = descriptor.getPsiElement();
|
||||
while (true) {
|
||||
PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiReferenceExpression || parent instanceof PsiMethodCallExpression) {
|
||||
element = parent;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!(element instanceof PsiExpression)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'integer != null ?:'" "true"
|
||||
|
||||
import java.lang.Integer;
|
||||
|
||||
class A{
|
||||
void test(){
|
||||
Integer integer = null;
|
||||
int i = integer != null ? integer.toString().length() : <selection>0</selection>;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'integer != null ?:'" "true"
|
||||
|
||||
import java.lang.Integer;
|
||||
|
||||
class A{
|
||||
void test(){
|
||||
Integer integer = null;
|
||||
int i = in<caret>teger.toString().length();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user