mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] remapping 'var' token for expressions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -551,6 +551,9 @@ public class ExpressionParser {
|
||||
tokenType = builder.getTokenType();
|
||||
}
|
||||
|
||||
if (tokenType == JavaTokenType.VAR_KEYWORD) {
|
||||
builder.remapCurrentToken(tokenType = JavaTokenType.IDENTIFIER);
|
||||
}
|
||||
if (tokenType == JavaTokenType.IDENTIFIER) {
|
||||
if (builder.lookAhead(1) == JavaTokenType.ARROW) {
|
||||
return parseLambdaExpression(builder, false);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
PsiJavaFile:ExprStatement0.java
|
||||
PsiExpressionStatement
|
||||
PsiReferenceExpression:var
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:var('var')
|
||||
PsiErrorElement:';' expected
|
||||
<empty list>
|
||||
@@ -1,10 +1,10 @@
|
||||
PsiJavaFile:LocalVar3.java
|
||||
PsiDeclarationStatement
|
||||
PsiLocalVariable:x
|
||||
PsiLocalVariable:var
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiTypeElement:var
|
||||
PsiKeyword:var('var')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:x('x')
|
||||
PsiIdentifier:var('var')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
@@ -0,0 +1,16 @@
|
||||
PsiJavaFile:LocalVar6.java
|
||||
PsiDeclarationStatement
|
||||
PsiModifierList:@A
|
||||
PsiAnnotation
|
||||
PsiJavaToken:AT('@')
|
||||
PsiJavaCodeReferenceElement:A
|
||||
PsiIdentifier:A('A')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiAnnotationParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiTypeElement:var
|
||||
PsiKeyword:var('var')
|
||||
PsiErrorElement:Identifier expected
|
||||
<empty list>
|
||||
@@ -45,9 +45,12 @@ public class StatementParserTest extends JavaParsingTestCase {
|
||||
|
||||
public void testLocalVar0() { doParserTest("List<Integer> list;"); }
|
||||
public void testLocalVar1() { doParserTest("p.@A T<P> x;"); }
|
||||
public void testLocalVar3() { doParserTest("var x;"); }
|
||||
public void testLocalVar3() { doParserTest("var var;"); }
|
||||
public void testLocalVar4() { doParserTest("final var x;"); }
|
||||
public void testLocalVar5() { doParserTest("@A var x;"); }
|
||||
public void testLocalVar6() { doParserTest("@A var"); }
|
||||
|
||||
public void testExprStatement0() { doParserTest("var"); }
|
||||
|
||||
public void testDoNormal() { doParserTest("do{}while(true);"); }
|
||||
public void testDoIncomplete0() { doParserTest("do"); }
|
||||
|
||||
Reference in New Issue
Block a user