Package spoon.support.reflect.reference
Class CtExecutableReferenceImpl<T>
java.lang.Object
spoon.support.reflect.declaration.CtElementImpl
spoon.support.reflect.reference.CtReferenceImpl
spoon.support.reflect.reference.CtExecutableReferenceImpl<T>
- All Implemented Interfaces:
Serializable,Cloneable,FactoryAccessor,SourcePositionHolder,CtElement,CtActualTypeContainer,CtExecutableReference<T>,CtReference,CtQueryable,CtVisitable
public class CtExecutableReferenceImpl<T>
extends CtReferenceImpl
implements CtExecutableReference<T>
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class spoon.support.reflect.reference.CtReferenceImpl
simplenameFields inherited from class spoon.support.reflect.declaration.CtElementImpl
ERROR_MESSAGE_TO_STRING, factory, LOGGER, parentFields inherited from interface spoon.reflect.reference.CtExecutableReference
CONSTRUCTOR_NAME, LAMBDA_NAME_PREFIX, UNKNOWN_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAccepts a visitor<C extends CtActualTypeContainer>
CaddActualTypeArgument(CtTypeReference<?> actualTypeArgument)Adds a type argument.clone()Clone the element which calls this method in a new object.protected AnnotatedElementConstructor<?>Gets the runtime constructor that corresponds to an executable reference if any.Gets the runtime method that corresponds to an executable reference if any.List<CtTypeReference<?>>Gets the type arguments.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 subtypeCtExecutablethat 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).booleanTells if this is a reference to a constructor.booleanisFinal()Tells if the referenced executable is final.booleanisOverriding(CtExecutableReference<?> executable)Returnstrueif this executable overrides the given executable.booleanisStatic()Tells if the referenced executable is static.booleanremoveActualTypeArgument(CtTypeReference<?> actualTypeArgument)Removes a type argument.<C extends CtActualTypeContainer>
CsetActualTypeArguments(List<? extends CtTypeReference<?>> actualTypeArguments)Sets the type arguments.<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 stat)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 class spoon.support.reflect.reference.CtReferenceImpl
equals, getSimpleName, setComments, setSimpleNameMethods inherited from class spoon.support.reflect.declaration.CtElementImpl
addAnnotation, addComment, asIterable, comment, delete, descendantIterator, emptyList, emptySet, filterChildren, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getFactory, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hashCode, hasParent, isImplicit, isParentInitialized, map, map, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setDocComment, setFactory, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, unmodifiableList, updateAllParentsBelowMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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, updateAllParentsBelowMethods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, mapMethods inherited from interface spoon.reflect.reference.CtReference
getSimpleName, setComments, setSimpleNameMethods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
-
Constructor Details
-
CtExecutableReferenceImpl
public CtExecutableReferenceImpl()
-
-
Method Details
-
accept
Description copied from interface:CtVisitableAccepts a visitor- Specified by:
acceptin interfaceCtVisitable
-
getActualTypeArguments
Description copied from interface:CtActualTypeContainerGets the type arguments.- Specified by:
getActualTypeArgumentsin interfaceCtActualTypeContainer
-
isConstructor
public boolean isConstructor()Description copied from interface:CtExecutableReferenceTells if this is a reference to a constructor.- Specified by:
isConstructorin interfaceCtExecutableReference<T>
-
getDeclaration
Description copied from interface:CtReferenceReturns 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()andCtExecutableReference.getExecutableDeclaration()that never return null.- Specified by:
getDeclarationin interfaceCtExecutableReference<T>- Specified by:
getDeclarationin interfaceCtReference- Returns:
- referenced element or null if element is not in the source path (aka input resource).
-
getExecutableDeclaration
Description copied from interface:CtExecutableReferenceReturns a subtypeCtExecutablethat 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).- Specified by:
getExecutableDeclarationin interfaceCtExecutableReference<T>- Returns:
- the executable declaration that corresponds to the reference.
-
getDeclaringType
Description copied from interface:CtExecutableReferenceGets the reference to the type that declares this executable.- Specified by:
getDeclaringTypein interfaceCtExecutableReference<T>
-
getType
Description copied from interface:CtExecutableReferenceFor 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).- Specified by:
getTypein interfaceCtExecutableReference<T>
-
getParameters
Description copied from interface:CtExecutableReferenceGets parameters of the executable.- Specified by:
getParametersin interfaceCtExecutableReference<T>
-
setParameters
Description copied from interface:CtExecutableReferenceSets parameters of the executable.- Specified by:
setParametersin interfaceCtExecutableReference<T>
-
getOverridingExecutable
Description copied from interface:CtExecutableReferenceGets an overriding executable for this executable from a given subtype, if exists.- Specified by:
getOverridingExecutablein interfaceCtExecutableReference<T>- 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)
-
isOverriding
Description copied from interface:CtExecutableReferenceReturnstrueif this executable overrides the given executable.- Specified by:
isOverridingin interfaceCtExecutableReference<T>
-
setActualTypeArguments
public <C extends CtActualTypeContainer> C setActualTypeArguments(List<? extends CtTypeReference<?>> actualTypeArguments)Description copied from interface:CtActualTypeContainerSets the type arguments.- Specified by:
setActualTypeArgumentsin interfaceCtActualTypeContainer
-
setDeclaringType
Description copied from interface:CtExecutableReferenceSets the declaring type.- Specified by:
setDeclaringTypein interfaceCtExecutableReference<T>
-
setType
Description copied from interface:CtExecutableReferenceSets the type of the variable.- Specified by:
setTypein interfaceCtExecutableReference<T>
-
getActualAnnotatedElement
- Specified by:
getActualAnnotatedElementin classCtReferenceImpl
-
getActualMethod
Description copied from interface:CtExecutableReferenceGets the runtime method that corresponds to an executable reference if any.- Specified by:
getActualMethodin interfaceCtExecutableReference<T>- Returns:
- the method (null if not found)
-
getActualConstructor
Description copied from interface:CtExecutableReferenceGets the runtime constructor that corresponds to an executable reference if any.- Specified by:
getActualConstructorin interfaceCtExecutableReference<T>- Returns:
- the constructor (null if not found)
-
isStatic
public boolean isStatic()Description copied from interface:CtExecutableReferenceTells if the referenced executable is static.- Specified by:
isStaticin interfaceCtExecutableReference<T>
-
setStatic
Description copied from interface:CtExecutableReferenceSets this executable reference to be static or not.- Specified by:
setStaticin interfaceCtExecutableReference<T>
-
isFinal
public boolean isFinal()Description copied from interface:CtExecutableReferenceTells if the referenced executable is final.- Specified by:
isFinalin interfaceCtExecutableReference<T>
-
getModifiers
-
getOverridingExecutable
Description copied from interface:CtExecutableReferenceReturns 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.- Specified by:
getOverridingExecutablein interfaceCtExecutableReference<T>
-
addActualTypeArgument
public <C extends CtActualTypeContainer> C addActualTypeArgument(CtTypeReference<?> actualTypeArgument)Description copied from interface:CtActualTypeContainerAdds a type argument.- Specified by:
addActualTypeArgumentin interfaceCtActualTypeContainer
-
removeActualTypeArgument
Description copied from interface:CtActualTypeContainerRemoves a type argument.- Specified by:
removeActualTypeArgumentin interfaceCtActualTypeContainer
-
getSignature
Description copied from interface:CtExecutableReferenceGets the signature of this method or constructor, as explained inCtExecutable.getSignature().- Specified by:
getSignaturein interfaceCtExecutableReference<T>
-
clone
Description copied from interface:CtElementClone 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:
clonein interfaceCtElement- Specified by:
clonein interfaceCtExecutableReference<T>- Specified by:
clonein interfaceCtReference- Overrides:
clonein classCtReferenceImpl
-