Package spoon.reflect.visitor.filter
Class SuperInheritanceHierarchyFunction
java.lang.Object
spoon.reflect.visitor.filter.SuperInheritanceHierarchyFunction
- All Implemented Interfaces:
CtConsumableFunction<CtTypeInformation>
,CtQueryAware
public class SuperInheritanceHierarchyFunction
extends Object
implements CtConsumableFunction<CtTypeInformation>, CtQueryAware
Expects a
The output is produced in following order:
CtTypeInformation
as input
and produces all super classes and super interfaces recursively.The output is produced in following order:
- input type. if `includingSelf==true`
- all interfaces of type recursively
- parent class of type
- goto 1: using parent class as input type
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Implementation ofCtScannerListener
, which is used to assure that each interface is visited only once. -
Constructor Summary
ConstructorDescriptionThe mapping function created using this constructor will visit each super class and super interface following super hierarchy.SuperInheritanceHierarchyFunction(Set<String> visitedSet)
The mapping function created using this constructor will visit each super class and super interface following super hierarchy. -
Method Summary
Modifier and TypeMethodDescriptionvoid
apply(CtTypeInformation input, CtConsumer<Object> outputConsumer)
Evaluates the function on the given input.failOnClassNotFound(boolean failOnClassNotFound)
includingInterfaces(boolean includingInterfaces)
includingSelf(boolean includingSelf)
interfacesExtendObject(boolean interfacesExtendObject)
configures whether it should visitObject
at the end of interface extends interface hierarchy.returnTypeReferences(boolean returnTypeReferences)
configures whetherCtType
orCtTypeReference
instances are returned by this mapping functionprotected void
sendResult(CtTypeReference<?> typeRef, CtConsumer<Object> outputConsumer)
setListener(CtScannerListener listener)
The listener evens are called in this order: enter(input element) return input element enter/exit for each super interface of input element recursively call 1-5) recursively where input element is super class of input element exit(input element) Note: this order is assured and some algorithms already depend on it!void
This method is called when the filter/function is added as a step to aCtQuery
by the query engine (CtQueryImpl
).protected void
visitSuperClasses(CtTypeReference<?> superTypeRef, CtConsumer<Object> outputConsumer, boolean includingInterfaces)
calls `outputConsumer.accept(superClass)` for all super classes of superType.protected void
visitSuperInterfaces(CtTypeReference<?> type, CtConsumer<Object> outputConsumer)
calls `outputConsumer.accept(interface)` for all superInterfaces of type recursively.
-
Constructor Details
-
SuperInheritanceHierarchyFunction
public SuperInheritanceHierarchyFunction()The mapping function created using this constructor will visit each super class and super interface following super hierarchy. It can happen that some interfaces will be visited more then once if they are in super inheritance hierarchy more then once.
Use second constructor if you want to visit each interface only once. -
SuperInheritanceHierarchyFunction
The mapping function created using this constructor will visit each super class and super interface following super hierarchy. It is assured that interfaces will be visited only once even if they are in super inheritance hierarchy more then once.- Parameters:
visitedSet
- assures that each class/interface is visited only once The types which are already contained in `visitedSet` are not visited and not returned by this mapping function.
-
-
Method Details
-
includingSelf
- Parameters:
includingSelf
- if true then input element is sent to output too. By default it is false.
-
includingInterfaces
- Parameters:
includingInterfaces
- if false then interfaces are not visited - only super classes. By default it is true.
-
returnTypeReferences
configures whetherCtType
orCtTypeReference
instances are returned by this mapping function- Parameters:
returnTypeReferences
- if true thenCtTypeReference
instances are returned by this mapping function- Returns:
- this to support fluent API
-
interfacesExtendObject
configures whether it should visitObject
at the end of interface extends interface hierarchy. Note: interface cannot extend Object (only other interfaces), but note that interface inherits all public type members ofObject
, so there are use cases where client wants to visit Object as last member of interface inheritance hierarchy- Parameters:
interfacesExtendObject
- if true thenObject
is visited at the end too- Returns:
- this to support fluent API
-
setListener
The listener evens are called in this order:- enter(input element)
- return input element
- enter/exit for each super interface of input element recursively
- call 1-5) recursively where input element is super class of input element
- exit(input element)
- Parameters:
listener
- the implementation ofCtScannerListener
, which will listen for enter/exit ofCtTypeReference
during type hierarchy scanning- Returns:
- this to support fluent API
-
failOnClassNotFound
- Parameters:
failOnClassNotFound
- sets whether processing should throw an exception if class is missing in noClassPath mode
-
apply
Description copied from interface:CtConsumableFunction
Evaluates the function on the given input.- Specified by:
apply
in interfaceCtConsumableFunction<CtTypeInformation>
- Parameters:
input
- the input of the functionoutputConsumer
- the consumer which accepts the results of this function.
-
visitSuperClasses
protected void visitSuperClasses(CtTypeReference<?> superTypeRef, CtConsumer<Object> outputConsumer, boolean includingInterfaces)calls `outputConsumer.accept(superClass)` for all super classes of superType.- Parameters:
superTypeRef
- the reference to a class. This method is called only for classes. Never for interfaceincludingInterfaces
- if true then all superInterfaces of each type are sent to `outputConsumer` too.
-
visitSuperInterfaces
calls `outputConsumer.accept(interface)` for all superInterfaces of type recursively. -
setQuery
Description copied from interface:CtQueryAware
This method is called when the filter/function is added as a step to aCtQuery
by the query engine (CtQueryImpl
).- Specified by:
setQuery
in interfaceCtQueryAware
- Parameters:
query
- an instance registering this function/filter.
-
sendResult
-