[java] fixes diamond type parsing (IDEA-155900)

This commit is contained in:
Roman Shevchenko
2016-05-12 16:01:20 +02:00
parent 1b334ab228
commit 8fd03f4731
3 changed files with 27 additions and 2 deletions
@@ -118,7 +118,13 @@ public class ReferenceParser {
parseJavaCodeReference(builder, isSet(flags, EAT_LAST_DOT), true, false, false, false, isSet(flags, DIAMONDS), typeInfo);
}
else if (isSet(flags, DIAMONDS) && tokenType == JavaTokenType.GT) {
emptyElement(builder, JavaElementType.DIAMOND_TYPE);
if (anno == null) {
emptyElement(builder, JavaElementType.DIAMOND_TYPE);
}
else {
error(builder, JavaErrorMessages.message("expected.identifier"));
typeInfo.hasErrors = true;
}
type.done(JavaElementType.TYPE);
typeInfo.marker = type;
return typeInfo;
@@ -0,0 +1,18 @@
PsiJavaFile:Type10.java
PsiTypeElement:Diamond<@TA>
PsiJavaCodeReferenceElement:Diamond<@TA>
PsiIdentifier:Diamond('Diamond')
PsiReferenceParameterList
PsiJavaToken:LT('<')
PsiTypeElement:@TA
PsiAnnotation
PsiJavaToken:AT('@')
PsiJavaCodeReferenceElement:TA
PsiIdentifier:TA('TA')
PsiReferenceParameterList
<empty list>
PsiAnnotationParameterList
<empty list>
PsiErrorElement:Identifier expected
<empty list>
PsiJavaToken:GT('>')
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -39,6 +39,7 @@ public class ReferenceParserTest extends JavaParsingTestCase {
public void testType7() { doTypeParserTest("Diamond<>"); }
public void testType8() { doTypeParserTest("A|"); }
public void testType9() { doTypeParserTest("A|B"); }
public void testType10() { doTypeParserTest("Diamond<@TA>"); }
public void testTypeParams0() { doTypeParamsParserTest("<T>"); }
public void testTypeParams1() { doTypeParamsParserTest("<T, U>"); }