PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) { if (!COMPARE_TO_METHODS.test(call)) return; PsiElement nameElement = call.getMethodExpression().getReferenceNameElement(); if (nameElement == null) return; final PsiExpression qualifierExpression = call.getMethodExpression().getQualifierExpression(); if (qualifierExpression == null) { return; } PsiType[] types = call.getArgumentList().getExpressionTypes(); if (types.length != 1) { return; } final PsiType argumentType = types[0]; if (argumentType == null || !argumentType.equals(qualifierExpression.getType())) { return; } PsiBinaryExpression binOp = ObjectUtils.tryCast(PsiUtil.skipParenthesizedExprUp(call.getParent()), PsiBinaryExpression.class); if (binOp == null) return; RelationType relationType = DfaPsiUtil.getRelationByToken(binOp.getOperationTokenType()); if (relationType == RelationType.IS || relationType == RelationType.IS_NOT) { return; } if (relationType == null) return; if (ExpressionUtils.isZero(binOp.getLOperand())) { relationType = relationType.getFlipped(); if (relationType == null) return; } else if (!ExpressionUtils.isZero(binOp.getROperand())) { return; } holder.registerProblem(nameElement, InspectionGadgetsBundle.message("inspection.simplifiable.compare.java.time.problem.descriptor"), new InlineCompareToTimeCallFix(relationType, argumentType.getCanonicalText())); } }; }