[java] Rename ASTClassOrInterfaceType to ASTClassType

This commit is contained in:
Andreas Dangel
2023-12-12 15:55:04 +01:00
parent 33c0d20f98
commit 698ca0d3ff
119 changed files with 1881 additions and 1884 deletions

View File

@ -393,6 +393,7 @@ which can also display the AST.
#### Renamed classes / interfaces
* AccessNode ➡️ {% jdoc jast::ModifierOwner %}
* ClassOrInterfaceType ➡️ ClassType ({% jdoc jast::ASTClassType %})
#### Annotations

View File

@ -166,6 +166,8 @@ The following previously deprecated classes have been removed:
* pmd-java
* The interface `AccessNode` has been renamed to {% jdoc java::lang.ast.ModifierOwner %}. This is only relevant
for Java rules, which use that type directly e.g. through downcasting.
* The node `ASTClassOrInterfaceType` has been renamed to {% jdoc java::lang.ast.ASTClassType %}. XPath rules
need to be adjusted.
**Deprecated classes and methods**

View File

@ -1684,7 +1684,7 @@ void ClassOrInterfaceType() #void:
// a type name, otherwise it wouldn't have compiled. So it's not ambiguous and we can
// start fresh: "@B Map.Entry" will be unambiguously [[@B Map].Entry]
(<IDENTIFIER> {setLastTokenImage(jjtThis);} [ TypeArguments() ]) #ClassOrInterfaceType
(<IDENTIFIER> {setLastTokenImage(jjtThis);} [ TypeArguments() ]) #ClassType
|
@ -1694,13 +1694,13 @@ void ClassOrInterfaceType() #void:
// be sure that the last segment is a type name.
AmbiguousName()
[ TypeArguments() #ClassOrInterfaceType(2) ]
[ TypeArguments() #ClassType(2) ]
{
// At this point the first ClassOrInterfaceType may be on top of the stack,
// but its image is not set. If it is on the stack we need to shrink the bounds
// of the ambiguous name, or delete it.
Node first = jjtree.peekNode();
if (first instanceof ASTClassOrInterfaceType) {
if (first instanceof ASTClassType) {
// then we saw type arguments, so the last segment is definitely a type name
ASTAmbiguousName name = first.getFirstChildOfType(ASTAmbiguousName.class);
name.shrinkOrDeleteInParentSetImage();
@ -1720,7 +1720,7 @@ void ClassOrInterfaceType() #void:
{ forceTypeContext(); }
}
private void ClassTypeSegment() #ClassOrInterfaceType(jjtree.nodeArity() + 1):
private void ClassTypeSegment() #ClassType(jjtree.nodeArity() + 1):
{}
{
TypeAnnotListNoInject()

View File

@ -117,14 +117,14 @@ public final class ASTAmbiguousName extends AbstractJavaExpr implements ASTRefer
/**
* Called by the parser if this ambiguous name was expected to be
* a type name. Then we simply promote it to an {@link ASTClassOrInterfaceType}
* a type name. Then we simply promote it to an {@link ASTClassType}
* with the appropriate LHS.
*
* @return the node which will replace this node in the tree
*/
ASTClassOrInterfaceType forceTypeContext() {
ASTClassType forceTypeContext() {
// same, there's no parent here
return shrinkOneSegment(ASTClassOrInterfaceType::new, ASTClassOrInterfaceType::new);
return shrinkOneSegment(ASTClassType::new, ASTClassType::new);
}

View File

@ -18,7 +18,7 @@ import net.sourceforge.pmd.lang.java.types.JClassType;
*
* <pre class="grammar">
*
* Annotation ::= "@" {@link ASTClassOrInterfaceType ClassName} {@link ASTAnnotationMemberList AnnotationMemberList}?
* Annotation ::= "@" {@link ASTClassType ClassName} {@link ASTAnnotationMemberList AnnotationMemberList}?
*
* </pre>
*/
@ -32,8 +32,8 @@ public final class ASTAnnotation extends AbstractJavaTypeNode implements TypeNod
/**
* Returns the node that represents the name of the annotation.
*/
public ASTClassOrInterfaceType getTypeNode() {
return (ASTClassOrInterfaceType) getChild(0);
public ASTClassType getTypeNode() {
return (ASTClassType) getChild(0);
}
@Override

View File

@ -42,7 +42,7 @@ public final class ASTAnonymousClassDeclaration extends AbstractAnyTypeDeclarati
}
@Override
public @NonNull NodeStream<ASTClassOrInterfaceType> getSuperInterfaceTypeNodes() {
public @NonNull NodeStream<ASTClassType> getSuperInterfaceTypeNodes() {
if (getParent() instanceof ASTConstructorCall) {
ASTConstructorCall ctor = (ASTConstructorCall) getParent();
@NonNull JTypeMirror type = ctor.getTypeMirror();

View File

@ -288,7 +288,7 @@ public interface ASTAnyTypeDeclaration
* Returns the list of interfaces implemented by this class, or
* extended by this interface. Returns null if no such list is declared.
*/
default @NonNull NodeStream<ASTClassOrInterfaceType> getSuperInterfaceTypeNodes() {
default @NonNull NodeStream<ASTClassType> getSuperInterfaceTypeNodes() {
return ASTList.orEmptyStream(isInterface() ? firstChild(ASTExtendsList.class)
: firstChild(ASTImplementsList.class));
}

View File

@ -12,7 +12,7 @@ import net.sourceforge.pmd.lang.ast.NodeStream;
* <pre class="grammar">
*
* ArrayType ::= {@link ASTPrimitiveType PrimitiveType} {@link ASTArrayDimensions ArrayDimensions}
* | {@link ASTClassOrInterfaceType ClassOrInterfaceType} {@link ASTArrayDimensions ArrayDimensions}
* | {@link ASTClassType ClassOrInterfaceType} {@link ASTArrayDimensions ArrayDimensions}
*
* </pre>
*/

View File

@ -79,12 +79,12 @@ public final class ASTCatchParameter extends AbstractJavaNode
* Since exception types cannot be interfaces, the LUB always erases
* to a single class supertype (eg {@link RuntimeException}).
*/
public NodeStream<ASTClassOrInterfaceType> getAllExceptionTypes() {
public NodeStream<ASTClassType> getAllExceptionTypes() {
ASTType typeNode = getTypeNode();
if (typeNode instanceof ASTUnionType) {
return typeNode.children(ASTClassOrInterfaceType.class);
return typeNode.children(ASTClassType.class);
} else {
return NodeStream.of((ASTClassOrInterfaceType) typeNode);
return NodeStream.of((ASTClassType) typeNode);
}
}

View File

@ -75,7 +75,7 @@ public final class ASTClassOrInterfaceDeclaration extends AbstractAnyTypeDeclara
*
* <p>Returns {@code null} otherwise.
*/
public ASTClassOrInterfaceType getSuperClassTypeNode() {
public ASTClassType getSuperClassTypeNode() {
if (isInterface()) {
return null;
}
@ -85,7 +85,7 @@ public final class ASTClassOrInterfaceDeclaration extends AbstractAnyTypeDeclara
}
public List<ASTClassOrInterfaceType> getPermittedSubclasses() {
public List<ASTClassType> getPermittedSubclasses() {
return ASTList.orEmpty(children(ASTPermitsList.class).first());
}
}

View File

@ -26,12 +26,14 @@ import net.sourceforge.pmd.util.AssertionUtil;
*
* </pre>
*
* <p>Note: This node was called ASTClassOrInterfaceType in PMD 6.
*
* @implNote
* The parser may produce an AmbiguousName for the qualifier.
* This is systematically removed by the disambiguation phase.
*/
// @formatter:on
public final class ASTClassOrInterfaceType extends AbstractJavaTypeNode implements ASTReferenceType {
public final class ASTClassType extends AbstractJavaTypeNode implements ASTReferenceType {
// todo rename to ASTClassType
private JTypeDeclSymbol symbol;
@ -43,8 +45,8 @@ public final class ASTClassOrInterfaceType extends AbstractJavaTypeNode implemen
private boolean isFqcn;
private JClassType implicitEnclosing;
ASTClassOrInterfaceType(ASTAmbiguousName lhs, String simpleName) {
super(JavaParserImplTreeConstants.JJTCLASSORINTERFACETYPE);
ASTClassType(ASTAmbiguousName lhs, String simpleName) {
super(JavaParserImplTreeConstants.JJTCLASSTYPE);
assert lhs != null : "Null LHS";
this.addChild(lhs, 0);
@ -53,8 +55,8 @@ public final class ASTClassOrInterfaceType extends AbstractJavaTypeNode implemen
}
ASTClassOrInterfaceType(ASTAmbiguousName simpleName) {
super(JavaParserImplTreeConstants.JJTCLASSORINTERFACETYPE);
ASTClassType(ASTAmbiguousName simpleName) {
super(JavaParserImplTreeConstants.JJTCLASSTYPE);
this.simpleName = simpleName.getFirstToken().getImage();
assertSimpleNameOk();
@ -62,13 +64,13 @@ public final class ASTClassOrInterfaceType extends AbstractJavaTypeNode implemen
// Just for one usage in Symbol table
@Deprecated
public ASTClassOrInterfaceType(String simpleName) {
super(JavaParserImplTreeConstants.JJTCLASSORINTERFACETYPE);
public ASTClassType(String simpleName) {
super(JavaParserImplTreeConstants.JJTCLASSTYPE);
this.simpleName = simpleName;
}
ASTClassOrInterfaceType(@Nullable ASTClassOrInterfaceType lhs, boolean isFqcn, JavaccToken firstToken, JavaccToken identifier) {
super(JavaParserImplTreeConstants.JJTCLASSORINTERFACETYPE);
ASTClassType(@Nullable ASTClassType lhs, boolean isFqcn, JavaccToken firstToken, JavaccToken identifier) {
super(JavaParserImplTreeConstants.JJTCLASSTYPE);
this.setImage(identifier.getImage());
this.isFqcn = isFqcn;
if (lhs != null) {
@ -79,7 +81,7 @@ public final class ASTClassOrInterfaceType extends AbstractJavaTypeNode implemen
}
ASTClassOrInterfaceType(int id) {
ASTClassType(int id) {
super(id);
}
@ -141,8 +143,8 @@ public final class ASTClassOrInterfaceType extends AbstractJavaTypeNode implemen
* @return A type, or null if this is a base type
*/
@Nullable
public ASTClassOrInterfaceType getQualifier() {
return getFirstChildOfType(ASTClassOrInterfaceType.class);
public ASTClassType getQualifier() {
return getFirstChildOfType(ASTClassType.class);
}
/**

View File

@ -18,7 +18,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* | {@link ASTExpression Expression} "." UnqualifiedAlloc
*
* UnqualifiedAlloc ::=
* "new" {@link ASTTypeArguments TypeArguments}? {@link ASTClassOrInterfaceType ClassOrInterfaceType} {@link ASTArgumentList ArgumentList} {@link ASTAnonymousClassDeclaration AnonymousClassDeclaration}?
* "new" {@link ASTTypeArguments TypeArguments}? {@link ASTClassType ClassType} {@link ASTArgumentList ArgumentList} {@link ASTAnonymousClassDeclaration AnonymousClassDeclaration}?
*
* </pre>
*/
@ -86,8 +86,8 @@ public final class ASTConstructorCall extends AbstractInvocationExpr
/**
* Returns the type node.
*/
public ASTClassOrInterfaceType getTypeNode() {
return getFirstChildOfType(ASTClassOrInterfaceType.class);
public ASTClassType getTypeNode() {
return getFirstChildOfType(ASTClassType.class);
}

View File

@ -14,13 +14,13 @@ import net.sourceforge.pmd.lang.java.ast.ASTList.ASTNonEmptyList;
*
* <pre class="grammar">
*
* ExtendsList ::= "extends" {@link ASTType Type} ( "," {@link ASTType Type} )*
* ExtendsList ::= "extends" {@link ASTClassType ClassType} ( "," {@link ASTClassType ClassType} )*
* </pre>
*/
public final class ASTExtendsList extends ASTNonEmptyList<ASTClassOrInterfaceType> {
public final class ASTExtendsList extends ASTNonEmptyList<ASTClassType> {
ASTExtendsList(int id) {
super(id, ASTClassOrInterfaceType.class);
super(id, ASTClassType.class);
}

View File

@ -12,14 +12,14 @@ import net.sourceforge.pmd.lang.java.ast.ASTList.ASTNonEmptyList;
*
* <pre class="grammar">
*
* ImplementsList ::= "implements" {@link ASTClassOrInterfaceType ClassOrInterfaceType} ( "," {@link ASTClassOrInterfaceType ClassOrInterfaceType})*
* ImplementsList ::= "implements" {@link ASTClassType InterfaceType} ( "," {@link ASTClassType InterfaceType})*
*
* </pre>
*/
public final class ASTImplementsList extends ASTNonEmptyList<ASTClassOrInterfaceType> {
public final class ASTImplementsList extends ASTNonEmptyList<ASTClassType> {
ASTImplementsList(int id) {
super(id, ASTClassOrInterfaceType.class);
super(id, ASTClassType.class);
}

View File

@ -22,7 +22,7 @@ import net.sourceforge.pmd.lang.ast.NodeStream;
*
* <pre class="grammar">
*
* IntersectionType ::= {@link ASTClassOrInterfaceType ClassOrInterfaceType} ("&amp;" {@link ASTClassOrInterfaceType InterfaceType})+
* IntersectionType ::= {@link ASTClassType ClassOrInterfaceType} ("&amp;" {@link ASTClassType InterfaceType})+
*
* </pre>
*/
@ -36,8 +36,8 @@ public final class ASTIntersectionType extends AbstractJavaTypeNode
}
/** Returns a stream of component types. */
public NodeStream<ASTClassOrInterfaceType> getComponents() {
return children(ASTClassOrInterfaceType.class);
public NodeStream<ASTClassType> getComponents() {
return children(ASTClassType.class);
}
@Override

View File

@ -12,8 +12,8 @@ import net.sourceforge.pmd.lang.ast.NodeStream;
* <pre class="grammar">
*
* ModuleProvidesDirective ::=
* "provides" {@linkplain ASTClassOrInterfaceType ClassType}
* "with" {@linkplain ASTClassOrInterfaceType ClassType} ( "," {@linkplain ASTClassOrInterfaceType ClassType} )*
* "provides" {@linkplain ASTClassType ClassType}
* "with" {@linkplain ASTClassType ClassType} ( "," {@linkplain ASTClassType ClassType} )*
* ";"
*
* </pre>
@ -32,15 +32,15 @@ public final class ASTModuleProvidesDirective extends ASTModuleDirective {
/**
* Returns the node representing the provided interface.
*/
public ASTClassOrInterfaceType getService() {
return firstChild(ASTClassOrInterfaceType.class);
public ASTClassType getService() {
return firstChild(ASTClassType.class);
}
/**
* Returns the nodes representing the service providers, that is,
* the service implementations.
*/
public NodeStream<ASTClassOrInterfaceType> getServiceProviders() {
return children(ASTClassOrInterfaceType.class).drop(1);
public NodeStream<ASTClassType> getServiceProviders() {
return children(ASTClassType.class).drop(1);
}
}

View File

@ -28,8 +28,8 @@ public final class ASTModuleUsesDirective extends ASTModuleDirective {
/**
* Returns the node representing the consumed service.
*/
public ASTClassOrInterfaceType getService() {
return firstChild(ASTClassOrInterfaceType.class);
public ASTClassType getService() {
return firstChild(ASTClassType.class);
}
}

View File

@ -16,14 +16,14 @@ import net.sourceforge.pmd.lang.java.ast.ASTList.ASTNonEmptyList;
*
* <pre class="grammar">
*
* PermitsList ::= "permits" ClassOrInterfaceType
* ( "," ClassOrInterfaceType )*
* PermitsList ::= "permits" ClassType
* ( "," ClassType )*
* </pre>
*/
public final class ASTPermitsList extends ASTNonEmptyList<ASTClassOrInterfaceType> {
public final class ASTPermitsList extends ASTNonEmptyList<ASTClassType> {
ASTPermitsList(int id) {
super(id, ASTClassOrInterfaceType.class);
super(id, ASTClassType.class);
}
@Override

View File

@ -31,7 +31,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
*
* <pre class="grammar">
*
* ReceiverParameter ::= {@link ASTClassOrInterfaceType ClassOrInterfaceType} (&lt;IDENTIFIER&gt; ".")? "this"
* ReceiverParameter ::= {@link ASTClassType ClassType} (&lt;IDENTIFIER&gt; ".")? "this"
*
* </pre>
*/
@ -58,8 +58,8 @@ public final class ASTReceiverParameter extends AbstractJavaNode {
* must be {@code Identifier.this} where {@code Identifier} is the simple name of C.
*/
@NonNull
public ASTClassOrInterfaceType getReceiverType() {
return (ASTClassOrInterfaceType) getChild(0);
public ASTClassType getReceiverType() {
return (ASTClassType) getChild(0);
}
}

View File

@ -5,12 +5,12 @@
package net.sourceforge.pmd.lang.java.ast;
/**
* Represents a reference type, i.e. a {@linkplain ASTClassOrInterfaceType class or interface type},
* Represents a reference type, i.e. a {@linkplain ASTClassType class or interface type},
* or an {@linkplain ASTArrayType array type}.
*
* <pre class="grammar">
*
* ReferenceType ::= {@link ASTClassOrInterfaceType ClassOrInterfaceType}
* ReferenceType ::= {@link ASTClassType ClassOrInterfaceType}
* | {@link ASTArrayType ArrayType}
* | {@link ASTIntersectionType IntersectionType}
* | {@link ASTUnionType UnionType}

View File

@ -13,7 +13,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* <pre class="grammar">
*
* SuperExpression ::= "super"
* | {@link ASTClassOrInterfaceType TypeName} "." "super"
* | {@link ASTClassType ClassType} "." "super"
*
* </pre>
*/
@ -24,8 +24,8 @@ public final class ASTSuperExpression extends AbstractJavaExpr implements ASTPri
@Nullable
public ASTClassOrInterfaceType getQualifier() {
return getNumChildren() > 0 ? (ASTClassOrInterfaceType) getChild(0) : null;
public ASTClassType getQualifier() {
return getNumChildren() > 0 ? (ASTClassType) getChild(0) : null;
}
@Override

View File

@ -13,7 +13,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
* <pre class="grammar">
*
* ThisExpression ::= "this"
* | {@link ASTClassOrInterfaceType TypeName} "." "this"
* | {@link ASTClassType ClassType} "." "this"
*
* </pre>
*/
@ -25,8 +25,8 @@ public final class ASTThisExpression extends AbstractJavaExpr implements ASTPrim
@Nullable
public ASTClassOrInterfaceType getQualifier() {
return getNumChildren() > 0 ? (ASTClassOrInterfaceType) getChild(0) : null;
public ASTClassType getQualifier() {
return getNumChildren() > 0 ? (ASTClassType) getChild(0) : null;
}
@Override

View File

@ -11,14 +11,14 @@ import net.sourceforge.pmd.lang.java.ast.ASTList.ASTNonEmptyList;
*
* <pre class="grammar">
*
* ThrowsList ::= "throws" {@link ASTClassOrInterfaceType ClassType} ("," {@link ASTClassOrInterfaceType ClassType})*
* ThrowsList ::= "throws" {@link ASTClassType ClassType} ("," {@link ASTClassType ClassType})*
*
* </pre>
*/
public final class ASTThrowsList extends ASTNonEmptyList<ASTClassOrInterfaceType> {
public final class ASTThrowsList extends ASTNonEmptyList<ASTClassType> {
ASTThrowsList(int id) {
super(id, ASTClassOrInterfaceType.class);
super(id, ASTClassType.class);
}
@Override

View File

@ -75,7 +75,7 @@ public interface ASTType extends TypeNode, Annotatable, LeftRecursiveNode {
@Deprecated
default boolean isClassOrInterfaceType() {
return this instanceof ASTClassOrInterfaceType;
return this instanceof ASTClassType;
}

View File

@ -19,7 +19,7 @@ import net.sourceforge.pmd.lang.java.ast.InternalInterfaces.AtLeastOneChildOfTyp
*
* <pre class="grammar">
*
* UnionType ::= {@link ASTClassOrInterfaceType ClassType} ("|" {@link ASTClassOrInterfaceType ClassType})+
* UnionType ::= {@link ASTClassType ClassType} ("|" {@link ASTClassType ClassType})+
*
* </pre>
*
@ -27,8 +27,8 @@ import net.sourceforge.pmd.lang.java.ast.InternalInterfaces.AtLeastOneChildOfTyp
*/
public final class ASTUnionType extends AbstractJavaTypeNode
implements ASTReferenceType,
AtLeastOneChildOfType<ASTClassOrInterfaceType>,
Iterable<ASTClassOrInterfaceType> {
AtLeastOneChildOfType<ASTClassType>,
Iterable<ASTClassType> {
ASTUnionType(int id) {
super(id);
@ -40,13 +40,13 @@ public final class ASTUnionType extends AbstractJavaTypeNode
}
/** Returns a stream of component types. */
public NodeStream<ASTClassOrInterfaceType> getComponents() {
return children(ASTClassOrInterfaceType.class);
public NodeStream<ASTClassType> getComponents() {
return children(ASTClassType.class);
}
@Override
public Iterator<ASTClassOrInterfaceType> iterator() {
return children(ASTClassOrInterfaceType.class).iterator();
public Iterator<ASTClassType> iterator() {
return children(ASTClassType.class).iterator();
}
}

View File

@ -62,7 +62,7 @@ final class AstDisambiguationPass {
// those ignore JTypeParameterSymbol, for error handling logic to be uniform
private static void checkParentIsMember(ReferenceCtx ctx, ASTClassOrInterfaceType resolvedType, ASTClassOrInterfaceType parent) {
private static void checkParentIsMember(ReferenceCtx ctx, ASTClassType resolvedType, ASTClassType parent) {
JTypeDeclSymbol sym = resolvedType.getReferencedSym();
JClassSymbol parentClass = ctx.findTypeMember(sym, parent.getSimpleName(), parent);
if (parentClass == null) {
@ -112,7 +112,7 @@ final class AstDisambiguationPass {
assert symbolTable != null : "Symbol tables haven't been set yet??";
boolean isPackageOrTypeOnly;
if (name.getParent() instanceof ASTClassOrInterfaceType) {
if (name.getParent() instanceof ASTClassType) {
isPackageOrTypeOnly = true;
} else if (name.getParent() instanceof ASTExpression) {
isPackageOrTypeOnly = false;
@ -132,9 +132,9 @@ final class AstDisambiguationPass {
if (isPackageOrTypeOnly && resolved instanceof ASTTypeExpression) {
// unambiguous, we just have to check that the parent is a member of the enclosing type
ASTClassOrInterfaceType resolvedType = (ASTClassOrInterfaceType) ((ASTTypeExpression) resolved).getTypeNode();
ASTClassType resolvedType = (ASTClassType) ((ASTTypeExpression) resolved).getTypeNode();
resolved = resolvedType;
ASTClassOrInterfaceType parent = (ASTClassOrInterfaceType) name.getParent();
ASTClassType parent = (ASTClassType) name.getParent();
checkParentIsMember(processor, resolvedType, parent);
}
@ -147,7 +147,7 @@ final class AstDisambiguationPass {
}
@Override
public Void visit(ASTClassOrInterfaceType type, ReferenceCtx ctx) {
public Void visit(ASTClassType type, ReferenceCtx ctx) {
if (type.getReferencedSym() != null) {
return null;
@ -165,7 +165,7 @@ final class AstDisambiguationPass {
return null;
}
ASTClassOrInterfaceType lhsType = type.getQualifier();
ASTClassType lhsType = type.getQualifier();
if (lhsType != null) {
JTypeDeclSymbol lhsSym = lhsType.getReferencedSym();
assert lhsSym != null : "Unresolved LHS for " + type;
@ -190,7 +190,7 @@ final class AstDisambiguationPass {
return null;
}
private static void setClassSymbolIfNoQualifier(ASTClassOrInterfaceType type, ReferenceCtx ctx) {
private static void setClassSymbolIfNoQualifier(ASTClassType type, ReferenceCtx ctx) {
final JTypeMirror resolved = ctx.resolveSingleTypeName(type.getSymbolTable(), type.getSimpleName(), type);
JTypeDeclSymbol sym;
if (resolved == null) {
@ -206,7 +206,7 @@ final class AstDisambiguationPass {
type.setImplicitEnclosing(enclosingType(resolved));
}
private void postProcess(ASTClassOrInterfaceType type, ReferenceCtx ctx) {
private void postProcess(ASTClassType type, ReferenceCtx ctx) {
JTypeDeclSymbol sym = type.getReferencedSym();
if (type.getParent() instanceof ASTAnnotation) {
if (!(sym instanceof JClassSymbol && (sym.isUnresolved() || ((JClassSymbol) sym).isAnnotation()))) {
@ -222,7 +222,7 @@ final class AstDisambiguationPass {
}
}
private static @NonNull JTypeDeclSymbol setArity(ASTClassOrInterfaceType type, ReferenceCtx ctx, String canonicalName) {
private static @NonNull JTypeDeclSymbol setArity(ASTClassType type, ReferenceCtx ctx, String canonicalName) {
int arity = ASTList.sizeOrZero(type.getTypeArguments());
return ctx.makeUnresolvedReference(canonicalName, arity);
}
@ -339,7 +339,7 @@ final class AstDisambiguationPass {
*
* @param isPackageOrTypeOnly If true, expressions are disallowed by the context, so we don't check fields
*/
private static ASTExpression resolveType(final @Nullable ASTClassOrInterfaceType qualifier, // lhs
private static ASTExpression resolveType(final @Nullable ASTClassType qualifier, // lhs
final @Nullable JClassType implicitEnclosing, // enclosing type, if it is implicitly inherited
final JTypeDeclSymbol sym, // symbol for the type
final boolean isFqcn, // whether this is a fully-qualified name
@ -351,7 +351,7 @@ final class AstDisambiguationPass {
TokenUtils.expectKind(identifier, JavaTokenKinds.IDENTIFIER);
final ASTClassOrInterfaceType type = new ASTClassOrInterfaceType(qualifier, isFqcn, ambig.getFirstToken(), identifier);
final ASTClassType type = new ASTClassType(qualifier, isFqcn, ambig.getFirstToken(), identifier);
type.setSymbol(sym);
type.setImplicitEnclosing(implicitEnclosing);
@ -451,7 +451,7 @@ final class AstDisambiguationPass {
* The parent type's image is set to a package name + simple name.
*/
private static void forceResolveAsFullPackageNameOfParent(StringBuilder packageImage, ASTAmbiguousName ambig, ReferenceCtx ctx) {
ASTClassOrInterfaceType parent = (ASTClassOrInterfaceType) ambig.getParent();
ASTClassType parent = (ASTClassType) ambig.getParent();
packageImage.append('.').append(parent.getSimpleName());
String fullName = packageImage.toString();

View File

@ -208,7 +208,7 @@ public final class InternalApiBridge {
return TypesFromAst.fromAst(ts, lexicalSubst, node);
}
public static JTypeDeclSymbol getReferencedSym(ASTClassOrInterfaceType type) {
public static JTypeDeclSymbol getReferencedSym(ASTClassType type) {
return type.getReferencedSym();
}

View File

@ -119,7 +119,7 @@ public class JavaVisitorBase<P, R> extends AstVisitorBase<P, R> implements JavaV
}
@Override
public R visit(ASTClassOrInterfaceType node, P data) {
public R visit(ASTClassType node, P data) {
return visitReferenceType(node, data);
}

View File

@ -55,9 +55,9 @@ final class TypesFromAst {
private static JTypeMirror fromAstImpl(TypeSystem ts, Substitution lexicalSubst, ASTType node) {
if (node instanceof ASTClassOrInterfaceType) {
if (node instanceof ASTClassType) {
return makeFromClassType(ts, (ASTClassOrInterfaceType) node, lexicalSubst);
return makeFromClassType(ts, (ASTClassType) node, lexicalSubst);
} else if (node instanceof ASTWildcardType) {
@ -122,7 +122,7 @@ final class TypesFromAst {
}
private static JTypeMirror makeFromClassType(TypeSystem ts, ASTClassOrInterfaceType node, Substitution subst) {
private static JTypeMirror makeFromClassType(TypeSystem ts, ASTClassType node, Substitution subst) {
if (node == null) {
return null;
}
@ -159,7 +159,7 @@ final class TypesFromAst {
}
}
private static @Nullable JClassType getEnclosing(TypeSystem ts, ASTClassOrInterfaceType node, Substitution subst, @Nullable ASTClassOrInterfaceType lhsType, JTypeDeclSymbol reference) {
private static @Nullable JClassType getEnclosing(TypeSystem ts, ASTClassType node, Substitution subst, @Nullable ASTClassType lhsType, JTypeDeclSymbol reference) {
@Nullable JTypeMirror enclosing = makeFromClassType(ts, lhsType, subst);
if (enclosing != null && !shouldEnclose(reference)) {
@ -199,7 +199,7 @@ final class TypesFromAst {
&& !Modifier.isStatic(reference.getModifiers());
}
private static @NonNull JTypeDeclSymbol getReferenceEnsureResolved(ASTClassOrInterfaceType node) {
private static @NonNull JTypeDeclSymbol getReferenceEnsureResolved(ASTClassType node) {
if (node.getReferencedSym() != null) {
return node.getReferencedSym();
} else if (node.getParent() instanceof ASTConstructorCall) {
@ -246,7 +246,7 @@ final class TypesFromAst {
*/
private static @Nullable Annotatable getEnclosingAnnotationGiver(JavaNode node) {
JavaNode parent = node.getParent();
if (node.getIndexInParent() == 0 && parent instanceof ASTClassOrInterfaceType) {
if (node.getIndexInParent() == 0 && parent instanceof ASTClassType) {
// this is an enclosing type
return getEnclosingAnnotationGiver(parent);
} else if (node.getIndexInParent() == 0 && parent instanceof ASTArrayType) {
@ -262,7 +262,7 @@ final class TypesFromAst {
private static PSet<SymAnnot> getTypeAnnotations(ASTType type) {
PSet<SymAnnot> annotsOnType = getSymbolicAnnotations(type);
if (type instanceof ASTClassOrInterfaceType && ((ASTClassOrInterfaceType) type).getQualifier() != null) {
if (type instanceof ASTClassType && ((ASTClassType) type).getQualifier() != null) {
return annotsOnType; // annots on the declaration only apply to the leftmost qualifier
}
Annotatable parent = getEnclosingAnnotationGiver(type);

View File

@ -37,7 +37,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTBooleanLiteral;
import net.sourceforge.pmd.lang.java.ast.ASTBreakStatement;
import net.sourceforge.pmd.lang.java.ast.ASTCastExpression;
import net.sourceforge.pmd.lang.java.ast.ASTCatchClause;
import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType;
import net.sourceforge.pmd.lang.java.ast.ASTClassType;
import net.sourceforge.pmd.lang.java.ast.ASTConstructorCall;
import net.sourceforge.pmd.lang.java.ast.ASTExpression;
import net.sourceforge.pmd.lang.java.ast.ASTExpressionStatement;
@ -205,12 +205,12 @@ public final class JavaAstUtils {
*/
@SafeVarargs
public static boolean hasExceptionList(ASTMethodOrConstructorDeclaration node, Class<? extends Throwable>... types) {
@NonNull List<ASTClassOrInterfaceType> formals = ASTList.orEmpty(node.getThrowsList());
@NonNull List<ASTClassType> formals = ASTList.orEmpty(node.getThrowsList());
if (formals.size() != types.length) {
return false;
}
for (int i = 0; i < formals.size(); i++) {
ASTClassOrInterfaceType fi = formals.get(i);
ASTClassType fi = formals.get(i);
if (!TypeTestUtil.isExactlyA(types[i], fi)) {
return false;
}
@ -610,7 +610,7 @@ public final class JavaAstUtils {
&& mtype.getSymbol().getEnclosingClass().equals(call.getEnclosingType().getSymbol());
}
public static ASTClassOrInterfaceType getThisOrSuperQualifier(ASTExpression expr) {
public static ASTClassType getThisOrSuperQualifier(ASTExpression expr) {
if (expr instanceof ASTThisExpression) {
return ((ASTThisExpression) expr).getQualifier();
} else if (expr instanceof ASTSuperExpression) {

Some files were not shown because too many files have changed in this diff Show More