Interface TypeNode
-
- All Superinterfaces:
GenericNode<JavaNode>
,JavaNode
,JjtreeNode<JavaNode>
,Node
,Reportable
,TextAvailableNode
- All Known Subinterfaces:
ASTAssignableExpr
,ASTAssignableExpr.ASTNamedReferenceExpr
,ASTExpression
,ASTLiteral
,ASTPattern
,ASTPrimaryExpression
,ASTReferenceType
,ASTType
,ASTTypeDeclaration
,FunctionalExpression
,InvocationNode
,QualifiableExpression
- All Known Implementing Classes:
ASTAmbiguousName
,ASTAnnotation
,ASTAnnotationTypeDeclaration
,ASTAnonymousClassDeclaration
,ASTArrayAccess
,ASTArrayAllocation
,ASTArrayInitializer
,ASTArrayType
,ASTAssignmentExpression
,ASTBooleanLiteral
,ASTCastExpression
,ASTCharLiteral
,ASTClassDeclaration
,ASTClassLiteral
,ASTClassType
,ASTConditionalExpression
,ASTConstructorCall
,ASTEnumConstant
,ASTEnumDeclaration
,ASTExplicitConstructorInvocation
,ASTFieldAccess
,ASTFormalParameter
,ASTImplicitClassDeclaration
,ASTInfixExpression
,ASTIntersectionType
,ASTLambdaExpression
,ASTLambdaParameter
,ASTMethodCall
,ASTMethodReference
,ASTNullLiteral
,ASTNumericLiteral
,ASTPatternExpression
,ASTPrimitiveType
,ASTRecordComponent
,ASTRecordDeclaration
,ASTRecordPattern
,ASTStringLiteral
,ASTSuperExpression
,ASTSwitchExpression
,ASTTemplateExpression
,ASTThisExpression
,ASTTypeExpression
,ASTTypeParameter
,ASTTypePattern
,ASTUnaryExpression
,ASTUnionType
,ASTUnnamedPattern
,ASTVariableAccess
,ASTVariableId
,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 Modifier and Type Method Description 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, getParent, getPreviousSibling
-
Methods inherited from interface net.sourceforge.pmd.lang.java.ast.JavaNode
getEnclosingType, getRoot, getSymbolTable, getTypeSystem
-
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, firstChild, getAstInfo, getBeginColumn, getBeginLine, getEndColumn, getEndLine, getImage, getIndexInParent, getLanguageVersion, getNumChildren, getReportLocation, getTextDocument, getUserMap, getXPathAttributesIterator, getXPathNodeName, 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)
-
-