Skip to content

Commit 763f40f

Browse files
committed
[parser] emit "expression expected" instead of "wrong expression" error #SCL-23798 fixed
1 parent 60d7fae commit 763f40f

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

scala/scala-impl/src/org/jetbrains/plugins/scala/lang/parser/parsing/builder/ScalaPsiBuilder.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,8 @@ trait ScalaPsiBuilder extends PsiBuilder {
6363
final def wrongExpressionError(): Unit = {
6464
error(ErrMsg("wrong.expression"))
6565
}
66+
67+
final def expressionExpectedError(): Unit = {
68+
error(ErrMsg("expression.expected"))
69+
}
6670
}

scala/scala-impl/src/org/jetbrains/plugins/scala/lang/parser/parsing/expressions/Enumerator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object Enumerator extends ParsingRule {
2121
case ScalaTokenTypes.tASSIGN =>
2222
builder.advanceLexer() //Ate =
2323
if (!ExprInIndentationRegion()) {
24-
builder.wrongExpressionError()
24+
builder.expressionExpectedError()
2525
}
2626
enumeratorMarker.done(ScalaElementType.FOR_BINDING)
2727
true

scala/scala-impl/src/org/jetbrains/plugins/scala/lang/parser/parsing/expressions/Generator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ object Generator extends ParsingRule {
2727
builder.advanceLexer()
2828

2929
if (!ExprInIndentationRegion()) {
30-
builder.wrongExpressionError()
30+
builder.expressionExpectedError()
3131
}
3232
genMarker.done(ScalaElementType.GENERATOR)
3333
builder.getTokenType match {

scala/scala-impl/src/org/jetbrains/plugins/scala/lang/parser/parsing/statements/FunDef.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ object FunDef extends ParsingRule {
4242
true
4343
}
4444
else {
45-
builder.wrongExpressionError()
45+
builder.expressionExpectedError()
4646
faultMarker.drop()
4747
true
4848
}
@@ -59,7 +59,7 @@ object FunDef extends ParsingRule {
5959
true
6060
}
6161
else {
62-
builder.error(ScalaBundle.message("expression.expected"))
62+
builder.expressionExpectedError()
6363
faultMarker.drop()
6464
true
6565
}

scala/scala-impl/src/org/jetbrains/plugins/scala/lang/parser/parsing/statements/PatDef.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object PatDef extends ParsingRule {
5353
builder.checkedAdvanceLexer()
5454

5555
if (!ExprInIndentationRegion()) {
56-
builder.error(ErrMsg("expression.expected"))
56+
builder.expressionExpectedError()
5757
}
5858

5959
patDefMarker.drop()

scala/scala-impl/test/org/jetbrains/plugins/scala/lang/parser/scala3/ExprParserTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,7 +2644,7 @@ class ExprParserTest extends SimpleScala3ParserTestBase {
26442644
| PsiElement(identifier)('String')
26452645
| PsiWhiteSpace(' ')
26462646
| PsiElement(=)('=')
2647-
| PsiErrorElement:Wrong expression
2647+
| PsiErrorElement:Expression expected
26482648
| <empty list>
26492649
| PsiWhiteSpace('\n\n ')
26502650
| ScPatternDefinition: value1
@@ -2764,7 +2764,7 @@ class ExprParserTest extends SimpleScala3ParserTestBase {
27642764
| PsiElement(identifier)('x')
27652765
| PsiWhiteSpace(' ')
27662766
| PsiElement(<-)('<-')
2767-
| PsiErrorElement:Wrong expression
2767+
| PsiErrorElement:Expression expected
27682768
| <empty list>
27692769
| PsiWhiteSpace(' ')
27702770
| PsiElement(})('}')
@@ -2784,7 +2784,7 @@ class ExprParserTest extends SimpleScala3ParserTestBase {
27842784
| PsiElement(identifier)('y')
27852785
| PsiWhiteSpace(' ')
27862786
| PsiElement(<-)('<-')
2787-
| PsiErrorElement:Wrong expression
2787+
| PsiErrorElement:Expression expected
27882788
| <empty list>
27892789
| PsiWhiteSpace(' ')
27902790
| PsiElement(})('}')

0 commit comments

Comments
 (0)