001package de.monochromata.anaphors.ast.relatedexp.strategy; 002 003import static de.monochromata.anaphors.ast.relatedexp.strategy.LocalVariableDeclarationStrategy.LVD_KIND; 004 005import java.util.List; 006 007import org.apache.commons.lang3.tuple.Pair; 008 009import de.monochromata.Strategy; 010import de.monochromata.anaphors.ast.relatedexp.RelatedExpression; 011import de.monochromata.anaphors.perspectivation.Perspectivation; 012 013/** 014 * A strategy for identifying and handling related expressions. 015 * 016 * @param <N> The node type in the AST 017 * @param <T> The type type 018 * @param <B> The binding type 019 * @param <TB> The type binding type 020 * @param <S> The scope type (optional) 021 * @param <QI> The type used to represent qualified identifiers 022 * @param <R> The sub-type of related expression to use 023 */ 024public interface RelatedExpressionStrategy<N, T, B, TB extends B, S, QI, R extends RelatedExpression<N, T, B, TB, S, QI, R>> 025 extends Strategy { 026 027 public void collectTo(List<N> potentialRelatedExpressions); 028 029 public void stopCollection(); 030 031 /** 032 * Create a perspectivations for the related expression 033 */ 034 public List<Perspectivation> underspecifyRelatedExpression(final R relatedExpression, 035 final List<Pair<LocalTempVariableContents, String>> variableContentsAndAnaphors, final S scope); 036 037 /** 038 * To be invoked when a related expression resolved with this strategy is 039 * realized to obtain the kind of related expression that applies after 040 * realization. All related expression strategies either represent parameters, 041 * local variables or introduce local variables. Hence, this method typically 042 * returns {@link LocalVariableDeclarationStrategy#LVD_KIND}. 043 * <p> 044 * That realized kind will also apply when the anaphora is re-resolved. Thus 045 * setting the realized kind in the beginning will avoid a faux change being 046 * detected during re-resolution of the unmodified anaphora relation. 047 */ 048 default String getKindOfRelatedExpressionToBeRealized() { 049 return LVD_KIND; 050 } 051}