001package de.monochromata.anaphors.ast.relatedexp.strategy; 002 003import java.util.List; 004import java.util.function.Function; 005 006import de.monochromata.anaphors.ast.ASTBasedAnaphora; 007import de.monochromata.anaphors.ast.AnaphorPart; 008import de.monochromata.anaphors.ast.RelatedExpressionPart; 009import de.monochromata.anaphors.ast.relatedexp.RelatedExpression; 010import de.monochromata.anaphors.ast.strategy.AnchoringStrategy; 011 012/** 013 * A related expression strategy that introduces a local temporary variable 014 * during anaphor resolution. 015 * 016 * @param <N> The node type in the AST 017 * @param <E> The expression type 018 * @param <T> The type type 019 * @param <B> The binding type 020 * @param <TB> The type binding type 021 * @param <S> The scope type (optional) 022 * @param <I> The type used to represent identifiers 023 * @param <QI> The type used to represent qualified identifiers 024 * @param <R> The sub-type of related expression to use 025 * @param <A> The sub-type of AST-based anaphora to use 026 */ 027public interface LocalTempVariableIntroducingStrategy<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>> 028 extends RelatedExpressionStrategy<N, T, B, TB, S, QI, R> { 029 030 int getLengthOfTypeForTempVariable(final RelatedExpressionPart<N, E, T, B, TB, S, I, QI, R> relatedExpressionPart, 031 final S scope); 032 033 /** 034 * @param importRewrite To turn a type binding into a type that can be used in 035 * the AST 036 */ 037 @Deprecated 038 T getTypeForTempVariable(final RelatedExpressionPart<N, E, T, B, TB, S, I, QI, R> relatedExpressionPart, 039 final S scope, Function<TB, T> importRewrite); 040 041 /** 042 * @return The identifier to be used for the temp variable: for anaphora with 043 * {@link AnchoringStrategy}, a name is derived from the related 044 * expression, for other anaphora, the anaphor is used. 045 */ 046 I getIdentifierForTempVariable(final RelatedExpressionPart<N, E, T, B, TB, S, I, QI, R> relatedExpressionPart, 047 final List<AnaphorPart<N, E, T, B, TB, S, I, QI, R, A>> anaphorParts, final S scope); 048 049}