@Override public void visitInstanceOfExpression( @NotNull PsiInstanceOfExpression expression) { super.visitInstanceOfExpression(expression); final PsiTypeElement typeElement = expression.getCheckType(); if (!ConcreteClassUtil.typeIsConcreteClass(typeElement, ignoreAbstractClasses)) { return; } if (typeElement == null) { return; } registerError(typeElement); }
@Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { final PsiElement psiElement = descriptor.getPsiElement(); if(psiElement instanceof PsiInstanceOfExpression) { PsiExpression compareToNull = JavaPsiFacade.getInstance(psiElement.getProject()).getElementFactory(). createExpressionFromText(((PsiInstanceOfExpression) psiElement).getOperand().getText() + " != null", psiElement.getParent()); psiElement.replace(compareToNull); } }
@Override public void visitInstanceOfExpression(PsiInstanceOfExpression expression) { mVisitor.report("PsiInstanceOfExpression", expression.getText(), expression); super.visitExpression(expression); }