Package io.sundr.model.repo
Class MethodReference
java.lang.Object
io.sundr.model.repo.MethodReference
Represents a method reference along with its owning TypeDef.
Provides functionality to analyze method dependencies and find all method references
that are called directly or transitively from a given method.
-
Constructor Summary
ConstructorsConstructorDescriptionMethodReference(Method method, TypeDef owningType) Visitor that collects all MethodCall instances found during AST traversal. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClears the method resolution cache.booleanstatic Set<MethodReference>getDirectMethodCallers(MethodReference targetMethod, DefinitionRepository repository) Find all methods that directly call the specified target method.static Set<MethodReference>getDirectMethodReferences(Method method, DefinitionRepository repository) Get all method references that are called directly from the given method (non-recursive).static Set<MethodReference>getMethodCallers(MethodReference targetMethod, DefinitionRepository repository) Find all methods that directly or transitively call the specified target method.static Set<MethodReference>getMethodReferences(Method method) Get all method references that are called directly or transitively from the given method.static Set<MethodReference>getMethodReferences(Method method, DefinitionRepository repository) Get all method references that are called directly or transitively from the given method.inthashCode()toString()
-
Constructor Details
-
MethodReference
Visitor that collects all MethodCall instances found during AST traversal. This includes both direct method calls and method calls embedded within expressions.
-
-
Method Details
-
getMethod
-
getOwningType
-
getDirectMethodReferences
public static Set<MethodReference> getDirectMethodReferences(Method method, DefinitionRepository repository) Get all method references that are called directly from the given method (non-recursive). This method analyzes only the method body to find direct method calls.- Parameters:
method- the method to analyze (cannot be null)repository- the definition repository containing type definitions (cannot be null)- Returns:
- set of direct method references
- Throws:
IllegalArgumentException- if method or repository is null
-
getMethodReferences
public static Set<MethodReference> getMethodReferences(Method method, DefinitionRepository repository) Get all method references that are called directly or transitively from the given method. This method analyzes the method body and recursively follows method calls to find all methods from types in the DefinitionRepository that are referenced.- Parameters:
method- the method to analyze (cannot be null)repository- the definition repository containing type definitions (cannot be null)- Returns:
- set of all method references (direct and transitive)
- Throws:
IllegalArgumentException- if method or repository is null
-
getMethodReferences
Get all method references that are called directly or transitively from the given method. This method uses the default DefinitionRepository instance.- Parameters:
method- the method to analyze (cannot be null)- Returns:
- set of all method references (direct and transitive)
- Throws:
IllegalArgumentException- if method is null
-
getDirectMethodCallers
public static Set<MethodReference> getDirectMethodCallers(MethodReference targetMethod, DefinitionRepository repository) Find all methods that directly call the specified target method. This is the reverse of getDirectMethodReferences() - instead of finding what a method calls, this finds what methods call the target method.- Parameters:
targetMethod- the method reference to find callers forrepository- the definition repository containing type definitions- Returns:
- set of method references that directly call the target method
-
getMethodCallers
public static Set<MethodReference> getMethodCallers(MethodReference targetMethod, DefinitionRepository repository) Find all methods that directly or transitively call the specified target method. This is the reverse of getMethodReferences() - instead of finding what a method calls, this finds all methods that call the target method either directly or through a chain of calls.- Parameters:
targetMethod- the method reference to find callers forrepository- the definition repository containing type definitions- Returns:
- set of method references that directly or transitively call the target method
-
clearCache
public static void clearCache()Clears the method resolution cache. This should be called when the repository changes to ensure cached results remain valid. -
equals
-
hashCode
public int hashCode() -
toString
-