mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-02 07:47:25 +07:00
[java-highlighting] checkSwitchSelectorType migrated
Error messages unified; do not list allowed switch types anymore Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only) GitOrigin-RevId: 69675af87ac8866fb5ba1475094b93af07aa1ad5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
16c58ccd5d
commit
cb626d5749
@@ -54,8 +54,6 @@ unexpected.type=Unexpected type. Found: ''{1}'', required: ''{0}''
|
||||
incompatible.types.reason.ambiguous.method.reference=<br/>reason: method reference is ambiguous: both ''{0}'' and ''{1}'' match
|
||||
incompatible.switch.null.type=''{0}'' cannot be converted to ''{1}''
|
||||
inaccessible.type=''{0}'' is inaccessible from here
|
||||
valid.switch.selector.types=byte, char, short or int
|
||||
valid.switch.1_7.selector.types=char, byte, short, int, Character, Byte, Short, Integer, String, or an enum
|
||||
switch.illegal.fall.through.to=Illegal fall-through to a pattern
|
||||
invalid.case.label.combination.constants.and.patterns=Invalid case label combination: a case label must consist of either a list of case constants or a single case pattern
|
||||
invalid.case.label.combination.constants.and.patterns.unnamed=Invalid case label combination: a case label must consist of either a list of case constants or a list of case patterns
|
||||
|
||||
@@ -89,8 +89,11 @@ public final class JavaPsiSwitchUtil {
|
||||
/**
|
||||
* Returns the selector kind based on the type.
|
||||
* <p>
|
||||
* It's not checked whether this particular kind is supported at a given location
|
||||
* (the method does not have location information anyway).
|
||||
* The result may depend on type language level for boxed primitive types.
|
||||
* E.g., if selector type is {@link Double} then {@link SelectorKind#DOUBLE} will be returned
|
||||
* if primitives in patterns are supported, but {@link SelectorKind#CLASS_OR_ARRAY} will be returned otherwise.
|
||||
* <p>
|
||||
* It's not checked whether this particular kind is supported at a given location.
|
||||
* It's up to the caller to check this using the {@link SelectorKind#getFeature()} method.
|
||||
*
|
||||
* @param selectorType type of switch selector expression
|
||||
@@ -100,7 +103,9 @@ public final class JavaPsiSwitchUtil {
|
||||
if (TypeConversionUtil.getTypeRank(selectorType) <= TypeConversionUtil.INT_RANK) {
|
||||
return SelectorKind.INT;
|
||||
}
|
||||
PsiType unboxedType = PsiPrimitiveType.getOptionallyUnboxedType(selectorType);
|
||||
PsiType unboxedType = selectorType instanceof PsiClassType &&
|
||||
JavaFeature.PRIMITIVE_TYPES_IN_PATTERNS.isSufficient(((PsiClassType)selectorType).getLanguageLevel()) ?
|
||||
PsiPrimitiveType.getOptionallyUnboxedType(selectorType) : selectorType;
|
||||
if (unboxedType != null) {
|
||||
if (unboxedType.equals(PsiTypes.longType())) {
|
||||
return SelectorKind.LONG;
|
||||
|
||||
Reference in New Issue
Block a user