mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
New Java parser (expression parsing fixed)
This commit is contained in:
@@ -216,7 +216,7 @@ public class ExpressionParser {
|
||||
}
|
||||
|
||||
final PsiBuilder.Marker expression = left.precede();
|
||||
builder.advanceLexer();
|
||||
advanceGtToken(builder, tokenType);
|
||||
|
||||
final PsiBuilder.Marker right = parseExpression(builder, toParse);
|
||||
if (right == null) {
|
||||
@@ -801,6 +801,9 @@ public class ExpressionParser {
|
||||
tokenType = JavaTokenType.GTGT;
|
||||
}
|
||||
}
|
||||
else if (builder.getTokenType() == JavaTokenType.EQ) {
|
||||
tokenType = JavaTokenType.GE;
|
||||
}
|
||||
}
|
||||
|
||||
sp.rollbackTo();
|
||||
@@ -822,6 +825,9 @@ public class ExpressionParser {
|
||||
else if (type == JavaTokenType.GTGT) {
|
||||
PsiBuilderUtil.advance(builder, 2);
|
||||
}
|
||||
else if (type == JavaTokenType.GE) {
|
||||
PsiBuilderUtil.advance(builder, 2);
|
||||
}
|
||||
else {
|
||||
gtToken.drop();
|
||||
builder.advanceLexer();
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
public class SystemInfo {
|
||||
public static final boolean isKDE = SUN_DESKTOP != null && SUN_DESKTOP.toLowerCase().indexOf("kde") >= 0;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
PsiJavaFile:ComplexInitializer.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiClass:SystemInfo
|
||||
PsiModifierList:public
|
||||
PsiKeyword:public('public')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:class('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:SystemInfo('SystemInfo')
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiField:isKDE
|
||||
PsiModifierList:public static final
|
||||
PsiKeyword:public('public')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:static('static')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiKeyword:final('final')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiTypeElement:boolean
|
||||
PsiKeyword:boolean('boolean')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:isKDE('isKDE')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:EQ('=')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiBinaryExpression:SUN_DESKTOP != null && SUN_DESKTOP.toLowerCase().indexOf("kde") >= 0
|
||||
PsiBinaryExpression:SUN_DESKTOP != null
|
||||
PsiReferenceExpression:SUN_DESKTOP
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:SUN_DESKTOP('SUN_DESKTOP')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:NE('!=')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiLiteralExpression:null
|
||||
PsiJavaToken:NULL_KEYWORD('null')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:ANDAND('&&')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiBinaryExpression:SUN_DESKTOP.toLowerCase().indexOf("kde") >= 0
|
||||
PsiMethodCallExpression:SUN_DESKTOP.toLowerCase().indexOf("kde")
|
||||
PsiReferenceExpression:SUN_DESKTOP.toLowerCase().indexOf
|
||||
PsiMethodCallExpression:SUN_DESKTOP.toLowerCase()
|
||||
PsiReferenceExpression:SUN_DESKTOP.toLowerCase
|
||||
PsiReferenceExpression:SUN_DESKTOP
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:SUN_DESKTOP('SUN_DESKTOP')
|
||||
PsiJavaToken:DOT('.')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:toLowerCase('toLowerCase')
|
||||
PsiExpressionList
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiJavaToken:DOT('.')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:indexOf('indexOf')
|
||||
PsiExpressionList
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiLiteralExpression:"kde"
|
||||
PsiJavaToken:STRING_LITERAL('"kde"')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:GE('>=')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiLiteralExpression:0
|
||||
PsiJavaToken:INTEGER_LITERAL('0')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -1,4 +1,4 @@
|
||||
PsiJavaFile:GE.java
|
||||
PsiJavaFile:GE0.java
|
||||
PsiAssignmentExpression:x >>>= 8 >> 2
|
||||
PsiReferenceExpression:x
|
||||
PsiReferenceParameterList
|
||||
@@ -0,0 +1,11 @@
|
||||
PsiJavaFile:GE1.java
|
||||
PsiBinaryExpression:x >= 2
|
||||
PsiReferenceExpression:x
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiIdentifier:x('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:GE('>=')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiLiteralExpression:2
|
||||
PsiJavaToken:INTEGER_LITERAL('2')
|
||||
@@ -19,4 +19,6 @@ public class FieldParsingTest extends JavaParsingTestCase {
|
||||
public void testMissingInitializerExpression() { doTest(true); }
|
||||
|
||||
public void testMultiLineUnclosed() { doTest(true); }
|
||||
|
||||
public void testComplexInitializer() { doTest(true); }
|
||||
}
|
||||
@@ -88,7 +88,8 @@ public class ExpressionParserTest extends JavaParsingTestCase {
|
||||
public void testPinesInReferenceExpression0() { doParserTest("Collections.<String>sort(null)"); }
|
||||
public void testPinesInReferenceExpression1() { doParserTest("this.<String>sort(null)"); }
|
||||
|
||||
public void testGE() { doParserTest("x >>>= 8 >> 2"); }
|
||||
public void testGE0() { doParserTest("x >>>= 8 >> 2"); }
|
||||
public void testGE1() { doParserTest("x >= 2"); }
|
||||
|
||||
public void testIncompleteCast() { doParserTest("f((ArrayList<String>) )"); }
|
||||
public void testShiftRight() { doParserTest("x >>= 2"); }
|
||||
|
||||
Reference in New Issue
Block a user