001package de.monochromata.anaphors.ast.strategy;
002
003import static de.monochromata.anaphors.ast.reference.strategy.concept.NameRecurrence.Rn_KIND;
004import static de.monochromata.anaphors.ast.relatedexp.strategy.LocalTempVariableContents.ANCHOR;
005
006import de.monochromata.anaphors.ast.ASTBasedAnaphora;
007import de.monochromata.anaphors.ast.AnaphorPart;
008import de.monochromata.anaphors.ast.reference.strategy.ReferentializationStrategy;
009import de.monochromata.anaphors.ast.reference.strategy.concept.NameRecurrence;
010import de.monochromata.anaphors.ast.relatedexp.RelatedExpression;
011import de.monochromata.anaphors.ast.relatedexp.strategy.LocalTempVariableContents;
012import de.monochromata.anaphors.ast.relatedexp.strategy.LocalTempVariableIntroducingStrategy;
013import de.monochromata.anaphors.ast.relatedexp.strategy.RelatedExpressionStrategy;
014
015/**
016 * This is an {@link AnchoringStrategy} that has an anchor that differs from the
017 * referent. It retains the resolved {@link AnaphorResolutionStrategy} and
018 * {@link ReferentializationStrategy} for realization, because this strategy
019 * relates to the referent which is not stored in the introduced local temp
020 * variable, if such a variable is introduced (depends on whether the
021 * {@link RelatedExpressionStrategy} is a
022 * {@link LocalTempVariableIntroducingStrategy}).
023 *
024 * @param <N>  The node type in the AST
025 * @param <E>  The expression type
026 * @param <T>  The type type
027 * @param <B>  The binding type
028 * @param <TB> The type binding type
029 * @param <S>  The scope type (optional)
030 * @param <I>  The type used to represent identifiers
031 * @param <QI> The type used to represent qualified identifiers
032 * @param <R>  The sub-type of related expression to use
033 * @param <A>  The sub-type of AST-based anaphora to use
034 */
035public interface StoresAnchorInLocalTempVariable<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>>
036                extends AnchoringStrategy<N, E, T, B, TB, S, I, QI, R, A> {
037
038        @Override
039        default LocalTempVariableContents getLocalTempVariableContents() {
040                return ANCHOR;
041        }
042
043        @Override
044        default String getKindOfAnaphorResolutionStrategyToBeRealized(
045                        final AnaphorPart<N, E, T, B, TB, S, I, QI, R, A> anaphorPart) {
046                return anaphorPart.getAnaphorResolutionStrategy().getKind();
047        }
048
049        /**
050         * Always returns {@link NameRecurrence#Rn_KIND} because re-resolution triggered
051         * after realization will always be name-based as it is based on the
052         * underspecified representation of the realized anaphor which contains the name
053         * of the referent.
054         */
055        @Override
056        default String getKindOfReferentializationStrategyToBeRealized(
057                        final AnaphorPart<N, E, T, B, TB, S, I, QI, R, A> anaphorPart) {
058                return Rn_KIND;
059        }
060
061}