mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-22 14:31:25 +07:00
Java: fix false positive on reference to enum constant (IDEA-357156)
GitOrigin-RevId: 7c833e46823ab41c9bdf275308ccee226d7e1a5f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5c96c794ed
commit
24aaef624d
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.siyeh.ig.style;
|
||||
|
||||
import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool;
|
||||
@@ -64,7 +64,7 @@ public final class ConstantExpressionInspection extends AbstractBaseJavaLocalIns
|
||||
// inspection disabled for long expressions because of performance issues on
|
||||
// relatively common large string expressions.
|
||||
Object value = computeConstant(expression);
|
||||
if (value == null) return;
|
||||
if (value == null || value instanceof Enum<?>) return;
|
||||
if (value instanceof PsiField && !(value instanceof PsiEnumConstant)) return;
|
||||
if (value instanceof PsiElement e && expression instanceof PsiReferenceExpression ref && ref.isReferenceTo(e)) return;
|
||||
String valueText = getValueText(value);
|
||||
@@ -99,7 +99,7 @@ public final class ConstantExpressionInspection extends AbstractBaseJavaLocalIns
|
||||
if (expression instanceof PsiClassObjectAccessExpression) return null;
|
||||
try {
|
||||
Object value = ExpressionUtils.computeConstantExpression(expression, true);
|
||||
if (value != null && !(value instanceof Enum<?>)) {
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Fix all 'Constant expression can be evaluated' problems in file" "false"
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(Retention<caret>Policy.RUNTIME)
|
||||
@interface Ann {}
|
||||
Reference in New Issue
Block a user