Interface TypeNode
-
- All Superinterfaces:
GenericNode<JavaNode>
,JavaNode
,JjtreeNode<JavaNode>
,Node
,Reportable
,TextAvailableNode
- All Known Subinterfaces:
ASTAnyTypeDeclaration
,ASTAssignableExpr
,ASTAssignableExpr.ASTNamedReferenceExpr
,ASTExpression
,ASTLiteral
,ASTPrimaryExpression
,ASTReferenceType
,ASTType
,FunctionalExpression
,InvocationNode
,QualifiableExpression
- All Known Implementing Classes:
ASTAmbiguousName
,ASTAnnotation
,ASTAnnotationTypeDeclaration
,ASTAnonymousClassDeclaration
,ASTArrayAccess
,ASTArrayAllocation
,ASTArrayInitializer
,ASTArrayType
,ASTAssignmentExpression
,ASTBooleanLiteral
,ASTCastExpression
,ASTCharLiteral
,ASTClassLiteral
,ASTClassOrInterfaceDeclaration
,ASTClassOrInterfaceType
,ASTConditionalExpression
,ASTConstructorCall
,ASTEnumConstant
,ASTEnumDeclaration
,ASTExplicitConstructorInvocation
,ASTFieldAccess
,ASTFormalParameter
,ASTInfixExpression
,ASTIntersectionType
,ASTLambdaExpression
,ASTLambdaParameter
,ASTMethodCall
,ASTMethodReference
,ASTNullLiteral
,ASTNumericLiteral
,ASTPatternExpression
,ASTPrimitiveType
,ASTRecordDeclaration
,ASTStringLiteral
,ASTSuperExpression
,ASTSwitchExpression
,ASTThisExpression
,ASTTypeExpression
,ASTTypeParameter
,ASTUnaryExpression
,ASTUnionType
,ASTVariableAccess
,ASTVariableDeclaratorId
,ASTVoidType
,ASTWildcardType
public interface TypeNode extends JavaNode
A node that has a statically known type. This includes e.g. types, which are explicitly written types, and expressions, whose types is determined from their form, or through type inference.
-
-
Field Summary
-
Fields inherited from interface net.sourceforge.pmd.lang.ast.Node
COORDS_COMPARATOR
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default @Nullable Class<?>
getType()
Deprecated.This doesn't work.default @NonNull JTypeMirror
getTypeMirror()
Returns the compile-time type of this node.JTypeMirror
getTypeMirror(TypingContext typing)
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.impl.GenericNode
ancestors, ancestorsOrSelf, asStream, children, descendants, descendantsOrSelf, getChild, getFirstChild, getLastChild, getNextSibling, getNthParent, getParent, getPreviousSibling
-
Methods inherited from interface net.sourceforge.pmd.lang.java.ast.JavaNode
getEnclosingType, getRoot, getSymbolTable, getTypeSystem, jjtAccept
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode
getFirstToken, getLastToken, tokens
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.Node
acceptVisitor, ancestors, children, compareLocation, descendants, findChildNodesWithXPath, findChildrenOfType, findDescendantsOfType, findDescendantsOfType, firstChild, getAstInfo, getBeginColumn, getBeginLine, getEndColumn, getEndLine, getFirstChildOfType, getFirstDescendantOfType, getFirstParentOfType, getImage, getIndexInParent, getLanguageVersion, getNumChildren, getParentsOfType, getReportLocation, getTextDocument, getUserMap, getXPathAttributesIterator, getXPathNodeName, hasDescendantOfType, hasImageEqualTo, isFindBoundary
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.TextAvailableNode
getOriginalText, getText, getTextRegion
-
-
-
-
Method Detail
-
getTypeMirror
default @NonNull JTypeMirror getTypeMirror()
Returns the compile-time type of this node. For example, for a string literal, returns the type mirror forString
, for a method call, returns the return type of the call, etc.This method ignores conversions applied to the value of the node because of its context. For example, in
1 + ""
, the numeric literal will have typeint
, but it is converted toString
by the surrounding concatenation expression. Similarly, inCollections.singletonList(1)
, theASTNumericLiteral
node has typeint
, but the type of the method formal isInteger
, and boxing is applied at runtime. Possibly, an API will be added to expose this information.- Returns:
- The type mirror. Never returns null; if the type is unresolved, returns
TypeSystem.UNKNOWN
.
-
getTypeMirror
JTypeMirror getTypeMirror(TypingContext typing)
-
getType
@Deprecated default @Nullable Class<?> getType()
Deprecated.This doesn't work. PMD doesn't load classes, it just reads the bytecode. Compare the symbol of thetype mirror
instead.Get the Java Class associated with this node.- Returns:
- The Java Class, may return
null
.
-
-