Class AbstractPendingLinkingCandidate<Expression extends XExpression>
- java.lang.Object
-
- org.eclipse.xtext.xbase.typesystem.internal.AbstractLinkingCandidate<Expression>
-
- org.eclipse.xtext.xbase.typesystem.internal.AbstractPendingLinkingCandidate<Expression>
-
- All Implemented Interfaces:
IApplicableCandidate,ILinkingCandidate
- Direct Known Subclasses:
ConstructorLinkingCandidate,FeatureLinkingCandidate,TypeLiteralLinkingCandidate
public abstract class AbstractPendingLinkingCandidate<Expression extends XExpression> extends AbstractLinkingCandidate<Expression>
Abstract base for linking candidates that attempt to resolve features which are not yet bound. This implements the overload resolution and disambiguation. That is, it can be compared to another candidate and return the better match.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.xtext.xbase.typesystem.internal.AbstractLinkingCandidate
AbstractLinkingCandidate.ArgumentTypeComputationState, AbstractLinkingCandidate.ObservableTypeExpectation
-
-
Field Summary
Fields Modifier and Type Field Description protected IIdentifiableElementDescriptiondescriptionThe backing feature descriptions.-
Fields inherited from class org.eclipse.xtext.xbase.typesystem.internal.AbstractLinkingCandidate
arguments, typeArguments
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractPendingLinkingCandidate(Expression expression, IIdentifiableElementDescription description, ITypeExpectation expectation, ExpressionTypeComputationState state)protectedAbstractPendingLinkingCandidate(Expression expression, IIdentifiableElementDescription description, ITypeExpectation expectation, ExpressionTypeComputationState state, PendingLinkingCandidateResolver<Expression> pendingLinkingCandidateResolver)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected CandidateCompareResultcompareByArgumentTypes(AbstractPendingLinkingCandidate<?> right)protected CandidateCompareResultcompareByArgumentTypes(AbstractPendingLinkingCandidate<?> right, boolean recompute)protected CandidateCompareResultcompareByArgumentTypes(AbstractPendingLinkingCandidate<?> other, int leftBoxing, int rightBoxing, int leftDemand, int rightDemand)Compare this linking candidate with the givenothercandidate atargumentIndexReturnsCandidateCompareResult#THISif this candidate is better,CandidateCompareResult#OTHERif the right candidate was better,CandidateCompareResult#AMBIGUOUSif both candidates are valid but ambiguous orCandidateCompareResult#EQUALLY_INVALIDif both candidates are ambiguous but erroneous.protected CandidateCompareResultcompareByArgumentTypesFlags(AbstractPendingLinkingCandidate<?> other, int leftIdx, int rightIdx, int leftConformance, int rightConformance)Compare this linking candidate with the givenothercandidate atleftIdxandrightIdxrespectively.protected CandidateCompareResultcompareByArity(int leftArityMismatch, int rightArityMismatch)protected CandidateCompareResultcompareByArityWith(AbstractPendingLinkingCandidate<?> right)protected CandidateCompareResultcompareByBoxing(int leftBoxing, int rightBoxing)protected CandidateCompareResultcompareByBucket(AbstractPendingLinkingCandidate<?> right)protected CandidateCompareResultcompareByName(AbstractPendingLinkingCandidate<?> right)protected CandidateCompareResultcompareByTypeArguments(AbstractPendingLinkingCandidate<?> right)protected intcompareDeclaredTypes(LightweightTypeReference left, LightweightTypeReference right, boolean leftResolved, boolean rightResolved)protected CandidateCompareResultcompareExpectedArgumentTypes(AbstractPendingLinkingCandidate<?> right)protected CandidateCompareResultcompareTo(AbstractPendingLinkingCandidate<?> right)ReturnsCandidateCompareResult#THISif this candidate is better,CandidateCompareResult#OTHERif the right candidate was better,CandidateCompareResult#AMBIGUOUSif both candidates are valid but ambiguous orCandidateCompareResult#EQUALLY_INVALIDif both candidates are ambiguous but erroneous.protected CandidateCompareResultcompareTo(AbstractPendingLinkingCandidate<?> right, boolean invalid)ReturnsCandidateCompareResult#THISif this candidate is better,CandidateCompareResult#OTHERif the right candidate was better,CandidateCompareResult#AMBIGUOUSif both candidates are valid but ambiguous orCandidateCompareResult#EQUALLY_INVALIDif both candidates are ambiguous but erroneous.protected abstract ILinkingCandidatecreateAmbiguousLinkingCandidate(AbstractPendingLinkingCandidate<?> second)Produce a candidate that carries the information about ambiguous candidates.protected ILinkingCandidatecreateSuspiciousLinkingCandidate(AbstractPendingLinkingCandidate<?> chosenCandidate)Produce a candidate that carries the information about suspicious overload resolution where a member on 'this' wins over a member on 'it'.protected com.google.common.hash.HashCodegetAllDescriptionsHash()protected java.lang.StringgetArgumentTypesAsString()Returns the resolved string representation of the argument types.intgetArityMismatch()Returns the mismatch of actually given arguments and declared parameters.protected intgetArityMismatch(org.eclipse.xtext.common.types.JvmExecutable executable, java.util.List<XExpression> arguments)protected intgetConformanceFlags(int idx, boolean recompute)protected org.eclipse.emf.ecore.EReferencegetDefaultValidationFeature()protected CandidateCompareResultgetExpectedTypeCompareResultOther(AbstractPendingLinkingCandidate<?> other)Returns the compare result for the declared parameter types if the given other candidate had won.org.eclipse.xtext.common.types.JvmIdentifiableElementgetFeature()The currently considered feature (if any).protected java.lang.StringgetFeatureParameterTypesAsString()Returns the unresolved string representation of the parameter types of the feature.protected java.lang.StringgetFeatureParameterTypesAsString(org.eclipse.xtext.common.types.JvmExecutable executable)protected abstract java.lang.StringgetFeatureTypeName()Returns the name of the feature type, e.g.protected java.lang.StringgetFeatureTypeParametersAsString(boolean showBounds)Returns the unresolved string representation of the unresolved type parameters of the feature.protected org.eclipse.emf.ecore.EReferencegetInvalidArgumentsValidationFeature()ILinkingCandidategetPreferredCandidate(ILinkingCandidate other)Returns the best candidate considering the this and the given other candidate.protected org.eclipse.xtext.diagnostics.SeveritygetSeverity(java.lang.String issueCode)Returns the current severity for the given issue code.protected java.lang.StringgetSimpleFeatureName()protected java.util.List<XExpression>getSyntacticArguments()protected intgetTypeArgumentConformanceFailures(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> acceptor)protected java.lang.StringgetTypeArgumentsAsString(java.util.List<? extends LightweightTypeReference> typeArguments)Returns the resolved string representation of the type arguments.intgetTypeArityMismatch()protected java.lang.StringgetTypeParameterAsString(org.eclipse.xtext.common.types.JvmTypeParameter typeParameter)Returns the unresolved string representation of the given type parameter.protected java.util.Map<org.eclipse.xtext.common.types.JvmTypeParameter,LightweightMergedBoundTypeArgument>getTypeParameterMapping()Returns the mapping of type parameters to their bound arguments.protected org.eclipse.xtext.diagnostics.SeveritygetUnhandledExceptionSeverity(org.eclipse.xtext.common.types.JvmExecutable executable)Obtain the currently applicable severity for uncaught exceptions.protected booleanisDefiniteEarlyExit(XExpression expression)protected booleanisExtension()protected booleanisLambdaExpression(int argumentIdx)protected booleanisPossibleFunctionType(int idx)Returns false if the argument expression is a lambda and the expected type of the argument is not a function type orObject.protected booleanisVarArgs()protected booleanisVisible()protected voidresolveLinkingProxy(org.eclipse.emf.ecore.EReference structuralFeature, int featureId)protected voidsetAllDescriptionsHash(com.google.common.hash.HashCode hashCode)java.lang.StringtoString()booleanvalidate(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)Validates this linking candidate and adds respective diagnostics to the given queue.protected booleanvalidateArity(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)protected booleanvalidateTypeArgumentConformance(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)protected booleanvalidateTypeArity(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)protected booleanvalidateUnhandledExceptions(org.eclipse.xtext.common.types.JvmExecutable executable, org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)protected booleanvalidateUnhandledExceptions(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)protected booleanvalidateVisibility(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)-
Methods inherited from class org.eclipse.xtext.xbase.typesystem.internal.AbstractLinkingCandidate
accept, applyToComputationState, computeArgumentType, computeArgumentTypes, computeFixedArityArgumentType, computeVarArgumentType, createArgumentTypeSubstitutor, createLinkingTypeComputationState, createVarArgTypeComputationState, deferredBindTypeArgument, discardRefinementTypeIfReassigned, getActualType, getActualType, getArguments, getDeclaratorParameterMapping, getDeclaredType, getDeclaredTypeParameters, getExpectedType, getExpression, getPlainSyntacticTypeArguments, getState, getSubstitutedExpectedType, getSyntacticTypeArguments, getTypeArguments, hasReceiver, initializeArgumentTypeComputation, initializeConstraintMapping, initializeMapping, initializeTypeParameterMapping, initializeTypeParameterMapping, isBoundTypeArgumentSkipped, isRawTypeContext, isTypeLiteral, mustDiscardRefinement, preApply, resolveAgainstActualType, resolveArgumentType
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.xtext.xbase.typesystem.computation.ILinkingCandidate
applyToModel
-
-
-
-
Field Detail
-
description
protected final IIdentifiableElementDescription description
The backing feature descriptions. It carries the information about the potentially resolved feature, e.g. the implicit receiver, whether it's an extension and more.
-
-
Constructor Detail
-
AbstractPendingLinkingCandidate
protected AbstractPendingLinkingCandidate(Expression expression, IIdentifiableElementDescription description, ITypeExpectation expectation, ExpressionTypeComputationState state)
-
AbstractPendingLinkingCandidate
protected AbstractPendingLinkingCandidate(Expression expression, IIdentifiableElementDescription description, ITypeExpectation expectation, ExpressionTypeComputationState state, PendingLinkingCandidateResolver<Expression> pendingLinkingCandidateResolver)
-
-
Method Detail
-
setAllDescriptionsHash
protected void setAllDescriptionsHash(com.google.common.hash.HashCode hashCode)
- Since:
- 2.30
-
getAllDescriptionsHash
protected com.google.common.hash.HashCode getAllDescriptionsHash()
- Since:
- 2.30
-
getTypeParameterMapping
protected java.util.Map<org.eclipse.xtext.common.types.JvmTypeParameter,LightweightMergedBoundTypeArgument> getTypeParameterMapping()
Returns the mapping of type parameters to their bound arguments.- Specified by:
getTypeParameterMappingin classAbstractLinkingCandidate<Expression extends XExpression>- See Also:
AbstractLinkingCandidate.initializeTypeParameterMapping()
-
getFeatureTypeName
protected abstract java.lang.String getFeatureTypeName()
Returns the name of the feature type, e.g. a feature of typeJvmOperationmay returnmethod, aXVariableDeclarationmay identify itself aslocal variable.
-
getArgumentTypesAsString
protected java.lang.String getArgumentTypesAsString()
Returns the resolved string representation of the argument types. The simple names of the types are used. The string representation includes the parenthesis.
-
getFeatureParameterTypesAsString
protected java.lang.String getFeatureParameterTypesAsString()
Returns the unresolved string representation of the parameter types of the feature. The simple names of the types are used. The string representation includes the parenthesis.
-
getFeatureParameterTypesAsString
protected java.lang.String getFeatureParameterTypesAsString(org.eclipse.xtext.common.types.JvmExecutable executable)
-
getFeatureTypeParametersAsString
protected java.lang.String getFeatureTypeParametersAsString(boolean showBounds)
Returns the unresolved string representation of the unresolved type parameters of the feature. The simple names of the type bounds are used. The string representation includes the angle brackets.
-
getTypeParameterAsString
protected java.lang.String getTypeParameterAsString(org.eclipse.xtext.common.types.JvmTypeParameter typeParameter)
Returns the unresolved string representation of the given type parameter. The simple names of the type bounds are used. The string representation includes the bounds, except for the upper boundObject.
-
getTypeArgumentsAsString
protected java.lang.String getTypeArgumentsAsString(java.util.List<? extends LightweightTypeReference> typeArguments)
Returns the resolved string representation of the type arguments. The simple names of the types are used. The string representation includes the angle brackets.
-
validate
public boolean validate(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)
Validates this linking candidate and adds respective diagnostics to the given queue. This checks the following criteria:- Returns:
trueif further validation should be performed.
-
validateVisibility
protected boolean validateVisibility(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)
-
getSimpleFeatureName
protected java.lang.String getSimpleFeatureName()
-
getDefaultValidationFeature
protected org.eclipse.emf.ecore.EReference getDefaultValidationFeature()
-
getInvalidArgumentsValidationFeature
protected org.eclipse.emf.ecore.EReference getInvalidArgumentsValidationFeature()
-
validateArity
protected boolean validateArity(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)
-
validateTypeArity
protected boolean validateTypeArity(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)
-
validateTypeArgumentConformance
protected boolean validateTypeArgumentConformance(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)
-
validateUnhandledExceptions
protected boolean validateUnhandledExceptions(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)
-
validateUnhandledExceptions
protected boolean validateUnhandledExceptions(org.eclipse.xtext.common.types.JvmExecutable executable, org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> result)
-
getUnhandledExceptionSeverity
protected org.eclipse.xtext.diagnostics.Severity getUnhandledExceptionSeverity(org.eclipse.xtext.common.types.JvmExecutable executable)
Obtain the currently applicable severity for uncaught exceptions. Sneaky throw techniques cannot be applied to delegating constructor calls. Therefore it's possible to raise the severity for them by checking the linked executable.- Parameters:
executable- the executable that declares the exception.
-
getSeverity
protected org.eclipse.xtext.diagnostics.Severity getSeverity(java.lang.String issueCode)
Returns the current severity for the given issue code.
-
isDefiniteEarlyExit
protected boolean isDefiniteEarlyExit(XExpression expression)
-
getSyntacticArguments
protected java.util.List<XExpression> getSyntacticArguments()
-
getPreferredCandidate
public ILinkingCandidate getPreferredCandidate(ILinkingCandidate other)
Returns the best candidate considering the this and the given other candidate. The result is not necessarily this or the other, but may also be a third instance, e.g. in order to disambiguate certain error conditions.
-
createAmbiguousLinkingCandidate
protected abstract ILinkingCandidate createAmbiguousLinkingCandidate(AbstractPendingLinkingCandidate<?> second)
Produce a candidate that carries the information about ambiguous candidates.
-
createSuspiciousLinkingCandidate
protected ILinkingCandidate createSuspiciousLinkingCandidate(AbstractPendingLinkingCandidate<?> chosenCandidate)
Produce a candidate that carries the information about suspicious overload resolution where a member on 'this' wins over a member on 'it'.- Parameters:
chosenCandidate- the candidate that was picked.
-
compareTo
protected final CandidateCompareResult compareTo(AbstractPendingLinkingCandidate<?> right)
ReturnsCandidateCompareResult#THISif this candidate is better,CandidateCompareResult#OTHERif the right candidate was better,CandidateCompareResult#AMBIGUOUSif both candidates are valid but ambiguous orCandidateCompareResult#EQUALLY_INVALIDif both candidates are ambiguous but erroneous.
-
compareTo
protected CandidateCompareResult compareTo(AbstractPendingLinkingCandidate<?> right, boolean invalid)
ReturnsCandidateCompareResult#THISif this candidate is better,CandidateCompareResult#OTHERif the right candidate was better,CandidateCompareResult#AMBIGUOUSif both candidates are valid but ambiguous orCandidateCompareResult#EQUALLY_INVALIDif both candidates are ambiguous but erroneous. The invalid flag indicates if we already know that both candidates are equally invalid.
-
compareByName
protected CandidateCompareResult compareByName(AbstractPendingLinkingCandidate<?> right)
-
compareByBucket
protected CandidateCompareResult compareByBucket(AbstractPendingLinkingCandidate<?> right)
-
isVisible
protected boolean isVisible()
-
isVarArgs
protected boolean isVarArgs()
-
isExtension
protected boolean isExtension()
-
compareByArgumentTypes
protected CandidateCompareResult compareByArgumentTypes(AbstractPendingLinkingCandidate<?> right)
-
compareByTypeArguments
protected CandidateCompareResult compareByTypeArguments(AbstractPendingLinkingCandidate<?> right)
-
getTypeArgumentConformanceFailures
protected int getTypeArgumentConformanceFailures(org.eclipse.xtext.util.IAcceptor<? super org.eclipse.xtext.diagnostics.AbstractDiagnostic> acceptor)
-
compareByArgumentTypes
protected CandidateCompareResult compareByArgumentTypes(AbstractPendingLinkingCandidate<?> right, boolean recompute)
-
compareByArgumentTypesFlags
protected CandidateCompareResult compareByArgumentTypesFlags(AbstractPendingLinkingCandidate<?> other, int leftIdx, int rightIdx, int leftConformance, int rightConformance)
Compare this linking candidate with the givenothercandidate atleftIdxandrightIdxrespectively. ReturnsCandidateCompareResult#THISif this candidate is better,CandidateCompareResult#OTHERif the right candidate was better,CandidateCompareResult#AMBIGUOUSif both candidates are valid but ambiguous orCandidateCompareResult#EQUALLY_INVALIDif both candidates are ambiguous but erroneous.- Parameters:
other- the other candidateleftIdx- the semantic argument index on this candidaterightIdx- the semantic argument index on the other candidateleftConformance- the computed conformance in this linking candidaterightConformance- the computed conformance if the other candidate was chosen
-
compareByArgumentTypes
protected CandidateCompareResult compareByArgumentTypes(AbstractPendingLinkingCandidate<?> other, int leftBoxing, int rightBoxing, int leftDemand, int rightDemand)
Compare this linking candidate with the givenothercandidate atargumentIndexReturnsCandidateCompareResult#THISif this candidate is better,CandidateCompareResult#OTHERif the right candidate was better,CandidateCompareResult#AMBIGUOUSif both candidates are valid but ambiguous orCandidateCompareResult#EQUALLY_INVALIDif both candidates are ambiguous but erroneous.- Parameters:
other- the other candidate (the rhs of the comparison)leftBoxing- the number of required boxing conversions if this candidate was chosenrightBoxing- the number of required boxing conversions if the other candidate was chosenleftDemand- the number of required demand conversions if this candidate was chosenrightDemand- the number of required demand conversions if the other candidate was chosen
-
compareByBoxing
protected CandidateCompareResult compareByBoxing(int leftBoxing, int rightBoxing)
-
isPossibleFunctionType
protected boolean isPossibleFunctionType(int idx)
Returns false if the argument expression is a lambda and the expected type of the argument is not a function type orObject. Returns true in all other cases. This serves as a shortcut to rule out decision path's where a method is overloaded and one of the overloads accepts a function type but the other doesn't. In those cases it is not necessary to compute the type of the lamdba expression twice. An example for this pattern isIterableExtensions.filter(Iterable, Class)vsIterableExtensions.filter(Iterable, org.eclipse.xtext.xbase.lib.Functions.Function1).
-
getConformanceFlags
protected int getConformanceFlags(int idx, boolean recompute)
-
isLambdaExpression
protected boolean isLambdaExpression(int argumentIdx)
-
compareExpectedArgumentTypes
protected CandidateCompareResult compareExpectedArgumentTypes(AbstractPendingLinkingCandidate<?> right)
-
compareDeclaredTypes
protected int compareDeclaredTypes(LightweightTypeReference left, LightweightTypeReference right, boolean leftResolved, boolean rightResolved)
-
getExpectedTypeCompareResultOther
protected CandidateCompareResult getExpectedTypeCompareResultOther(AbstractPendingLinkingCandidate<?> other)
Returns the compare result for the declared parameter types if the given other candidate had won.- Parameters:
other- the winner of the comparison.
-
compareByArityWith
protected CandidateCompareResult compareByArityWith(AbstractPendingLinkingCandidate<?> right)
-
compareByArity
protected CandidateCompareResult compareByArity(int leftArityMismatch, int rightArityMismatch)
-
getArityMismatch
public int getArityMismatch()
Returns the mismatch of actually given arguments and declared parameters. Receivers and staticness of the feature is taken into account, too. The mismatch may either be negative or positive.
-
getTypeArityMismatch
public int getTypeArityMismatch()
-
resolveLinkingProxy
protected void resolveLinkingProxy(org.eclipse.emf.ecore.EReference structuralFeature, int featureId)
-
getArityMismatch
protected int getArityMismatch(org.eclipse.xtext.common.types.JvmExecutable executable, java.util.List<XExpression> arguments)
-
getFeature
public org.eclipse.xtext.common.types.JvmIdentifiableElement getFeature()
Description copied from interface:ILinkingCandidateThe currently considered feature (if any). Otherwisenull.- Specified by:
getFeaturein interfaceILinkingCandidate- Specified by:
getFeaturein classAbstractLinkingCandidate<Expression extends XExpression>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-