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 AST
E - The expression type
T - The type type
B - The binding type
TB - The type binding type
S - The scope type (optional)
I - The type used to represent identifiers
QI - The type used to represent qualified identifiers
R - The sub-type of related expression to use
A - 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
A strategy for resolving or constructing the referents of anaphors.
  • Method Details

    • canRelateTo

      boolean canRelateTo​(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.
    • generatePotentialAnaphora

      List<A> generatePotentialAnaphora​(S scope, String anaphor, E anaphorExpression, List<R> potentialRelatedExpressions, List<ReferentializationStrategy<E,​TB,​S,​I,​QI>> refStrategies)
      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 potential ASTBasedAnaphora relation 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 by AbstractAnaphorResolutionStrategy.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

      Referent<TB,​S,​I,​QI> createReferent​(S scope, R relatedExpression, Object memento)
      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 a LocalTempVariableIntroducingStrategy, 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

      List<Perspectivation> underspecifyAnaphor​(R relatedExpression, String anaphor, E anaphorExpression, Referent<TB,​S,​I,​QI> referent, S scope)
    • 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.