PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitIfStatement(@NotNull PsiIfStatement ifStatement) { PsiStatement[] thenStatements = unwrap(ifStatement.getThenBranch()); PsiStatement[] elseStatements = unwrap(ifStatement.getElseBranch()); for (IfStatementInspector inspector : ourInspectors) { IfInspectionResult result = inspector.inspect(ifStatement, thenStatements, elseStatements, isOnTheFly, IfStatementWithIdenticalBranchesInspection.this); if (result != null) { ProblemHighlightType highlightType; if (result.myIsWarning) { highlightType = ProblemHighlightType.GENERIC_ERROR_OR_WARNING; } else { if (!isOnTheFly) return; highlightType = ProblemHighlightType.INFORMATION; } LocalQuickFix[] fixes; if (myHighlightWhenLastStatementIsCall) { fixes = new LocalQuickFix[]{ LocalQuickFix.from(new UpdateInspectionOptionFix( IfStatementWithIdenticalBranchesInspection.this, "myHighlightWhenLastStatementIsCall", JavaAnalysisBundle.message("inspection.common.if.parts.disable.highlight.tail.call"), false )), result.myFix }; } else { fixes = new LocalQuickFix[] { result.myFix }; } holder.registerProblem(result.myElementToHighlight, result.myMessage, highlightType, fixes); } } } }; }