Class ExprContext
- java.lang.Object
-
- net.sourceforge.pmd.lang.java.types.ast.ExprContext
-
public abstract class ExprContext extends Object
Context of an expression. This determines the target type of poly expressions, which is necessary for overload resolution. It also determines what kinds of conversions apply to the value to make it compatible with the context.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExprContext.ExprContextKind
Kind of context.
-
Field Summary
Fields Modifier and Type Field Description protected ExprContext.ExprContextKind
kind
-
Constructor Summary
Constructors Modifier Constructor Description protected
ExprContext(ExprContext.ExprContextKind kind)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
acceptsType(@NonNull JTypeMirror type)
Returns true if the given type is compatible with this context implicitly (without cast).@Nullable InvocationNode
getInvocNodeIfInvocContext()
ExprContext.ExprContextKind
getKind()
Returns the kind of context this is.static net.sourceforge.pmd.lang.java.types.ast.internal.RegularCtx
getMissingInstance()
Returns anExprContext
instance which represents a missing context.@Nullable JTypeMirror
getPolyTargetType(boolean lambdaOrMethodRef)
Returns the target type bestowed by this context ON A POLY EXPRESSION.abstract @Nullable JTypeMirror
getTargetType()
Returns the target type, or null if there is none.@NonNull ExprContext
getToplevelCtx()
boolean
hasKind(ExprContext.ExprContextKind kind)
boolean
isMissing()
Returns true if this context does not provide any target type.
-
-
-
Field Detail
-
kind
protected final ExprContext.ExprContextKind kind
-
-
Constructor Detail
-
ExprContext
protected ExprContext(ExprContext.ExprContextKind kind)
-
-
Method Detail
-
getTargetType
public abstract @Nullable JTypeMirror getTargetType()
Returns the target type, or null if there is none.
-
acceptsType
public boolean acceptsType(@NonNull JTypeMirror type)
Returns true if the given type is compatible with this context implicitly (without cast). Conversions may occur to make this possible. What conversions may occur depends on the kind of this context.By convention, any type is compatible with a missing context.
- Parameters:
type
- A type which is checked against the target type
-
isMissing
public boolean isMissing()
Returns true if this context does not provide any target type. This is then a sentinel object.
-
getKind
public ExprContext.ExprContextKind getKind()
Returns the kind of context this is.
-
getInvocNodeIfInvocContext
public @Nullable InvocationNode getInvocNodeIfInvocContext()
-
getToplevelCtx
public @NonNull ExprContext getToplevelCtx()
-
getPolyTargetType
public @Nullable JTypeMirror getPolyTargetType(boolean lambdaOrMethodRef)
Returns the target type bestowed by this context ON A POLY EXPRESSION.- Parameters:
lambdaOrMethodRef
- Whether the poly to be considered is a lambda or method ref. In this case, cast contexts can give a target type.
-
getMissingInstance
public static net.sourceforge.pmd.lang.java.types.ast.internal.RegularCtx getMissingInstance()
Returns anExprContext
instance which represents a missing context. UseisMissing()
instead of testing for equality.
-
hasKind
public boolean hasKind(ExprContext.ExprContextKind kind)
-
-