Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: javax/ide/model/java/source/util/TreeResolver.java


1   /*
2    * @(#)TreeResolver.java
3    */
4   
5   package javax.ide.model.java.source.util;
6   
7   import java.util.Collection;
8   import javax.ide.model.java.declaration.Declaration;
9   import javax.ide.model.java.declaration.TypeD;
10  import javax.ide.model.java.source.tree.FileT;
11  import javax.ide.model.java.source.tree.Tree;
12  
13  /**
14   * The TreeResolver provides a facility for resolving type and declaration
15   * references on Trees. Methods are provided for resolving individual
16   * Tree objects. Other methods are provided for resolving an entire FileT.
17   * <p/>
18   * 
19   * The TreeResolver may need to acquire resource(s) as it performs
20   * resolution. Callers should be warned that TreeResolver operations may
21   * therefore block unless the underlying resource has already been acquired.
22   * <p/>
23   * 
24   * TODO: How does a caller acquire said resources? In particular, this is a
25   * problem since the resolution does not know ahead of time which
26   * compilation units will need to be read to perform a particular operation.
27   * <p/>
28   * 
29   * <h3> Constructors </h3>
30   * 
31   * There is one special case where a Tree resolves to a valid type and a
32   * valid declaration that "seem" to not match, namely NewClassExpressionT.
33   * The NewClassExpressionT will be resolved to a type which is the type
34   * of the class being created. However, the NewClassExpressionT will
35   * also resolve to a constructor declaration which, as you may recall,
36   * have no return type. <p/>
37   *
38   * @author Andy Yu
39   */
40  public interface TreeResolver
41  {
42    // ----------------------------------------------------------------------
43  
44    /**
45     * Resolves this tree into a declaration reference.
46     * 
47     * @return The resolved declaration this tree refers to, null if
48     *         unresolvable.
49     * 
50     * @throws UnsupportedOperationException if this tree does not resolve
51     *                                       to a declaration. Example: assert.
52     */
53    public Declaration getResolvedDeclaration(Tree tree);
54  
55    /**
56     * Resolves this tree into a type reference.
57     * 
58     * @return The resolved type this tree refers to, null if unresolvable.
59     * 
60     * @throws UnsupportedOperationException if this tree does not resolve
61     *                                       to a type. Example: assert.
62     */
63    public TypeD getResolvedType(Tree tree);
64  
65  
66    // ----------------------------------------------------------------------
67  
68    /**
69     * Lists all the declaration references made in this file.
70     * 
71     * @return The collection of declaration references made in this file.
72     * <p/>
73     * 
74     * Collection of Declarations.
75     */
76    public Collection getResolvedDeclarations(FileT file);
77    
78    /**
79     * Lists all the type references made in this file.
80     * 
81     * @return The collection of type references made in this file. <p/>
82     * 
83     * Collection of TypeDs.
84     */
85    public Collection getResolvedTypes(FileT file);
86  }