• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package annotator.find;
2 
3 import com.sun.source.util.TreePath;
4 import com.sun.source.tree.Tree;
5 
6 /**
7  * A criterion for locating a program element in an AST.  A Criterion does
8  * not actually give a location.  Given a location, the isSatisfiedBy
9  * method indicates whether that location is a desired one.
10  */
11 public interface Criterion {
12 
13     /**
14      * Types of criterion.
15      */
16     public static enum Kind {
17         IN_METHOD,
18         /*
19          * Used for classes, interfaces, enums, annotation types.
20          * What would be a better name?
21          * Also see Criteria.isClassEquiv
22          */
23         IN_CLASS,
24         ENCLOSED_BY,
25         HAS_KIND,
26         NOT_IN_METHOD,
27         TYPE_PARAM,
28         GENERIC_ARRAY_LOCATION,
29         RECEIVER,
30         RETURN_TYPE,
31         SIG_METHOD,
32         PARAM,
33         CAST,
34         LOCAL_VARIABLE,
35         FIELD,
36         NEW,
37         INSTANCE_OF,
38         TYPE_ARGUMENT,
39         METHOD_CALL,
40         METHOD_REFERENCE,
41         LAMBDA_EXPRESSION,
42         BOUND_LOCATION,
43         EXTIMPLS_LOCATION,
44         INTERSECT_LOCATION,
45         METHOD_BOUND,
46         CLASS_BOUND,
47         IN_PACKAGE,
48         AST_PATH,
49         IN_STATIC_INIT,
50         IN_INSTANCE_INIT,
51         IN_FIELD_INIT,
52         /*
53          * This constant is never used. What is the difference to IN_CLASS?
54          * Is one for anywhere within a class and this one only for the
55          * class declaration itself?
56          */
57         CLASS,
58         PACKAGE;
59     }
60 
61     /**
62      * Determines if the given tree path is satisfied by this criterion.
63      *
64      * @param path the tree path to check against
65      * @return true if this criterion is satisfied by the given path,
66      * false otherwise
67      */
isSatisfiedBy(TreePath path, Tree tree)68     public boolean isSatisfiedBy(TreePath path, Tree tree);
69 
70     /**
71      * Determines if the given tree path is satisfied by this criterion.
72      *
73      * @param path the tree path to check against
74      * @return true if this criterion is satisfied by the given path,
75      * false otherwise
76      */
isSatisfiedBy(TreePath path)77     public boolean isSatisfiedBy(TreePath path);
78 
79     /**
80      * Gets the type of this criterion.
81      *
82      * @return this criterion's kind
83      */
getKind()84     public Kind getKind();
85 
86 }
87