IDEA-142416 (fixed parsing of annotated fully-qualified types in assignment statements)

This commit is contained in:
Roman Shevchenko
2015-07-09 16:29:04 +03:00
parent a73256bf9a
commit 83674908b6
4 changed files with 39 additions and 5 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -231,9 +231,9 @@ public class StatementParser {
final PsiBuilder.Marker refPos = builder.mark();
myParser.getDeclarationParser().parseAnnotations(builder);
skipQualifiedName(builder);
final IElementType suspectedLT = builder.getTokenType();
final IElementType suspectedLT = builder.getTokenType(), next = builder.lookAhead(1);
refPos.rollbackTo();
if (suspectedLT == JavaTokenType.LT) {
if (suspectedLT == JavaTokenType.LT || suspectedLT == JavaTokenType.DOT && next == JavaTokenType.AT) {
final PsiBuilder.Marker declStatement = builder.mark();
final PsiBuilder.Marker decl = myParser.getDeclarationParser().parse(builder, DeclarationParser.Context.CODE_BLOCK);
if (decl == null) {
@@ -126,7 +126,6 @@ class Outer {
}
static class This extends Super {
void superField() {
Outer.<error descr="Annotations are not allowed here">@TA</error> This.super.aField = 0;
IntFunction<Super> f = Outer.<error descr="Annotations are not allowed here">@TA</error> This.super::getField;
}
}
@@ -0,0 +1,33 @@
PsiJavaFile:LocalVar1.java
PsiDeclarationStatement
PsiLocalVariable:x
PsiModifierList:
<empty list>
PsiTypeElement:p.@A T<P>
PsiJavaCodeReferenceElement:p.@A T<P>
PsiJavaCodeReferenceElement:p
PsiIdentifier:p('p')
PsiReferenceParameterList
<empty list>
PsiJavaToken:DOT('.')
PsiAnnotation
PsiJavaToken:AT('@')
PsiJavaCodeReferenceElement:A
PsiIdentifier:A('A')
PsiReferenceParameterList
<empty list>
PsiAnnotationParameterList
<empty list>
PsiWhiteSpace(' ')
PsiIdentifier:T('T')
PsiReferenceParameterList
PsiJavaToken:LT('<')
PsiTypeElement:P
PsiJavaCodeReferenceElement:P
PsiIdentifier:P('P')
PsiReferenceParameterList
<empty list>
PsiJavaToken:GT('>')
PsiWhiteSpace(' ')
PsiIdentifier:x('x')
PsiJavaToken:SEMICOLON(';')
@@ -43,7 +43,9 @@ public class StatementParserTest extends JavaParsingTestCase {
public void testContinueNormal0() { doParserTest("continue;"); }
public void testContinueNormal1() { doParserTest("continue LABEL;"); }
public void testLocalVar() { doParserTest("List<Integer> list;"); }
public void testLocalVar0() { doParserTest("List<Integer> list;"); }
public void testLocalVar1() { doParserTest("p.@A T<P> x;"); }
public void testFor() { doParserTest("for(Iterator<String> it = null; it.hasNext();) { String s = it.next(); }"); }
public void testDoNormal() { doParserTest("do{}while(true);"); }