Interface TypeNode

All Superinterfaces:
net.sourceforge.pmd.lang.ast.impl.GenericNode<JavaNode>, JavaNode, net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode<JavaNode>, net.sourceforge.pmd.lang.ast.Node, net.sourceforge.pmd.reporting.Reportable, net.sourceforge.pmd.lang.ast.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, 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

    Modifier and Type
    Method
    Description
    default @NonNull JTypeMirror
    Returns the compile-time type of this node.
     

    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 Details

    • getTypeMirror

      default @NonNull JTypeMirror getTypeMirror()
      Returns the compile-time type of this node. For example, for a string literal, returns the type mirror for String, 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 type int, but it is converted to String by the surrounding concatenation expression. Similarly, in Collections.singletonList(1), the ASTNumericLiteral node has type int, but the type of the method formal is Integer, 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)