Package spoon.reflect.reference
Interface CtExecutableReference<T>
- All Superinterfaces:
Cloneable
,CtActualTypeContainer
,CtElement
,CtQueryable
,CtReference
,CtVisitable
,FactoryAccessor
,Serializable
,SourcePositionHolder
- All Known Implementing Classes:
CtExecutableReferenceImpl
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionclone()
Clone the element which calls this method in a new object.Constructor<?>
Gets the runtime constructor that corresponds to an executable reference if any.Gets the runtime method that corresponds to an executable reference if any.Returns the declaration that corresponds to the referenced element only if the declaration is in the analyzed source files.Gets the reference to the type that declares this executable.Returns a subtypeCtExecutable
that corresponds to the reference even if its declaring type isn't in the Spoon source path (in this case, the Spoon elements are built with runtime reflection).Returns the method overridden by this one, if exists (null otherwise).<S extends T>
CtExecutableReference<S>getOverridingExecutable(CtTypeReference<?> subType)
Gets an overriding executable for this executable from a given subtype, if exists.List<CtTypeReference<?>>
Gets parameters of the executable.Gets the signature of this method or constructor, as explained inCtExecutable.getSignature()
.getType()
For methods, gets the return type of the executable (may be null in noclasspath mode).boolean
Tells if this is a reference to a constructor.boolean
isFinal()
Tells if the referenced executable is final.boolean
isOverriding(CtExecutableReference<?> executable)
Returnstrue
if this executable overrides the given executable.boolean
isStatic()
Tells if the referenced executable is static.<C extends CtExecutableReference<T>>
CsetDeclaringType(CtTypeReference<?> declaringType)
Sets the declaring type.<C extends CtExecutableReference<T>>
CsetParameters(List<CtTypeReference<?>> parameters)
Sets parameters of the executable.<C extends CtExecutableReference<T>>
CsetStatic(boolean b)
Sets this executable reference to be static or not.<C extends CtExecutableReference<T>>
CsetType(CtTypeReference type)
Sets the type of the variable.Methods inherited from interface spoon.reflect.reference.CtActualTypeContainer
addActualTypeArgument, getActualTypeArguments, removeActualTypeArgument, setActualTypeArguments
Methods inherited from interface spoon.reflect.declaration.CtElement
addAnnotation, addComment, asIterable, delete, descendantIterator, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hasParent, isImplicit, isParentInitialized, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setDocComment, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, updateAllParentsBelow
Methods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, map
Methods inherited from interface spoon.reflect.reference.CtReference
getSimpleName, setComments, setSimpleName
Methods inherited from interface spoon.reflect.visitor.CtVisitable
accept
Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
Field Details
-
CONSTRUCTOR_NAME
- See Also:
- Constant Field Values
-
LAMBDA_NAME_PREFIX
- See Also:
- Constant Field Values
-
UNKNOWN_TYPE
- See Also:
- Constant Field Values
-
-
Method Details
-
isConstructor
boolean isConstructor()Tells if this is a reference to a constructor. -
getActualMethod
Method getActualMethod()Gets the runtime method that corresponds to an executable reference if any.- Returns:
- the method (null if not found)
-
getActualConstructor
Constructor<?> getActualConstructor()Gets the runtime constructor that corresponds to an executable reference if any.- Returns:
- the constructor (null if not found)
-
getDeclaration
CtExecutable<T> getDeclaration()Description copied from interface:CtReference
Returns the declaration that corresponds to the referenced element only if the declaration is in the analyzed source files. It is strongly advised to use the more robustCtTypeReference.getTypeDeclaration()
andgetExecutableDeclaration()
that never return null.- Specified by:
getDeclaration
in interfaceCtReference
- Returns:
- referenced element or null if element is not in the source path (aka input resource).
-
getExecutableDeclaration
CtExecutable<T> getExecutableDeclaration()Returns a subtypeCtExecutable
that corresponds to the reference even if its declaring type isn't in the Spoon source path (in this case, the Spoon elements are built with runtime reflection).- Returns:
- the executable declaration that corresponds to the reference.
-
getDeclaringType
CtTypeReference<?> getDeclaringType()Gets the reference to the type that declares this executable. -
getType
CtTypeReference<T> getType()For methods, gets the return type of the executable (may be null in noclasspath mode). For constructors, gets the constructor class (which is also the return type of the contructor calls). -
getParameters
List<CtTypeReference<?>> getParameters()Gets parameters of the executable. -
setParameters
Sets parameters of the executable. -
isOverriding
Returnstrue
if this executable overrides the given executable. -
getOverridingExecutable
CtExecutableReference<?> getOverridingExecutable()Returns the method overridden by this one, if exists (null otherwise). The returned method is searched in the superclass hierarchy (and not in the super-interfaces). The returned method can be an abstract method from an abstract class, a super implementation, or even a method from Object. -
getOverridingExecutable
Gets an overriding executable for this executable from a given subtype, if exists.- Type Parameters:
S
- subtype of T- Parameters:
subType
- starting bottom type to find an overriding executable (subtypes are not tested)- Returns:
- the first found (most concrete) executable that overrides this executable (null if none found)
-
isStatic
boolean isStatic()Tells if the referenced executable is static. -
setDeclaringType
Sets the declaring type. -
setStatic
Sets this executable reference to be static or not. -
setType
Sets the type of the variable. -
isFinal
boolean isFinal()Tells if the referenced executable is final. -
getSignature
String getSignature()Gets the signature of this method or constructor, as explained inCtExecutable.getSignature()
. -
clone
CtExecutableReference<T> clone()Description copied from interface:CtElement
Clone the element which calls this method in a new object. Note that that references are kept as is, and thus, so if you clone whole classes or methods, some parts of the cloned element (eg executable references) may still point to the initial element. In this case, consider using methodsRefactoring.copyType(CtType)
andRefactoring.copyMethod(CtMethod)
instead which does additional work beyond cloning.- Specified by:
clone
in interfaceCtElement
- Specified by:
clone
in interfaceCtReference
-