Interface AnaphorResolutionStrategy<N,E,T,B,TB extends B,S,I,QI,R extends RelatedExpression<N,T,B,TB,S,QI,R>,A extends ASTBasedAnaphora<N,E,T,B,TB,S,I,QI,R,A>>
- Type Parameters:
N- The node type in the ASTE- The expression typeT- The type typeB- The binding typeTB- The type binding typeS- The scope type (optional)I- The type used to represent identifiersQI- The type used to represent qualified identifiersR- The sub-type of related expression to useA- The sub-type of AST-based anaphora to use
- All Superinterfaces:
Strategy
- All Known Subinterfaces:
AnchoringStrategy<N,E,T,B,TB,S,I,QI,R,A>,StoresAnchorInLocalTempVariable<N,E,T,B,TB,S,I,QI,R,A>,StoresReferentInLocalTempVariable<N,E,T,B,TB,S,I,QI,R,A>
- All Known Implementing Classes:
AbstractAnaphorResolutionStrategy,AbstractAnchoringStrategy,DA1ReStrategy,IA1MrStrategy,IA2FStrategy,IA2MgStrategy
public interface AnaphorResolutionStrategy<N,E,T,B,TB extends B,S,I,QI,R extends RelatedExpression<N,T,B,TB,S,QI,R>,A extends ASTBasedAnaphora<N,E,T,B,TB,S,I,QI,R,A>> extends Strategy
-
Method Summary
Modifier and Type Method Description booleancanRelateTo(RelatedExpressionStrategy<N,T,B,TB,S,QI,R> potentialRelatedExpressionStrategy)Used to decide whether this strategy can create potential anaphora relations for the given potential related expression.AcreateAnaphora(S scope, String anaphor, E anaphorExpression, R potentialRelatedExpression, Referent<TB,S,I,QI> potentialReferent, ReferentializationStrategy<E,TB,S,I,QI> refStrategy)Create a single potentialASTBasedAnaphorarelation for a pair of anaphor (TODO: definite expression) and a potential related expression.Referent<TB,S,I,QI>createReferent(S scope, R relatedExpression, Object memento)Re-creates a referent from a given related expression and memento.List<A>generatePotentialAnaphora(S scope, String anaphor, E anaphorExpression, List<R> potentialRelatedExpressions, List<ReferentializationStrategy<E,TB,S,I,QI>> refStrategies)Generates a list of potentialASTBasedAnaphorarelations.StringgetAnaphorToBeRealized(RelatedExpressionPart<N,E,T,B,TB,S,I,QI,R> relatedExpressionPart, List<AnaphorPart<N,E,T,B,TB,S,I,QI,R,A>> allAnaphorPartsRelatedToTheRelatedExpression, AnaphorPart<N,E,T,B,TB,S,I,QI,R,A> anaphorPart, S scope)To be invoked when a related expression resolved with this strategy is realized to obtain the anaphor that will be present after realization.StringgetKindOfAnaphorResolutionStrategyToBeRealized(AnaphorPart<N,E,T,B,TB,S,I,QI,R,A> anaphorPart)To be invoked when a related expression resolved with this strategy is realized to obtain the kind of anaphor resolution strategy that applies after realization.StringgetKindOfReferentializationStrategyToBeRealized(AnaphorPart<N,E,T,B,TB,S,I,QI,R,A> anaphorPart)To be invoked when an anaphora resolved with this strategy is realized to obtain the kind of referentialization that applies after realization.LocalTempVariableContentsgetLocalTempVariableContents()Erealize(RelatedExpressionPart<N,E,T,B,TB,S,I,QI,R> relatedExpressionPart, AnaphorPart<N,E,T,B,TB,S,I,QI,R,A> anaphorPart, E replacee, Optional<I> guessedTempName, Object... support)Replaces the anaphor of the given anaphora relation.List<Perspectivation>underspecifyAnaphor(R relatedExpression, String anaphor, E anaphorExpression, Referent<TB,S,I,QI> referent, S scope)
-
Method Details
-
generatePotentialAnaphora
List<A> generatePotentialAnaphora(S scope, String anaphor, E anaphorExpression, List<R> potentialRelatedExpressions, List<ReferentializationStrategy<E,TB,S,I,QI>> refStrategies)Generates a list of potentialASTBasedAnaphorarelations. InvokescanRelateTo(RelatedExpressionStrategy)andcreateAnaphora(Object, String, Object, RelatedExpression, Referent, ReferentializationStrategy).- Parameters:
scope- The scope containing the anaphor if used by the compiler-specific implementation. Implementations of this method must not access the scope but merely pass it on to SPI's they invoke.anaphor- The anaphor that is to be (re-)resolved.anaphorExpression- The expression that may function as anaphor in the anaphora relation to be generated by this method. If the anaphora relation is to be re-resolved, this can be a non-trivial expression. If the anaphora relation is to be resolved for the first time, this is typically a simple name and might as well be called a definite expression at this point.potentialRelatedExpressions- Related expressions that could potentially constitute an anaphora relation with the given anaphor.refStrategies- Referentialisation strategies to be used to generate anaphora relations.- Returns:
- A list of potential anaphora relations.
- See Also:
canRelateTo(RelatedExpressionStrategy),createAnaphora(Object, String, Object, RelatedExpression, Referent, ReferentializationStrategy)
-
createAnaphora
A createAnaphora(S scope, String anaphor, E anaphorExpression, R potentialRelatedExpression, Referent<TB,S,I,QI> potentialReferent, ReferentializationStrategy<E,TB,S,I,QI> refStrategy)Create a single potentialASTBasedAnaphorarelation for a pair of anaphor (TODO: definite expression) and a potential related expression.- Parameters:
scope- The scope containing the anaphor if used by the compiler-specific implementation. Implementations of this method must not access the scope but merely pass it on to SPI's they invoke.anaphor- The anaphor that is to be (re-)resolved.anaphorExpression- The expression that may function as anaphor in the anaphora relation to be generated by this method. If the anaphora relation is to be re-resolved, this can be a non-trivial expression. If the anaphora relation is to be resolved for the first time, this is typically a simple name and might as well be called a definite expression at this point.potentialRelatedExpression- A related expression that could potentially constitute an anaphora relation with the given anaphor.potentialReferent- As e.g. returned byAbstractAnaphorResolutionStrategy.createPotentialReferents(Object, RelatedExpression)of this instance.refStrategy- The referentialization strategies to be used to generate the anaphora relation.- Returns:
- A list of potential anaphora relations.
-
createReferent
Re-creates a referent from a given related expression and memento.TODO: This method should be renamed to reCreateReferent(...)
TODO: When should this method be used?
- Parameters:
scope- The scope containing the anaphor if used by the compiler-specific implementation. Implementations of this method must not access the scope but merely pass it on to SPI's they invoke.relatedExpression- Related expressions that could potentially constitute an anaphora relation with the given anaphor.memento- A compiler-specific memento used to reconstruct the referent.- Returns:
- The re-constructed referent.
- Throws:
IllegalArgumentException- If the referent cannot be re-created from the given related expression and memento- See Also:
Referent.getMemento()
-
realize
E realize(RelatedExpressionPart<N,E,T,B,TB,S,I,QI,R> relatedExpressionPart, AnaphorPart<N,E,T,B,TB,S,I,QI,R,A> anaphorPart, E replacee, Optional<I> guessedTempName, Object... support)Replaces the anaphor of the given anaphora relation. Note that this method will replace AST nodes in the given anaphora instance if realization involves replacing AST nodes.- Parameters:
replacee- The anaphor node that will be replaced. TODO: Is this the anaphor, really?guessedTempName- If the given related expression part has aLocalTempVariableIntroducingStrategy, the strategy introduced a temporary variable that might be used by the anaphor resolution strategy to generate code for the anaphors.support- Optional compiler-specific support objects. Implementations of this method must not access the support objects but merely pass them on to SPI's they invoke.- Returns:
- The node that replaced the anaphor.
- See Also:
ASTBasedAnaphora.getAnaphor()
-
underspecifyAnaphor
-
getLocalTempVariableContents
-
getKindOfAnaphorResolutionStrategyToBeRealized
String getKindOfAnaphorResolutionStrategyToBeRealized(AnaphorPart<N,E,T,B,TB,S,I,QI,R,A> anaphorPart)To be invoked when a related expression resolved with this strategy is realized to obtain the kind of anaphor resolution strategy that applies after realization.That realized kind will also apply when the anaphora is re-resolved. Thus setting the realized kind in the beginning will avoid a faux change being detected during re-resolution of the unmodified anaphora relation.
-
getKindOfReferentializationStrategyToBeRealized
String getKindOfReferentializationStrategyToBeRealized(AnaphorPart<N,E,T,B,TB,S,I,QI,R,A> anaphorPart)To be invoked when an anaphora resolved with this strategy is realized to obtain the kind of referentialization that applies after realization.That realized kind will also apply when the anaphora is re-resolved. Thus setting the realized kind in the beginning will avoid a faux change being detected during re-resolution of the unmodified anaphora relation.
-
getAnaphorToBeRealized
String getAnaphorToBeRealized(RelatedExpressionPart<N,E,T,B,TB,S,I,QI,R> relatedExpressionPart, List<AnaphorPart<N,E,T,B,TB,S,I,QI,R,A>> allAnaphorPartsRelatedToTheRelatedExpression, AnaphorPart<N,E,T,B,TB,S,I,QI,R,A> anaphorPart, S scope)To be invoked when a related expression resolved with this strategy is realized to obtain the anaphor that will be present after realization.That realized anaphor will also apply when the anaphora is re-resolved. Thus setting the realized anaphor in the beginning will avoid a faux change being detected during re-resolution of the unmodified anaphora relation.