mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
add assert != null fix should be disabled on the class level (EA-66814 - assert: AddAssertStatementFix.applyFix)
This commit is contained in:
+2
-2
@@ -200,7 +200,7 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool {
|
||||
final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
|
||||
final PsiBinaryExpression binary = (PsiBinaryExpression)elementFactory.createExpressionFromText("a != null", null);
|
||||
binary.getLOperand().replace(qualifier);
|
||||
ContainerUtil.addIfNotNull(fixes, createAssertFix(binary));
|
||||
ContainerUtil.addIfNotNull(fixes, createAssertFix(binary, expression));
|
||||
}
|
||||
|
||||
addSurroundWithIfFix(qualifier, fixes, onTheFly);
|
||||
@@ -216,7 +216,7 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool {
|
||||
}
|
||||
}
|
||||
|
||||
protected LocalQuickFix createAssertFix(PsiBinaryExpression binary) {
|
||||
protected LocalQuickFix createAssertFix(PsiBinaryExpression binary, PsiExpression expression) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.psi.PsiAssignmentExpression;
|
||||
import com.intellij.psi.PsiBinaryExpression;
|
||||
import com.intellij.psi.PsiExpression;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
@@ -59,8 +60,8 @@ public class DataFlowInspection extends DataFlowInspectionBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AddAssertStatementFix createAssertFix(PsiBinaryExpression binary) {
|
||||
return new AddAssertStatementFix(binary);
|
||||
protected AddAssertStatementFix createAssertFix(PsiBinaryExpression binary, PsiExpression expression) {
|
||||
return RefactoringUtil.getParentStatement(expression, false) == null ? null : new AddAssertStatementFix(binary);
|
||||
}
|
||||
|
||||
private class OptionsPanel extends JPanel {
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// "Assert 'myFoo != null'" "false"
|
||||
class A{
|
||||
private final String myFoo = null;
|
||||
String myBar = my<caret>Foo.substring(0);
|
||||
}
|
||||
Reference in New Issue
Block a user