void (@NotNull PsiExpression expression) { ProgressManager.checkCanceled(); // visitLiteralExpression is invoked very often in array initializers super.visitExpression(expression); PsiElement parent = expression.getParent(); // Method expression of the call should not be especially processed if (parent instanceof PsiMethodCallExpression) return; PsiType type = expression.getType(); if (!hasErrorResults()) add(HighlightUtil.checkMustBeBoolean(expression, type)); if (!hasErrorResults() && expression instanceof PsiArrayAccessExpression) { add(HighlightUtil.checkValidArrayAccessExpression((PsiArrayAccessExpression)expression)); } if (!hasErrorResults() && parent instanceof PsiNewExpression && ((PsiNewExpression)parent).getQualifier() != expression && ((PsiNewExpression)parent).getArrayInitializer() != expression) { add(HighlightUtil.checkAssignability(PsiTypes.intType(), expression.getType(), expression, expression)); // like in 'new String["s"]' } if (!hasErrorResults()) add(HighlightControlFlowUtil.checkCannotWriteToFinal(expression, myFile)); if (!hasErrorResults()) add(HighlightUtil.checkVariableExpected(expression)); if (parent instanceof PsiArrayInitializerExpression arrayInitializer) { if (!hasErrorResults()) add(HighlightUtil.checkArrayInitializer(expression, type, arrayInitializer)); } if (!hasErrorResults()) add(HighlightUtil.checkTernaryOperatorConditionIsBoolean(expression, type)); if (!hasErrorResults()) add(HighlightUtil.checkAssertOperatorTypes(expression, type)); if (!hasErrorResults()) add(HighlightUtil.checkSynchronizedExpressionType(expression, type, myFile)); if (!hasErrorResults()) add(HighlightUtil.checkConditionalExpressionBranchTypesMatch(expression, type)); if (!hasErrorResults() && parent instanceof PsiThrowStatement && ((PsiThrowStatement)parent).getException() == expression && type != null) { add(HighlightUtil.checkMustBeThrowable(type, expression, true)); } if (!hasErrorResults()) add(AnnotationsHighlightUtil.checkConstantExpression(expression)); if (!hasErrorResults() && shouldReportForeachNotApplicable(expression)) { add(GenericsHighlightUtil.checkForeachExpressionTypeIsIterable(expression)); } }