public abstract class FuzzyMethodLookup
extends java.lang.Object
| Constructor and Description |
|---|
FuzzyMethodLookup() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract java.util.List<MatchMetrics> |
candidates(java.lang.String name,
int num,
int access,
boolean isStatic,
boolean internal,
boolean first,
java.util.Set<SignatureKey> exist)
Get the list of all possible methods that could match in this class AND its parent classes.
|
private boolean |
filterList(java.util.List<MatchMetrics> list,
java.util.function.Predicate<MatchMetrics> test,
int idx,
java.lang.String callerType,
java.lang.String[] error)
Check if there is only 1 or more possible match for the given predicate, if so then remove all
candidates from the list except for the possible matches.
|
private java.lang.String |
fromJava(java.lang.String type)
Convert the specified Java-style type to a legacy BDT compatible type, if possible.
|
protected MethodSearchResult |
fuzzyMethodLookup(java.lang.String name,
ParameterKey[] caller,
int access,
boolean isStatic,
boolean internal,
Aast node)
Find the named method based on a fuzzy signature match.
|
protected abstract java.lang.String |
getClassName()
Get the class name where this method lookup starts from.
|
private int |
getExtent(java.lang.String sig)
Get the extent value from a parameter's type.
|
protected abstract boolean |
isImplemented(java.lang.String caller,
java.lang.String callee)
Detect if the callee class is an instance of an implemented interface of the caller class.
|
protected abstract boolean |
isInheritedFrom(java.lang.String caller,
java.lang.String callee,
java.lang.Runnable incrementer)
Detect if the callee class is an instance of a parent class or an implemented interface of a parent
class, of the caller.
|
private boolean |
isNarrowingTypeMatch(java.lang.String caller,
java.lang.String callee,
java.lang.Runnable incrementer)
Check if the callee's type can be written back to a wider caller's type, when viewed from the
caller to callee, this looks like a "narrowing" operation.
|
protected abstract boolean |
isSetParam(java.lang.String method)
Reports if the class name is Progress.Lang.ParameterList and the method name is
setParameter(). |
private boolean |
isWideningTypeMatch(java.lang.String caller,
java.lang.String callee,
java.lang.Runnable incrementer)
Check if the caller's type can be matched to a wider type in the callee's signature.
|
private boolean |
processExactMatches(java.util.List<MatchMetrics> list,
java.util.function.Predicate<MatchMetrics> exactMatch)
Remove any non-exact matches from the given list.
|
private void |
processExtentMatches(java.util.List<MatchMetrics> list,
int callerExtVal,
int idx)
Remove any candidates from the list which do not match the caller's extent.
|
protected abstract java.lang.String getClassName()
protected abstract boolean isImplemented(java.lang.String caller,
java.lang.String callee)
caller - The caller type.callee - The callee type.true if the given class is an implemented interface in this class.protected abstract boolean isInheritedFrom(java.lang.String caller,
java.lang.String callee,
java.lang.Runnable incrementer)
caller - The caller type.callee - The callee type to check.incrementer - Code to be executed to increment the inheritance level.true if the given class is a parent class or an implemented interface of a parent
class.protected abstract boolean isSetParam(java.lang.String method)
setParameter().method - The method name.true if this is a setParameter call.protected abstract java.util.List<MatchMetrics> candidates(java.lang.String name, int num, int access, boolean isStatic, boolean internal, boolean first, java.util.Set<SignatureKey> exist)
name - Method name.num - Number of parameters.access - Access mode (KW_PUBLIC, KW_PROTECTD or KW_PRIVATE).isStatic - If true, only static methods will be looked up. Otherwise any method can be
returned.internal - true if the lookup is internal to the current class definition.first - true if the first match should be immediately returned as the result.exist - The set of existing methods already represented in the list.protected MethodSearchResult fuzzyMethodLookup(java.lang.String name, ParameterKey[] caller, int access, boolean isStatic, boolean internal, Aast node)
name - Resource name.caller - Method call signature.access - Access mode (KW_PUBLIC, KW_PROTECTD or
KW_PRIVATE).isStatic - If true, only static methods will be looked up.
Otherwise any method can be returned.internal - true if the lookup is internal to the current class definition.node - The AST referencing this method.null if no match exists.private java.lang.String fromJava(java.lang.String type)
type - The Java type, in jobject> extends< format.private boolean isWideningTypeMatch(java.lang.String caller,
java.lang.String callee,
java.lang.Runnable incrementer)
Primitive types widen as follows:
Caller Type Callee Parameter Types -------------- ---------------------- integer int64, decimal int64 decimal character longchar date datetime, datetime-tz datetime datetime-tz
Object types widen by these rules:
caller - The caller's passed instance's data type.callee - The candidate callee method's parameter data type.incrementer - Code to be executed to increment the inheritance level.true if a widening operation is possible.private boolean isNarrowingTypeMatch(java.lang.String caller,
java.lang.String callee,
java.lang.Runnable incrementer)
Primitive types narrow as follows:
Caller Type Callee Parameter Types -------------- ---------------------- int64 integer decimal integer, int64 longchar character datetime date datetime-tz date, datetime
Object types narrow by these rules:
caller - The caller's passed instance's data type.callee - The candidate callee method's parameter data type.incrementer - Code to be executed to increment the inheritance level.true if a narrowing operation is possible.private boolean filterList(java.util.List<MatchMetrics> list, java.util.function.Predicate<MatchMetrics> test, int idx, java.lang.String callerType, java.lang.String[] error)
list - The list to edit.test - The predicate to test.idx - The parameter index for error messages.callerType - The caller type for error messages.error - A location to store an error message for the caller.private boolean processExactMatches(java.util.List<MatchMetrics> list, java.util.function.Predicate<MatchMetrics> exactMatch)
list - The list to edit.exactMatch - The test for an exact match.true if edits were made.private void processExtentMatches(java.util.List<MatchMetrics> list, int callerExtVal, int idx)
list - The list of candidates.callerExtVal - Caller's extent value (-1 means indeterminate, 0 is scalar and any positive value is
the fixed extent).idx - Parameter number being processed.private int getExtent(java.lang.String sig)
sig - The parameter's type.