001package de.monochromata.ast;
002
003import java.util.List;
004
005/**
006 * A special service provider interface related to finding potential referents
007 * of a given definite expression in a given related expression.
008 *
009 * @param <N>  The node type in the AST
010 * @param <E>  The expression type
011 * @param <T>  The type type
012 * @param <B>  The binding type
013 * @param <VB> The variable binding type
014 * @param <FB> The field binding type
015 * @param <MB> The method binding type
016 * @param <TB> The type binding type
017 * @param <S>  The scope type (optional)
018 * @param <I>  The type used to represent identifiers
019 * @param <QI> The type used to represent qualified identifiers
020 */
021public interface AnaphoraResolutionApi<N, E, T, B, VB extends B, FB extends B, MB extends B, TB extends B, S, I, QI> {
022
023    List<FB> getAccessibleFields(TB typeBinding, S scope);
024
025    I getFieldName(FB fieldBinding);
026
027    boolean identifierStartsUpperCase(I identifier);
028
029    String getFieldDescription(FB fieldBinding);
030
031    TB resolveType(FB fieldBinding, S scope);
032
033    List<MB> getAccessibleGetterMethods(TB typeBinding, S scope);
034
035    boolean doesGetterMethodOnlyReturnValueOf(MB methodBinding, FB fieldBinding, S scope);
036
037    /**
038     * Return a variable name for the given method that removes getter or setter
039     * prefix to the method name and converts the first character of the remaining
040     * string to lower case.
041     *
042     * @param methodBinding The method binding to use.
043     * @return A variable name.
044     */
045    QI getReferentName(MB methodBinding);
046
047    I getMethodName(MB methodBinding);
048
049    String getMethodDescription(MB methodBinding);
050
051    TB resolveReturnType(MB methodBinding, S scope);
052
053    boolean couldBeAPreviousRealization(E definiteExpression);
054
055    I getIdFromPreviousRealization(E definiteExpression);
056
057    /**
058     * TODO: Move more code from PublicAnaphoraResolution to d.m.a without adding
059     * types from d.m.a to the AST API
060     *
061     * Replace an anaphor of kind DA1Re by an expression that realizes it.
062     *
063     * @param replacee        The anaphor to be replaced.
064     * @param guessedTempName If the given related expression part has a local temp
065     *                        variable introducing strategy, the strategy introduced
066     *                        a temporary variable that might be used by the anaphor
067     *                        resolution strategy to generate code for the anaphors.
068     * @param support         Optional compiler-specific support objects.
069     * @return The AST node that realizes the anaphor.
070     *
071     *         E realizeDA1Re(RelatedExpressionPart<N, E, T, B, TB, S, I, QI, R>
072     *         relatedExpressionPart, AnaphorPart<N, E, T, B, TB, S, I, QI, R, A>
073     *         anaphorPart, E replacee, Optional<I> guessedTempName, Object...
074     *         support);
075     *
076     *         E realizeIA1Mr(RelatedExpressionPart<N, E, T, B, TB, S, I, QI, R>
077     *         relatedExpressionPart, AnaphorPart<N, E, T, B, TB, S, I, QI, R, A>
078     *         anaphorPart, E replacee, Optional<I> guessedTempName, Object[]
079     *         support);
080     *
081     *
082     *         Replace an anaphor of kind IA2F by an expression that realizes it.
083     *
084     * @param replacee        The anaphor to be replaced.
085     * @param guessedTempName If the given related expression part has a local temp
086     *                        variable introducing strategy, the strategy introduced
087     *                        a temporary variable that might be used by the anaphor
088     *                        resolution strategy to generate code for the anaphors.
089     * @param support         Optional compiler-specific support objects.
090     * @return The AST node that realizes the anaphor.
091     *
092     *         E realizeIA2F(RelatedExpressionPart<N, E, T, B, TB, S, I, QI, R>
093     *         relatedExpressionPart, AnaphorPart<N, E, T, B, TB, S, I, QI, R, A>
094     *         anaphorPart, E replacee, Optional<I> guessedTempName, Object...
095     *         support);
096     *
097     *         Replace an anaphor of kind IA2Mg by an expression that realizes it.
098     *
099     * @param replacee        The anaphor to be replaced.
100     * @param guessedTempName If the given related expression part has a local temp
101     *                        variable introducing strategy, the strategy introduced
102     *                        a temporary variable that might be used by the anaphor
103     *                        resolution strategy to generate code for the anaphors.
104     * @param support         Optional compiler-specific support objects.
105     * @return The AST node that realizes the anaphor.
106     *
107     *         E realizeIA2Mg(RelatedExpressionPart<N, E, T, B, TB, S, I, QI, R>
108     *         relatedExpressionPart, AnaphorPart<N, E, T, B, TB, S, I, QI, R, A>
109     *         anaphorPart, E replacee, Optional<I> guessedTempName, Object...
110     *         support);
111     *
112     *
113     *         String getIA1MrUnderspecifiedRelation(R potentialRelatedExpression,
114     *         MB methodBinding, S scope);
115     *
116     *         Returns the underspecified relation represented by an indirect
117     *         anaphora relation of kind IA2F in the format
118     *         <code>&lt;fully-qualified name of field declaring type&gt;.&lt;fieldName&gt;</code>
119     *         .
120     *
121     * @param relatedExpression The related expression whose type declares the
122     *                          underspecified relation.
123     * @param fieldBinding      The field that is part of the underspecified
124     *                          relation.
125     * @param scope             The scope containing the anaphor if used by the
126     *                          compiler-specific implementation.
127     * @return A string representing the underspecified relation.
128     *
129     *         String getIA2FUnderspecifiedRelation(R relatedExpression, FB
130     *         fieldBinding, S scope);
131     *
132     *         String getIA2MgUnderspecifiedRelation(R relatedExpression, MB
133     *         methodBinding, S scope);
134     */
135}