diff --git a/pmd-java/etc/grammar/Java.jjt b/pmd-java/etc/grammar/Java.jjt index 5264cea500..960c45c9d4 100644 --- a/pmd-java/etc/grammar/Java.jjt +++ b/pmd-java/etc/grammar/Java.jjt @@ -1945,7 +1945,8 @@ Dims: * * See https://docs.oracle.com/javase/specs/jls/se10/html/jls-8.html#jls-UnannType */ -void Type(): +// TODO make void +void Type() #void: { Token t; } @@ -1971,7 +1972,8 @@ void ArrayTypeDim(): (TypeAnnotation())* "[" "]" } -void ReferenceType(): +// TODO make void +void ReferenceType() #void: {} { @@ -2018,6 +2020,22 @@ void WildcardBounds(): ("extends" | "super") (TypeAnnotation())* ReferenceType() } +/* JLS https://docs.oracle.com/javase/specs/jls/se10/html/jls-4.html#jls-PrimitiveType + +PrimitiveType: + {Annotation} NumericType + {Annotation} boolean +NumericType: + IntegralType + FloatingPointType +IntegralType: + (one of) + byte short int long char +FloatingPointType: + (one of) + float double +*/ + void PrimitiveType() : {} { diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTReferenceType.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTReferenceType.java index 74f56040b5..9373a886e3 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTReferenceType.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTReferenceType.java @@ -7,66 +7,15 @@ package net.sourceforge.pmd.lang.java.ast; /** * Represents a reference type, i.e. a {@linkplain ASTClassOrInterfaceType class or interface type}, - * or an array type. + * or an {@linkplain ASTArrayType array type}. * *
* - * ReferenceType ::= {@linkplain ASTPrimitiveType PrimitiveType} {@linkplain ASTAnnotation Annotation}* ( "[" "]" )+ - * | {@linkplain ASTClassOrInterfaceType ClassOrInterfaceType} {@linkplain ASTAnnotation Annotation}* ( "[" "]" )* + * ReferenceType ::= {@linkplain ASTClassOrInterfaceType ClassOrInterfaceType} + * | {@linkplain ASTArrayType} * *- * */ -public class ASTReferenceType extends AbstractJavaTypeNode implements Dimensionable { - - private int arrayDepth; - - public ASTReferenceType(int id) { - super(id); - } - - public ASTReferenceType(JavaParser p, int id) { - super(p, id); - } - - /** - * Accept the visitor. * - */ - @Override - public Object jjtAccept(JavaParserVisitor visitor, Object data) { - return visitor.visit(this, data); - } - - - @Override - public
* - * Type ::= {@linkplain ASTReferenceType ReferenceType} | {@linkplain ASTPrimitiveType PrimitiveType} + * Type ::= {@linkplain ASTReferenceType ReferenceType} + * | {@linkplain ASTPrimitiveType PrimitiveType} * ** * Note: it is not exactly the same the "UnnanType" defined in JLS. */ -public class ASTType extends AbstractJavaTypeNode { - public ASTType(int id) { - super(id); - } - - public ASTType(JavaParser p, int id) { - super(p, id); - } - - /** - * Accept the visitor. * - */ - @Override - public Object jjtAccept(JavaParserVisitor visitor, Object data) { - return visitor.visit(this, data); - } - - - @Override - public