Simplify expressions

This commit is contained in:
Juan Martín Sotuyo Dodero
2017-06-01 11:56:48 -03:00
parent 2460402ea8
commit 0822218574
2 changed files with 33 additions and 29 deletions

View File

@ -1,4 +1,8 @@
/**
* Add support for new Java 8 annotation locations.
* Bugs #414, #415, #417
* @Snap252 06/2017
*====================================================================
* Allow empty statements (";") between package, import
* and type declarations.
* Bug #378
@ -1416,7 +1420,7 @@ void TypeParameter():
void TypeBound():
{}
{
"extends" ((Annotation() {checkForBadTypeAnnotations();})*) ClassOrInterfaceType() ( "&" ((Annotation() {checkForBadTypeAnnotations();})*) ClassOrInterfaceType() )*
"extends" (Annotation() {checkForBadTypeAnnotations();})* ClassOrInterfaceType() ( "&" (Annotation() {checkForBadTypeAnnotations();})* ClassOrInterfaceType() )*
}
void ClassOrInterfaceBody():
@ -1488,7 +1492,7 @@ void MethodDeclaration(int modifiers) :
{jjtThis.setModifiers(modifiers);}
{
[ TypeParameters() ]
[(Annotation() {checkForBadTypeAnnotations();})+] ResultType() MethodDeclarator() [ "throws" NameList() ]
(Annotation() {checkForBadTypeAnnotations();})* ResultType() MethodDeclarator() [ "throws" NameList() ]
( Block() | ";" )
}
@ -1564,9 +1568,9 @@ void Type():
void ReferenceType():
{}
{
PrimitiveType() ((Annotation() {checkForBadTypeAnnotations();})*) ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })+
PrimitiveType() (Annotation() {checkForBadTypeAnnotations();})* ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })+
|
( ClassOrInterfaceType()) ((Annotation() {checkForBadTypeAnnotations();})*) ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })*
( ClassOrInterfaceType()) (Annotation() {checkForBadTypeAnnotations();})* ( LOOKAHEAD(2) "[" "]" { jjtThis.bumpArrayDepth(); })*
}
void ClassOrInterfaceType():
@ -1939,7 +1943,7 @@ void ArrayDimsAndInits() :
{
LOOKAHEAD(2)
( LOOKAHEAD(2) ((Annotation() {checkForBadTypeAnnotations();})*) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*
( LOOKAHEAD(2) (Annotation() {checkForBadTypeAnnotations();})* "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*
|
( "[" "]" )+ ArrayInitializer()
}

View File

@ -166,33 +166,33 @@ public class ParserCornerCases18 {
}
public List<@AnnotatedUsage ?> testWildCardWithAnnotation() {
return null;
return null;
}
public Object @Nullable [] testAnnotationsToArrayElements() {
return null;
}
private byte @Nullable [] getBytes(){
return null;
}
public static <T extends @NonNull Enum<T>> T getEnum() {
return null;
}
public Object @Nullable [] testAnnotationsToArrayElements() {
return null;
}
private byte @Nullable [] getBytes(){
return null;
}
public static <T extends @NonNull Enum<?>> T getEnum() {
return null;
}
public static <T> @Nullable T getNullableEnum() {
return null;
}
public Object[] createNonNullArray() {
return new Object @NonNull[0];
}
private static void testMultiDimArrayWithAnnotations() {
// ever used a 2D-Array in java??
Object x = new Object @NonNull[2] @Nullable[1] @NonNull[3];
}
public static <T> @Nullable T getNullableEnum() {
return null;
}
public Object[] createNonNullArray() {
return new Object @NonNull[0];
}
private static void testMultiDimArrayWithAnnotations() {
// ever used a 3D-Array in java??
Object x = new Object @NonNull[2] @Nullable[1] @NonNull[3];
}
/**