Package org.ek9lang.compiler.search
Class MethodSymbolSearchResult
java.lang.Object
org.ek9lang.compiler.search.MethodSymbolSearchResult
Models a set of result for a search for methods.
-
Constructor Summary
ConstructorDescriptionMethodSymbolSearchResult
(MethodSymbolSearchResult startWithResults) New results that contain the result passed in. -
Method Summary
Modifier and TypeMethodDescriptionadd
(List<WeightedMethodSymbolMatch> moreResults) Add more results and sort the list held.add
(WeightedMethodSymbolMatch weightedMethodSymbolMatch) Add a result and sort the list held.Get the parameters that are considered ambiguous and the line they are on.If there is a single best match for the search; then return it.boolean
boolean
Found more than one matching method.boolean
isEmpty()
boolean
boolean
Is there a single best match available.mergePeerToNewResult
(MethodSymbolSearchResult withResults) Typically used with traits and class/trait combinations so that multiple methods of the same name and parameters.overrideToNewResult
(MethodSymbolSearchResult withResults) So now let's imagine we have a set of results from various interfaces and classes (maybe using method above to accumulate the methods) But now you are dealing with a Class or a Trait - now we need to know that for all the methods that could be called we only have one single one that would be resolved.void
setAccessModifierIncompatible
(boolean accessModifierIncompatible) void
setMethodNotMarkedWithOverride
(boolean methodNotMarkedWithOverride) Converts the results to a list of match results that are ordered by cost and can be displayed.toString()
-
Constructor Details
-
MethodSymbolSearchResult
public MethodSymbolSearchResult() -
MethodSymbolSearchResult
New results that contain the result passed in.
-
-
Method Details
-
isAccessModifierIncompatible
public boolean isAccessModifierIncompatible() -
setAccessModifierIncompatible
public void setAccessModifierIncompatible(boolean accessModifierIncompatible) -
isMethodNotMarkedWithOverride
public boolean isMethodNotMarkedWithOverride() -
setMethodNotMarkedWithOverride
public void setMethodNotMarkedWithOverride(boolean methodNotMarkedWithOverride) -
mergePeerToNewResult
Typically used with traits and class/trait combinations so that multiple methods of the same name and parameters. These are merged together this may then mean that the results have two results of the same weight and this indicates ambiguity. So for example if you had ClassA implementing interfaceZ (lets say default method methodBoo in interfaceZ) all is good. Now say we have interfaceP (also with method methodBoo) and now add ClassK that extends ClassA and implements interfaceP. We now have a situation where 'methodBoo' has two default implementations (diamond-ish); and therefore we must define one in ClassK. We need to know that there are two methods that would match via different routes. it's not the case where one has overridden the other that's what default methods in traits/interfaces has introduced.- Parameters:
withResults
- The results to merge in- Returns:
- A new set of results - does not alter either of the two sets being merged.
-
overrideToNewResult
So now let's imagine we have a set of results from various interfaces and classes (maybe using method above to accumulate the methods) But now you are dealing with a Class or a Trait - now we need to know that for all the methods that could be called we only have one single one that would be resolved. If this is not the case then it is an indicator that the method should be implemented in the class so as tobe explicit which implementation is to be used. So we will be checking for matching method name and parameters and compatible covariance return types.- Parameters:
withResults
- The set of methods that can be used to override one or more results.- Returns:
- A new set of results - does not alter either of the two sets being merged.
-
getSingleBestMatchSymbol
If there is a single best match for the search; then return it. -
isSingleBestMatchPresent
public boolean isSingleBestMatchPresent()Is there a single best match available. Could be there are no results, could be a single (very good result - perfect match), Could be a match but not perfect but acceptable. But could also be several results. Of equal weight; in which case we have an ambiguity.- Returns:
- true if there is a single best match.
-
isAmbiguous
public boolean isAmbiguous()Found more than one matching method. -
getAmbiguousMethodParameters
Get the parameters that are considered ambiguous and the line they are on. -
toMatchResults
Converts the results to a list of match results that are ordered by cost and can be displayed. -
toString
-
isEmpty
public boolean isEmpty() -
add
Add more results and sort the list held. -
add
Add a result and sort the list held.
-