keywords are not name-elements in command-expressions

This commit is contained in:
Maxim Medvedev
2011-05-03 15:45:55 +04:00
parent 8468d4853e
commit 07b68472f0
3 changed files with 30 additions and 0 deletions
@@ -142,6 +142,7 @@ public class ExpressionStatement implements GroovyElementTypes {
private static GroovyElementType namePartParse(PsiBuilder builder, GroovyParser parser) {
if (BINARY_OP_SET.contains(builder.getTokenType())) return WRONGWAY;
if (KEYWORDS.contains(builder.getTokenType())) return WRONGWAY;
final GroovyElementType type = PathExpression.namePartParse(builder, parser);
if (type == WRONGWAY && NUMBERS.contains(builder.getTokenType())) {
builder.advanceLexer();
@@ -278,6 +278,7 @@ public class ExpressionsParsingTest extends GroovyParsingTestCase {
public void testcommandExpr$in() {doTest()}
public void testcommandExpr$as() {doTest()}
public void testcommandExpr$arrayAccess() {doTest()}
public void testcommandExpr$keywords() {doTest()}
public void testDiamond() {doTest()}
}
@@ -0,0 +1,28 @@
if (true) print "foo" else print "bar"
-----
Groovy script
IF statement
PsiElement(if)('if')
PsiWhiteSpace(' ')
PsiElement(()('(')
Literal
PsiElement(true)('true')
PsiElement())(')')
PsiWhiteSpace(' ')
Call expression
Reference expression
PsiElement(identifier)('print')
PsiWhiteSpace(' ')
Command arguments
Literal
PsiElement(Gstring)('"foo"')
PsiWhiteSpace(' ')
PsiElement(else)('else')
PsiWhiteSpace(' ')
Call expression
Reference expression
PsiElement(identifier)('print')
PsiWhiteSpace(' ')
Command arguments
Literal
PsiElement(Gstring)('"bar"')