switch selector error message (IDEA-123937)

This commit is contained in:
Anna Kozlova
2014-04-14 19:35:18 +02:00
parent 964735c32a
commit 8195023646
2 changed files with 6 additions and 3 deletions
@@ -1323,10 +1323,12 @@ public class HighlightUtil extends HighlightUtilBase {
return null;
}
HighlightInfo errorResult = null;
if (!isValidTypeForSwitchSelector(type, PsiUtil.isLanguageLevel7OrHigher(expression))) {
final boolean atLeastJava7 = PsiUtil.isLanguageLevel7OrHigher(expression);
if (!isValidTypeForSwitchSelector(type, atLeastJava7)) {
final String switchSelectorMessage = atLeastJava7 ? JavaErrorMessages.message("valid.switch.17.selector.types")
: JavaErrorMessages.message("valid.switch.selector.types");
String message =
JavaErrorMessages.message("incompatible.types", JavaErrorMessages.message("valid.switch.selector.types"), JavaHighlightUtil.formatType(
type));
JavaErrorMessages.message("incompatible.types", switchSelectorMessage, JavaHighlightUtil.formatType(type));
errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create();
QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createConvertSwitchToIfIntention(statement));
if (PsiType.LONG.equals(type) || PsiType.FLOAT.equals(type) || PsiType.DOUBLE.equals(type)) {
@@ -220,6 +220,7 @@ not.a.statement=Not a statement
invalid.statement=Invalid statement
incompatible.types=Incompatible types. Found: ''{1}'', required: ''{0}''
valid.switch.selector.types=byte, char, short or int
valid.switch.17.selector.types=char, byte, short, int, Character, Byte, Short, Integer, String, or an enum
dot.expected.after.super.or.this='.' expected
unqualified.super.disallowed=Unqualified super reference is not allowed in extension method