mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] reverts multifaceted switch labels support
This commit is contained in:
+1
-3
@@ -807,9 +807,7 @@ public class GenericsHighlightUtil {
|
||||
|
||||
if (!(resolved instanceof PsiField)) return null;
|
||||
if (!((PsiModifierListOwner)resolved).hasModifierProperty(PsiModifier.STATIC)) return null;
|
||||
if (expr.getParent() instanceof PsiExpressionList && expr.getParent().getParent() instanceof PsiSwitchLabelStatementBase) {
|
||||
return null;
|
||||
}
|
||||
if (expr.getParent() instanceof PsiSwitchLabelStatement) return null;
|
||||
final PsiMember constructorOrInitializer = PsiUtil.findEnclosingConstructorOrInitializer(expr);
|
||||
if (constructorOrInitializer == null) return null;
|
||||
if (constructorOrInitializer.hasModifierProperty(PsiModifier.STATIC)) return null;
|
||||
|
||||
+45
-71
@@ -46,7 +46,6 @@ import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.JavaPsiConstructorUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.containers.hash.HashSet;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.xml.util.XmlStringUtil;
|
||||
@@ -1851,78 +1850,63 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description).create();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static Collection<HighlightInfo> checkSwitchLabelValues(@NotNull PsiSwitchStatement switchStatement) {
|
||||
PsiCodeBlock body = switchStatement.getBody();
|
||||
if (body == null) return null;
|
||||
|
||||
PsiExpression switchExpression = switchStatement.getExpression();
|
||||
PsiType switchType = switchExpression == null ? PsiType.INT : switchExpression.getType();
|
||||
MultiMap<Object, PsiElement> values = new MultiMap<>();
|
||||
Object defaultValue = new Object();
|
||||
Collection<HighlightInfo> results = new ArrayList<>();
|
||||
boolean defaultCase = statement.isDefaultCase();
|
||||
PsiExpression caseValue = statement.getCaseValue();
|
||||
|
||||
for (PsiStatement st : body.getStatements()) {
|
||||
if (!(st instanceof PsiSwitchLabelStatementBase)) continue;
|
||||
PsiSwitchLabelStatementBase labelStatement = (PsiSwitchLabelStatementBase)st;
|
||||
boolean defaultCase = labelStatement.isDefaultCase();
|
||||
|
||||
if (defaultCase) {
|
||||
values.putValue(defaultValue, ObjectUtils.notNull(labelStatement.getFirstChild(), labelStatement));
|
||||
}
|
||||
else {
|
||||
PsiExpressionList expressionList = labelStatement.getCaseValues();
|
||||
if (expressionList != null) {
|
||||
for (PsiExpression expr : expressionList.getExpressions()) {
|
||||
if (switchExpression != null) {
|
||||
HighlightInfo result = checkAssignability(switchType, expr.getType(), expr, expr);
|
||||
if (result != null) {
|
||||
results.add(result);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Object value = null;
|
||||
if (expr instanceof PsiReferenceExpression) {
|
||||
PsiElement element = ((PsiReferenceExpression)expr).resolve();
|
||||
if (element instanceof PsiEnumConstant) {
|
||||
value = ((PsiEnumConstant)element).getName();
|
||||
if (((PsiReferenceExpression)expr).getQualifier() != null) {
|
||||
String message = JavaErrorMessages.message("qualified.enum.constant.in.switch");
|
||||
results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expr).descriptionAndTooltip(message).create());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value == null) {
|
||||
value = ConstantExpressionUtil.computeCastTo(expr, switchType);
|
||||
}
|
||||
if (value == null) {
|
||||
String description = JavaErrorMessages.message("constant.expression.required");
|
||||
results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expr).descriptionAndTooltip(description).create());
|
||||
continue;
|
||||
}
|
||||
|
||||
values.putValue(value, expr);
|
||||
// Every case constant expression associated with a switch statement must be assignable ($5.2) to the type of the switch Expression.
|
||||
if (caseValue != null && switchExpression != null) {
|
||||
HighlightInfo highlightInfo = checkAssignability(switchType, caseValue.getType(), caseValue, caseValue);
|
||||
if (highlightInfo != null) return highlightInfo;
|
||||
}
|
||||
Object value = null;
|
||||
boolean isEnumSwitch = false;
|
||||
if (!defaultCase && caseValue != null) {
|
||||
if (caseValue instanceof PsiReferenceExpression) {
|
||||
PsiElement element = ((PsiReferenceExpression)caseValue).resolve();
|
||||
if (element instanceof PsiEnumConstant) {
|
||||
isEnumSwitch = true;
|
||||
value = ((PsiEnumConstant)element).getName();
|
||||
if (((PsiReferenceExpression)caseValue).getQualifier() != null) {
|
||||
String message = JavaErrorMessages.message("qualified.enum.constant.in.switch");
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(caseValue).descriptionAndTooltip(message).create();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<Object, Collection<PsiElement>> entry : values.entrySet()) {
|
||||
if (entry.getValue().size() > 1) {
|
||||
Object value = entry.getKey();
|
||||
String description = value == defaultValue ? JavaErrorMessages.message("duplicate.default.switch.label") : JavaErrorMessages.message("duplicate.switch.label", value);
|
||||
for (PsiElement element : entry.getValue()) {
|
||||
results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create());
|
||||
}
|
||||
if (!isEnumSwitch) {
|
||||
value = ConstantExpressionUtil.computeCastTo(caseValue, switchType);
|
||||
}
|
||||
if (value == null) {
|
||||
String description = JavaErrorMessages.message("constant.expression.required");
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(caseValue).descriptionAndTooltip(description).create();
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
// check duplicate
|
||||
for (PsiStatement st : body.getStatements()) {
|
||||
if (st == statement || !(st instanceof PsiSwitchLabelStatementBase)) continue;
|
||||
PsiSwitchLabelStatementBase labelStatement = (PsiSwitchLabelStatementBase)st;
|
||||
if (labelStatement.isDefaultCase() != defaultCase) continue;
|
||||
PsiExpression caseExpr = labelStatement.getCaseValue();
|
||||
if (isEnumSwitch && caseExpr instanceof PsiReferenceExpression) {
|
||||
PsiElement element = ((PsiReferenceExpression)caseExpr).resolve();
|
||||
if (!(element instanceof PsiEnumConstant && Comparing.equal(((PsiEnumConstant)element).getName(), value))) continue;
|
||||
}
|
||||
else {
|
||||
// not assignable error already caught
|
||||
if (!TypeConversionUtil.areTypesAssignmentCompatible(switchType, caseExpr)) continue;
|
||||
if (!Comparing.equal(ConstantExpressionUtil.computeCastTo(caseExpr, switchType), value)) continue;
|
||||
}
|
||||
String description = defaultCase ? JavaErrorMessages.message("duplicate.default.switch.label") : JavaErrorMessages.message("duplicate.switch.label", value);
|
||||
PsiElement element = caseValue != null ? caseValue : ObjectUtils.notNull(statement.getFirstChild(), statement);
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2449,16 +2433,6 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
}
|
||||
classicLabels = true;
|
||||
}
|
||||
|
||||
if (!levelChecked && element instanceof PsiSwitchLabelStatementBase) {
|
||||
PsiExpressionList values = ((PsiSwitchLabelStatementBase)element).getCaseValues();
|
||||
if (values != null && values.getExpressionCount() > 1) {
|
||||
HighlightInfo info = checkFeature(values, Feature.ENHANCED_SWITCH, languageLevel, file);
|
||||
if (info != null) return info;
|
||||
levelChecked = true;
|
||||
}
|
||||
}
|
||||
|
||||
element = PsiTreeUtil.skipWhitespacesAndCommentsForward(element);
|
||||
}
|
||||
if (alien != null) {
|
||||
|
||||
-1
@@ -1595,7 +1595,6 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
super.visitSwitchStatement(statement);
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkSwitchBlockStatements(statement, myLanguageLevel, myFile));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkSwitchSelectorType(statement, myLanguageLevel));
|
||||
if (!myHolder.hasErrorResults()) myHolder.addAll(HighlightUtil.checkSwitchLabelValues(statement));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,23 +16,10 @@ public interface PsiSwitchLabelStatementBase extends PsiStatement {
|
||||
boolean isDefaultCase();
|
||||
|
||||
/**
|
||||
* Returns the constants associated with the {@code case} block,
|
||||
* Returns the constant associated with the {@code case} block,
|
||||
* or {@code null} if the statement is incomplete or the element represents a {@code default} section.
|
||||
*/
|
||||
@Nullable PsiExpressionList getCaseValues();
|
||||
|
||||
/** @deprecated doesn't support enhanced "switch" statement; use {@link #getCaseValues()} instead */
|
||||
@Deprecated
|
||||
default PsiExpression getCaseValue() {
|
||||
PsiExpressionList expressionList = getCaseValues();
|
||||
if (expressionList != null) {
|
||||
PsiExpression[] expressions = expressionList.getExpressions();
|
||||
if (expressions.length == 1) {
|
||||
return expressions[0];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Nullable PsiExpression getCaseValue();
|
||||
|
||||
/**
|
||||
* Returns the {@code switch} statement with which the section is associated,
|
||||
|
||||
@@ -466,21 +466,15 @@ public class StatementParser {
|
||||
return statement;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PsiBuilder.Marker parseSwitchLabelStatement(PsiBuilder builder) {
|
||||
PsiBuilder.Marker statement = builder.mark();
|
||||
boolean isCase = builder.getTokenType() == JavaTokenType.CASE_KEYWORD;
|
||||
builder.advanceLexer();
|
||||
|
||||
if (isCase) {
|
||||
PsiBuilder.Marker expressionList = builder.mark();
|
||||
do {
|
||||
PsiBuilder.Marker nextExpression = myParser.getExpressionParser().parseCaseLabel(builder);
|
||||
if (nextExpression == null) {
|
||||
error(builder, JavaErrorMessages.message("expected.expression"));
|
||||
}
|
||||
}
|
||||
while (expect(builder, JavaTokenType.COMMA));
|
||||
done(expressionList, JavaElementType.EXPRESSION_LIST);
|
||||
if (isCase && myParser.getExpressionParser().parseCaseLabel(builder) == null) {
|
||||
statement.rollbackTo();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (expect(builder, JavaTokenType.ARROW)) {
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ package com.intellij.psi.impl.source.tree.java;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
import com.intellij.psi.impl.source.tree.JavaElementType;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.scope.ElementClassFilter;
|
||||
import com.intellij.psi.scope.PsiScopeProcessor;
|
||||
import com.intellij.psi.scope.processor.FilterScopeProcessor;
|
||||
@@ -21,8 +21,8 @@ public abstract class PsiSwitchLabelStatementBaseImpl extends CompositePsiElemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiExpressionList getCaseValues() {
|
||||
return (PsiExpressionList)findPsiChildByType(JavaElementType.EXPRESSION_LIST);
|
||||
public PsiExpression getCaseValue() {
|
||||
return (PsiExpression)findPsiChildByType(ElementType.EXPRESSION_BIT_SET);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-13
@@ -59,19 +59,6 @@ class EnhancedSwitchStatements {
|
||||
|
||||
switch (E.valueOf("E1")) {
|
||||
case <error descr="Constant expression required">null</error> -> noop();
|
||||
case <error descr="An enum switch case label must be the unqualified name of an enumeration constant">E.E1</error> -> noop();
|
||||
case E2 -> noop();
|
||||
}
|
||||
|
||||
switch (new Random().nextInt()) {
|
||||
case <error descr="Duplicate label '1'">1</error>, <error descr="Duplicate label '1'">1</error> -> noop();
|
||||
}
|
||||
|
||||
switch (new Random().nextInt()) {
|
||||
case 1, <error descr="Duplicate label '2'">2</error>:
|
||||
noop(); break;
|
||||
case 3, <error descr="Duplicate label '2'">2</error>:
|
||||
noop(); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-3
@@ -29,9 +29,6 @@ class UnsupportedFeatures {
|
||||
<error descr="Enhanced 'switch' blocks are not supported at language level '6'">case 0 -> throw new IllegalStateException("empty list");</error>
|
||||
default -> System.out.println("it's okay");
|
||||
}
|
||||
switch (list.size()) {
|
||||
case <error descr="Enhanced 'switch' blocks are not supported at language level '6'">1, 2</error>:
|
||||
}
|
||||
}
|
||||
|
||||
void f(<error descr="Receiver parameters are not supported at language level '6'">Object this</error>) { }
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
PsiJavaFile:SwitchLabelsIncomplete0.java
|
||||
PsiSwitchLabelStatement
|
||||
PsiKeyword:case('case')
|
||||
PsiExpressionList
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiErrorElement:':' expected
|
||||
<empty list>
|
||||
PsiErrorElement:Unexpected token
|
||||
PsiKeyword:case('case')
|
||||
@@ -2,8 +2,7 @@ PsiJavaFile:SwitchLabelsIncomplete1.java
|
||||
PsiSwitchLabelStatement
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:2
|
||||
PsiJavaToken:INTEGER_LITERAL('2')
|
||||
PsiLiteralExpression:2
|
||||
PsiJavaToken:INTEGER_LITERAL('2')
|
||||
PsiErrorElement:':' expected
|
||||
<empty list>
|
||||
@@ -1,8 +0,0 @@
|
||||
PsiJavaFile:SwitchLabelsIncomplete4.java
|
||||
PsiSwitchLabelStatement
|
||||
PsiKeyword:case('case')
|
||||
PsiExpressionList
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:COLON(':')
|
||||
@@ -1,16 +0,0 @@
|
||||
PsiJavaFile:SwitchLabelsIncomplete5.java
|
||||
PsiSwitchLabelStatement
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:COLON(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiBreakStatement
|
||||
PsiKeyword:break('break')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
@@ -1,16 +0,0 @@
|
||||
PsiJavaFile:SwitchLabelsMultiple.java
|
||||
PsiSwitchLabelStatement
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiLiteralExpression:2
|
||||
PsiJavaToken:INTEGER_LITERAL('2')
|
||||
PsiJavaToken:COLON(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiBreakStatement
|
||||
PsiKeyword:break('break')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
@@ -2,9 +2,8 @@ PsiJavaFile:SwitchLabelsNormal.java
|
||||
PsiSwitchLabelStatement
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiJavaToken:COLON(':')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiBreakStatement
|
||||
|
||||
@@ -2,14 +2,13 @@ PsiJavaFile:SwitchRules10.java
|
||||
PsiSwitchLabeledRule
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiParenthesizedExpression:(b)
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiReferenceExpression:b
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:b('b')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiParenthesizedExpression:(b)
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiReferenceExpression:b
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:b('b')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
PsiJavaFile:SwitchRules11.java
|
||||
PsiSwitchLabeledRule
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiLiteralExpression:2
|
||||
PsiJavaToken:INTEGER_LITERAL('2')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiBlockStatement
|
||||
PsiCodeBlock
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -1,18 +0,0 @@
|
||||
PsiJavaFile:SwitchRules12.java
|
||||
PsiSwitchLabeledRule
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiJavaToken:COMMA(',')
|
||||
PsiErrorElement:Expression expected
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiBlockStatement
|
||||
PsiCodeBlock
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -2,9 +2,8 @@ PsiJavaFile:SwitchRules2.java
|
||||
PsiSwitchLabeledRule
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -2,9 +2,8 @@ PsiJavaFile:SwitchRules3.java
|
||||
PsiSwitchLabeledRule
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -2,9 +2,8 @@ PsiJavaFile:SwitchRules4.java
|
||||
PsiSwitchLabeledRule
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -2,9 +2,8 @@ PsiJavaFile:SwitchRules5.java
|
||||
PsiSwitchLabeledRule
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -2,9 +2,8 @@ PsiJavaFile:SwitchRules6.java
|
||||
PsiSwitchLabeledRule
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -2,9 +2,8 @@ PsiJavaFile:SwitchRules7.java
|
||||
PsiSwitchLabeledRule
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -2,9 +2,8 @@ PsiJavaFile:SwitchRules8.java
|
||||
PsiSwitchLabeledRule
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiLiteralExpression:1
|
||||
PsiJavaToken:INTEGER_LITERAL('1')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiErrorElement:Expression, block or throw statement expected
|
||||
|
||||
@@ -2,11 +2,10 @@ PsiJavaFile:SwitchRules9.java
|
||||
PsiSwitchLabeledRule
|
||||
PsiKeyword:case('case')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiExpressionList
|
||||
PsiReferenceExpression:b
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:b('b')
|
||||
PsiReferenceExpression:b
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:b('b')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ARROW('->')
|
||||
PsiWhiteSpace(' ')
|
||||
|
||||
@@ -99,13 +99,10 @@ public class StatementParserTest extends JavaParsingTestCase {
|
||||
public void testSwitchIncomplete5() { doParserTest("switch(\n foo();"); }
|
||||
|
||||
public void testSwitchLabelsNormal() { doParserTest("case 1: break; default: break;"); }
|
||||
public void testSwitchLabelsMultiple() { doParserTest("case 1, 2: break;"); }
|
||||
public void testSwitchLabelsIncomplete0() { doParserTest("case"); }
|
||||
public void testSwitchLabelsIncomplete1() { doParserTest("case 2"); }
|
||||
public void testSwitchLabelsIncomplete2() { doParserTest("default"); }
|
||||
public void testSwitchLabelsIncomplete3() { doParserTest("default 3:"); }
|
||||
public void testSwitchLabelsIncomplete4() { doParserTest("case :"); }
|
||||
public void testSwitchLabelsIncomplete5() { doParserTest("case 1, : break;"); }
|
||||
|
||||
public void testSwitchRules0() { doParserTest("default ->"); }
|
||||
public void testSwitchRules1() { doParserTest("default -> return;"); }
|
||||
@@ -118,8 +115,6 @@ public class StatementParserTest extends JavaParsingTestCase {
|
||||
public void testSwitchRules8() { doParserTest("case 1 -> ;"); }
|
||||
public void testSwitchRules9() { doParserTest("case b -> f(b);"); }
|
||||
public void testSwitchRules10() { doParserTest("case (b) -> f(b);"); }
|
||||
public void testSwitchRules11() { doParserTest("case 1, 2 -> { }"); }
|
||||
public void testSwitchRules12() { doParserTest("case 1, -> { }"); }
|
||||
|
||||
public void testSyncNormal() { doParserTest("synchronized(o){}"); }
|
||||
public void testSyncIncomplete0() { doParserTest("synchronized"); }
|
||||
|
||||
Reference in New Issue
Block a user