Class MethodResolutionLogic
java.lang.Object
com.github.javaparser.resolution.logic.MethodResolutionLogic
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
areOverride
(MethodUsage winningCandidate, MethodUsage other) private static ResolvedArrayType
private static <T> Predicate
<T> distinctByKey
(Function<? super T, ?> keyExtractor) Filters by given function using a stateful filter mechanism.private static ResolvedType
findCommonType
(List<ResolvedType> variadicValues) findMostApplicable
(List<ResolvedMethodDeclaration> methods, String name, List<ResolvedType> argumentsTypes, TypeSolver typeSolver) findMostApplicable
(List<ResolvedMethodDeclaration> methods, String name, List<ResolvedType> argumentsTypes, TypeSolver typeSolver, boolean wildcardTolerance) static Optional
<MethodUsage> findMostApplicableUsage
(List<MethodUsage> methods, String name, List<ResolvedType> argumentsTypes, TypeSolver typeSolver) private static int
getLastParameterIndex
(int countOfMethodParametersDeclared) private static ResolvedType
private static List
<ResolvedType> groupTrailingArgumentsIntoArray
(ResolvedMethodDeclaration methodDeclaration, List<ResolvedType> needleArgumentTypes, ResolvedType expectedVariadicParameterType) private static List
<ResolvedType> groupVariadicParamValues
(List<ResolvedType> argumentsTypes, int startVariadic, ResolvedType variadicType) private static void
inferTypes
(ResolvedType source, ResolvedType target, Map<ResolvedTypeParameterDeclaration, ResolvedType> mappings) static boolean
isApplicable
(ResolvedMethodDeclaration method, String name, List<ResolvedType> argumentsTypes, TypeSolver typeSolver) private static boolean
isApplicable
(ResolvedMethodDeclaration methodDeclaration, String needleName, List<ResolvedType> needleArgumentTypes, TypeSolver typeSolver, boolean withWildcardTolerance) Note the specific naming here -- parameters are part of the method declaration, while arguments are the values passed when calling a method.static boolean
isApplicable
(MethodUsage methodUsage, String needleName, List<ResolvedType> needleParameterTypes, TypeSolver typeSolver) Note the specific naming here -- parameters are part of the method declaration, while arguments are the values passed when calling a method.private static boolean
isArrayOfObject
(ResolvedType type) static boolean
isAssignableMatchTypeParameters
(ResolvedReferenceType expected, ResolvedReferenceType actual, Map<String, ResolvedType> matchedParameters) static boolean
isAssignableMatchTypeParameters
(ResolvedType expected, ResolvedType actual, Map<String, ResolvedType> matchedParameters) private static boolean
isAssignableMatchTypeParametersMatchingQName
(ResolvedReferenceType expected, ResolvedReferenceType actual, Map<String, ResolvedType> matchedParameters) protected static boolean
isExactMatch
(ResolvedMethodLikeDeclaration method, List<ResolvedType> argumentsTypes) private static boolean
isJavaLangObject
(ResolvedType paramType) private static boolean
isMoreSpecific
(ResolvedMethodDeclaration methodA, ResolvedMethodDeclaration methodB, List<ResolvedType> argumentTypes) private static boolean
isMoreSpecific
(MethodUsage methodA, MethodUsage methodB) private static boolean
matchTypeVariable
(ResolvedTypeVariable typeVariable, ResolvedType type, Map<String, ResolvedType> matchedParameters) static ResolvedType
replaceTypeParam
(ResolvedType type, ResolvedTypeParameterDeclaration tp, TypeSolver typeSolver) solveMethodInType
(ResolvedTypeDeclaration typeDeclaration, String name, List<ResolvedType> argumentsTypes) solveMethodInType
(ResolvedTypeDeclaration typeDeclaration, String name, List<ResolvedType> argumentsTypes, boolean staticOnly)
-
Field Details
-
JAVA_LANG_OBJECT
-
-
Constructor Details
-
MethodResolutionLogic
public MethodResolutionLogic()
-
-
Method Details
-
groupVariadicParamValues
private static List<ResolvedType> groupVariadicParamValues(List<ResolvedType> argumentsTypes, int startVariadic, ResolvedType variadicType) -
findCommonType
-
isApplicable
public static boolean isApplicable(ResolvedMethodDeclaration method, String name, List<ResolvedType> argumentsTypes, TypeSolver typeSolver) -
isApplicable
private static boolean isApplicable(ResolvedMethodDeclaration methodDeclaration, String needleName, List<ResolvedType> needleArgumentTypes, TypeSolver typeSolver, boolean withWildcardTolerance) Note the specific naming here -- parameters are part of the method declaration, while arguments are the values passed when calling a method. Note that "needle" refers to that value being used as a search/query term to match against.- Returns:
- true, if the given ResolvedMethodDeclaration matches the given name/types (normally obtained from a MethodUsage)
-
isArrayOfObject
-
convertToVariadicParameter
-
getLastParameterIndex
private static int getLastParameterIndex(int countOfMethodParametersDeclared) -
groupTrailingArgumentsIntoArray
private static List<ResolvedType> groupTrailingArgumentsIntoArray(ResolvedMethodDeclaration methodDeclaration, List<ResolvedType> needleArgumentTypes, ResolvedType expectedVariadicParameterType) -
isAssignableMatchTypeParameters
public static boolean isAssignableMatchTypeParameters(ResolvedType expected, ResolvedType actual, Map<String, ResolvedType> matchedParameters) -
isAssignableMatchTypeParameters
public static boolean isAssignableMatchTypeParameters(ResolvedReferenceType expected, ResolvedReferenceType actual, Map<String, ResolvedType> matchedParameters) -
isAssignableMatchTypeParametersMatchingQName
private static boolean isAssignableMatchTypeParametersMatchingQName(ResolvedReferenceType expected, ResolvedReferenceType actual, Map<String, ResolvedType> matchedParameters) -
matchTypeVariable
private static boolean matchTypeVariable(ResolvedTypeVariable typeVariable, ResolvedType type, Map<String, ResolvedType> matchedParameters) -
replaceTypeParam
public static ResolvedType replaceTypeParam(ResolvedType type, ResolvedTypeParameterDeclaration tp, TypeSolver typeSolver) -
isApplicable
public static boolean isApplicable(MethodUsage methodUsage, String needleName, List<ResolvedType> needleParameterTypes, TypeSolver typeSolver) Note the specific naming here -- parameters are part of the method declaration, while arguments are the values passed when calling a method. Note that "needle" refers to that value being used as a search/query term to match against.- Returns:
- true, if the given MethodUsage matches the given name/types (normally obtained from a ResolvedMethodDeclaration)
-
distinctByKey
Filters by given function using a stateful filter mechanism.persons.stream().filter(distinctByKey(Person::getName))
The example above would return a distinct list of persons containing only one person per name.
-
findMostApplicable
public static SymbolReference<ResolvedMethodDeclaration> findMostApplicable(List<ResolvedMethodDeclaration> methods, String name, List<ResolvedType> argumentsTypes, TypeSolver typeSolver) - Parameters:
methods
- we expect the methods to be ordered such that inherited methods are later in the list
-
findMostApplicable
public static SymbolReference<ResolvedMethodDeclaration> findMostApplicable(List<ResolvedMethodDeclaration> methods, String name, List<ResolvedType> argumentsTypes, TypeSolver typeSolver, boolean wildcardTolerance) -
isExactMatch
protected static boolean isExactMatch(ResolvedMethodLikeDeclaration method, List<ResolvedType> argumentsTypes) -
getMethodsExplicitAndVariadicParameterType
private static ResolvedType getMethodsExplicitAndVariadicParameterType(ResolvedMethodDeclaration method, int i) -
isMoreSpecific
private static boolean isMoreSpecific(ResolvedMethodDeclaration methodA, ResolvedMethodDeclaration methodB, List<ResolvedType> argumentTypes) -
isJavaLangObject
-
isMoreSpecific
-
findMostApplicableUsage
public static Optional<MethodUsage> findMostApplicableUsage(List<MethodUsage> methods, String name, List<ResolvedType> argumentsTypes, TypeSolver typeSolver) -
areOverride
-
solveMethodInType
public static SymbolReference<ResolvedMethodDeclaration> solveMethodInType(ResolvedTypeDeclaration typeDeclaration, String name, List<ResolvedType> argumentsTypes) -
solveMethodInType
public static SymbolReference<ResolvedMethodDeclaration> solveMethodInType(ResolvedTypeDeclaration typeDeclaration, String name, List<ResolvedType> argumentsTypes, boolean staticOnly) -
inferTypes
private static void inferTypes(ResolvedType source, ResolvedType target, Map<ResolvedTypeParameterDeclaration, ResolvedType> mappings)
-