001package de.monochromata.ast;
002
003import java.util.List;
004
005import org.apache.commons.lang3.tuple.Pair;
006
007/**
008 * An interface to objects used to traverse the AST to find potential related
009 * expressions.
010 * <p>
011 * Note that the implementations of this interface may support only a limited
012 * set of {@link RelatedExpressionType}s.
013 *
014 * @param <E> The expression type
015 * @param <S> The scope type (optional)
016 */
017public interface RelatedExpressionsCollector<E, S> {
018
019    /**
020     * Traverse the body declaration that contains the given definite expression.
021     * <p>
022     * TODO: Rename the method to make clear that the enclosing body declaration is
023     * to be traversed?
024     * <p>
025     * TODO: There might be related expression that do not traverse the body
026     * enclosing the given definite expression but that check whether that body is
027     * reachable from some place
028     *
029     * @param definiteExpression The definite expression whose enclosing body is to
030     *                           be traversed.
031     * @param scope              The scope containing the definite expression if
032     *                           used by the compiler-specific implementation.
033     *                           Implementations of this method must not access the
034     *                           scope but merely pass it on to SPI's they invoke.
035     * @return collected potential related expressions
036     */
037    public List<Pair<RelatedExpressionType, E>> traverse(E definiteExpression, S scope);
038}