mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
New Java parser - diamonds support
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
{
|
||||
new A<>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
PsiJavaFile:New15.java
|
||||
PsiImportList
|
||||
<empty list>
|
||||
PsiClass:Foo
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiKeyword:class('class')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiIdentifier:Foo('Foo')
|
||||
PsiTypeParameterList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiReferenceList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiClassInitializer
|
||||
PsiModifierList:
|
||||
<empty list>
|
||||
PsiCodeBlock
|
||||
PsiJavaToken:LBRACE('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiExpressionStatement
|
||||
PsiNewExpression:new A<>()
|
||||
PsiKeyword:new('new')
|
||||
PsiReferenceParameterList
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiJavaCodeReferenceElement:A<>
|
||||
PsiIdentifier:A('A')
|
||||
PsiReferenceParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeElement:
|
||||
PsiElement(DIAMOND_TYPE)
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
PsiExpressionList
|
||||
PsiJavaToken:LPARENTH('(')
|
||||
PsiJavaToken:RPARENTH(')')
|
||||
PsiJavaToken:SEMICOLON(';')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiJavaToken:RBRACE('}')
|
||||
@@ -0,0 +1,10 @@
|
||||
PsiJavaFile:Type7.java
|
||||
PsiTypeElement:Diamond<>
|
||||
PsiJavaCodeReferenceElement:Diamond<>
|
||||
PsiIdentifier:Diamond('Diamond')
|
||||
PsiReferenceParameterList
|
||||
PsiJavaToken:LT('<')
|
||||
PsiTypeElement:
|
||||
PsiElement(DIAMOND_TYPE)
|
||||
<empty list>
|
||||
PsiJavaToken:GT('>')
|
||||
@@ -16,6 +16,8 @@
|
||||
package com.intellij.lang.java.parser;
|
||||
|
||||
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
|
||||
public class ExpressionParsingTest extends JavaParsingTestCase {
|
||||
|
||||
public ExpressionParsingTest() {
|
||||
@@ -73,6 +75,10 @@ public class ExpressionParsingTest extends JavaParsingTestCase {
|
||||
public void testNew12() { doTest(true); }
|
||||
public void testNew13() { doTest(true); }
|
||||
public void testNew14() { doTest(true); }
|
||||
public void testNew15() {
|
||||
withLevel(LanguageLevel.JDK_1_7,
|
||||
new Runnable() { public void run() { doTest(true); } });
|
||||
}
|
||||
|
||||
public void testExprList0() { doTest(true); }
|
||||
public void testExprList1() { doTest(true); }
|
||||
|
||||
+7
-3
@@ -40,6 +40,7 @@ public class ReferenceParserTest extends JavaParsingTestCase {
|
||||
withLevel(LanguageLevel.JDK_1_7,
|
||||
new Runnable() { public void run() { doTypeParserTest("@English String @NonEmpty []", false); } });
|
||||
}
|
||||
public void testType7() { doTypeParserTest("Diamond<>", true); }
|
||||
|
||||
public void testTypeParams0() { doTypeParamsParserTest("<T>"); }
|
||||
public void testTypeParams1() { doTypeParamsParserTest("<T, U>"); }
|
||||
@@ -53,15 +54,18 @@ public class ReferenceParserTest extends JavaParsingTestCase {
|
||||
private void doRefParserTest(final String text, final boolean incomplete) {
|
||||
doParserTest(text, new TestParser() {
|
||||
public void parse(final PsiBuilder builder) {
|
||||
ReferenceParser.parseJavaCodeReference(builder, incomplete, false, false);
|
||||
ReferenceParser.parseJavaCodeReference(builder, incomplete, false, false, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doTypeParserTest(final String text, final boolean incomplete) {
|
||||
private void doTypeParserTest(final String text, final boolean diamonds) {
|
||||
doParserTest(text, new TestParser() {
|
||||
public void parse(final PsiBuilder builder) {
|
||||
ReferenceParser.parseTypeWithEllipsis(builder, incomplete, false);
|
||||
if (diamonds)
|
||||
ReferenceParser.parseType(builder, false, false, true);
|
||||
else
|
||||
ReferenceParser.parseTypeWithEllipsis(builder, false, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user