Interface JExecutableSymbol
-
- All Superinterfaces:
AnnotableSymbol
,JAccessibleElementSymbol
,JElementSymbol
,JTypeParameterOwnerSymbol
- All Known Subinterfaces:
JConstructorSymbol
,JMethodSymbol
public interface JExecutableSymbol extends JTypeParameterOwnerSymbol
Common supertype for method and constructor symbols.
-
-
Field Summary
-
Fields inherited from interface net.sourceforge.pmd.lang.java.symbols.JAccessibleElementSymbol
PRIMITIVE_PACKAGE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description @Nullable JTypeMirror
getAnnotatedReceiverType(Substitution subst)
Return the receiver type with all type annotations, when viewed under the given substitution.int
getArity()
Returns the number of formal parameters expected.@NonNull JClassSymbol
getEnclosingClass()
Returns the class symbol declaring this method or constructor.List<JFormalParamSymbol>
getFormalParameters()
Returns the formal parameters this executable declares.List<JTypeMirror>
getFormalParameterTypes(Substitution subst)
Returns the types of the formal parameters, when viewed under the given substitution.default @NonNull String
getPackageName()
Returns the name of the package this element is declared in.List<JTypeMirror>
getThrownExceptionTypes(Substitution subst)
Returns the types of the thrown exceptions, when viewed under the given substitution.default boolean
hasReceiver()
Return true if this method needs to be called on a receiver instance.default boolean
isDefaultMethod()
boolean
isVarargs()
Returns true if the last formal parameter is a varargs parameter.-
Methods inherited from interface net.sourceforge.pmd.lang.java.symbols.AnnotableSymbol
getDeclaredAnnotation, getDeclaredAnnotations, isAnnotationPresent
-
Methods inherited from interface net.sourceforge.pmd.lang.java.symbols.JAccessibleElementSymbol
getModifiers, isStatic
-
Methods inherited from interface net.sourceforge.pmd.lang.java.symbols.JElementSymbol
acceptVisitor, equals, getSimpleName, getTypeSystem, isUnresolved, nameEquals, tryGetNode
-
Methods inherited from interface net.sourceforge.pmd.lang.java.symbols.JTypeParameterOwnerSymbol
getEnclosingTypeParameterOwner, getLexicalScope, getTypeParameterCount, getTypeParameters, isGeneric
-
-
-
-
Method Detail
-
getFormalParameters
List<JFormalParamSymbol> getFormalParameters()
Returns the formal parameters this executable declares. These are only non-synthetic parameters. For example, a constructor for an inner non-static class will not reflect a parameter for the enclosing instance.
-
isDefaultMethod
default boolean isDefaultMethod()
-
isVarargs
boolean isVarargs()
Returns true if the last formal parameter is a varargs parameter.
-
getArity
int getArity()
Returns the number of formal parameters expected. This must be the length ofgetFormalParameters()
but if it can be implemented without creating the formal parameters, it should.A varargs parameter counts as a single parameter.
-
getAnnotatedReceiverType
@Nullable JTypeMirror getAnnotatedReceiverType(Substitution subst)
Return the receiver type with all type annotations, when viewed under the given substitution. Return null if this method has no receiver.- Throws:
IllegalArgumentException
- If the argument is not the receiver type of this type.
-
hasReceiver
default boolean hasReceiver()
Return true if this method needs to be called on a receiver instance. This is not the case if the method is static, or a constructor of an outer or static class.
-
getEnclosingClass
@NonNull JClassSymbol getEnclosingClass()
Returns the class symbol declaring this method or constructor. This is similar toConstructor.getDeclaringClass()
, resp.Method.getDeclaringClass()
. Never null.- Specified by:
getEnclosingClass
in interfaceJAccessibleElementSymbol
-
getPackageName
default @NonNull String getPackageName()
Description copied from interface:JAccessibleElementSymbol
Returns the name of the package this element is declared in. This recurses into the enclosing elements if needed. If this is an array symbol, returns the package name of the element symbol. If this is a primitive type, returns "java.lang".This is consistent with Java 9's
getPackageName()
.- Specified by:
getPackageName
in interfaceJAccessibleElementSymbol
-
getFormalParameterTypes
List<JTypeMirror> getFormalParameterTypes(Substitution subst)
Returns the types of the formal parameters, when viewed under the given substitution. The returned list has one item for each formal.- See Also:
getFormalParameters()
-
getThrownExceptionTypes
List<JTypeMirror> getThrownExceptionTypes(Substitution subst)
Returns the types of the thrown exceptions, when viewed under the given substitution.
-
-