Fix duplicate ModifierList

This commit is contained in:
Clément Fournier
2020-08-23 22:00:09 +02:00
parent e8bb2c186f
commit b64042bfab
3 changed files with 11 additions and 5 deletions

View File

@ -2203,10 +2203,10 @@ void BlockStatement() #void:
// or a local variable declaration follows.
// This allows more modifiers for local variables than actually allowed
// The ModifierList is adopted by the next class to open
// The ModifierList is adopted by the next node to open
ModifierList() (
LOOKAHEAD({localTypeDeclAfterModifiers()}) LocalTypeDecl()
| LOOKAHEAD({true}) LocalVariableDeclaration() ";" { fixLastToken(); }
| LOOKAHEAD({true}) LocalVariableDeclarationPendingModifiers() ";" { fixLastToken(); }
)
| LOOKAHEAD(1, <IDENTIFIER>)
(
@ -2263,6 +2263,15 @@ void LocalVariableDeclaration() :
( "," VariableDeclarator() )*
}
void LocalVariableDeclarationPendingModifiers() #LocalVariableDeclaration:
{}
{
// no ModifierList, it's pending at this time
LocalVariableType()
VariableDeclarator()
( "," VariableDeclarator() )*
}
private void LocalVarModifierList() #ModifierList:
{Set<JModifier> set = Collections.emptySet(); }
{

View File

@ -55,7 +55,6 @@
+- Block[@Size = "5", @containsComment = "false"]
+- LocalVariableDeclaration[@TypeInferred = "false", @Visibility = "local"]
| +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"]
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"]
| +- VariableDeclarator[@Initializer = "true", @Name = "key"]
| +- VariableDeclaratorId[@ArrayType = "false", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "key", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "package"]
@ -64,7 +63,6 @@
| +- VariableAccess[@AccessType = "READ", @CompileTimeConstant = "false", @Image = "obj", @Name = "obj", @ParenthesisDepth = "0", @Parenthesized = "false"]
+- LocalVariableDeclaration[@TypeInferred = "false", @Visibility = "local"]
| +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"]
| +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| +- ClassOrInterfaceType[@FullyQualified = "false", @SimpleName = "String"]
| +- VariableDeclarator[@Initializer = "true", @Name = "value"]
| +- VariableDeclaratorId[@ArrayType = "false", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "value", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "package"]

View File

@ -96,7 +96,6 @@
| +- Block[@Size = "2", @containsComment = "false"]
| +- LocalVariableDeclaration[@TypeInferred = "false", @Visibility = "local"]
| | +- ModifierList[@EffectiveModifiers = "{final}", @ExplicitModifiers = "{final}"]
| | +- ModifierList[@EffectiveModifiers = "{}", @ExplicitModifiers = "{}"]
| | +- PrimitiveType[@Boolean = "false", @Image = "int", @ModelConstant = "int"]
| | +- VariableDeclarator[@Initializer = "true", @Name = "register"]
| | +- VariableDeclaratorId[@ArrayType = "false", @EnumConstant = "false", @ExceptionBlockParameter = "false", @Field = "false", @FormalParameter = "false", @LambdaParameter = "false", @LocalVariable = "true", @Name = "register", @PatternBinding = "false", @RecordComponent = "false", @ResourceDeclaration = "false", @TypeInferred = "false", @Visibility = "package"]