[java-highlighting] Migrate fallthrough-related errors

Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: 0a2b7e91a93e8207101368c0fcfb3cf58a793203
This commit is contained in:
Tagir Valeev
2025-02-26 10:29:12 +00:00
committed by intellij-monorepo-bot
parent 1da6f5d864
commit 6d7ef89b5a
9 changed files with 220 additions and 213 deletions
@@ -0,0 +1,22 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.codeserver.core;
import com.intellij.psi.PsiExpression;
import com.intellij.psi.PsiLiteralExpression;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Nullable;
/**
* Utilities related to Java expressions
*/
public final class JavaPsiExpressionUtil {
/**
* @param expression expression to check
* @return true if the expression is a null literal (possibly parenthesized or cast)
*/
@Contract("null -> false")
public static boolean isNullLiteral(@Nullable PsiExpression expression) {
return PsiUtil.deparenthesizeExpression(expression) instanceof PsiLiteralExpression literal && literal.getValue() == null;
}
}