langtools/src/java.compiler/share/classes/javax/annotation/processing/Processor.java
author jlahoda
Tue, 13 Dec 2016 10:49:28 +0100
changeset 42815 050370edaade
parent 25874 83c19f00452c
child 43133 08a858022ea6
permissions -rw-r--r--
8072988: Update javax.annotation.processing for modules Summary: Support for generating files in multi-module mode. Reviewed-by: darcy, jjg Contributed-by: joe.darcy@oracle.com, jan.lahoda@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
42815
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
     2
 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package javax.annotation.processing;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.util.Set;
18669
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
    29
import javax.lang.model.util.Elements;
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
    30
import javax.lang.model.AnnotatedConstruct;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import javax.lang.model.element.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import javax.lang.model.SourceVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * The interface for an annotation processor.
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * <p>Annotation processing happens in a sequence of {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * javax.annotation.processing.RoundEnvironment rounds}.  On each
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * round, a processor may be asked to {@linkplain #process process} a
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * subset of the annotations found on the source and class files
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * produced by a prior round.  The inputs to the first round of
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * processing are the initial inputs to a run of the tool; these
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * initial inputs can be regarded as the output of a virtual zeroth
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * round of processing.  If a processor was asked to process on a
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * given round, it will be asked to process on subsequent rounds,
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * including the last round, even if there are no annotations for it
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * to process.  The tool infrastructure may also ask a processor to
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * process files generated implicitly by the tool's operation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * <p> Each implementation of a {@code Processor} must provide a
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * public no-argument constructor to be used by tools to instantiate
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * the processor.  The tool infrastructure will interact with classes
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * implementing this interface as follows:
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * <ol>
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * <li>If an existing {@code Processor} object is not being used, to
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 * create an instance of a processor the tool calls the no-arg
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 * constructor of the processor class.
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
 * <li>Next, the tool calls the {@link #init init} method with
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
 * an appropriate {@code ProcessingEnvironment}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
 * <li>Afterwards, the tool calls {@link #getSupportedAnnotationTypes
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
 * getSupportedAnnotationTypes}, {@link #getSupportedOptions
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
 * getSupportedOptions}, and {@link #getSupportedSourceVersion
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
 * getSupportedSourceVersion}.  These methods are only called once per
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
 * run, not on each round.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
 * <li>As appropriate, the tool calls the {@link #process process}
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
 * method on the {@code Processor} object; a new {@code Processor}
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
 * object is <em>not</em> created for each round.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
 * </ol>
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
 * If a processor object is created and used without the above
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
 * protocol being followed, then the processor's behavior is not
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
 * defined by this interface specification.
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
 * <p> The tool uses a <i>discovery process</i> to find annotation
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
 * processors and decide whether or not they should be run.  By
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
 * configuring the tool, the set of potential processors can be
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
 * controlled.  For example, for a {@link javax.tools.JavaCompiler
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
 * JavaCompiler} the list of candidate processors to run can be
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
 * {@linkplain javax.tools.JavaCompiler.CompilationTask#setProcessors
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
 * set directly} or controlled by a {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
 * javax.tools.StandardLocation#ANNOTATION_PROCESSOR_PATH search path}
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
 * used for a {@linkplain java.util.ServiceLoader service-style}
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
 * lookup.  Other tool implementations may have different
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
 * configuration mechanisms, such as command line options; for
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
 * details, refer to the particular tool's documentation.  Which
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
 * processors the tool asks to {@linkplain #process run} is a function
18669
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
    93
 * of the types of the annotations <em>{@linkplain AnnotatedConstruct present}</em>
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
    94
 * on the {@linkplain
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
 * RoundEnvironment#getRootElements root elements}, what {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
 * #getSupportedAnnotationTypes annotation types a processor
18669
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
    97
 * supports}, and whether or not a processor {@linkplain #process
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
    98
 * claims the annotation types it processes}.  A processor will be asked to
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
 * process a subset of the annotation types it supports, possibly an
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
 * empty set.
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
 *
18669
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   102
 * For a given round, the tool computes the set of annotation types
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   103
 * that are present on the elements enclosed within the root elements.
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   104
 * If there is at least one annotation type present, then as
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   105
 * processors claim annotation types, they are removed from the set of
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   106
 * unmatched annotation types.  When the set is empty or no more
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   107
 * processors are available, the round has run to completion.  If
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
 * there are no annotation types present, annotation processing still
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
 * occurs but only <i>universal processors</i> which support
18669
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   110
 * processing all annotation types, {@code "*"}, can claim the (empty)
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   111
 * set of annotation types.
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   112
 *
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   113
 * <p>An annotation type is considered present if there is at least
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   114
 * one annotation of that type present on an element enclosed within
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   115
 * the root elements of a round. For this purpose, a type parameter is
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   116
 * considered to be enclosed by its {@linkplain
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   117
 * TypeParameterElement#getGenericElement generic
42815
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   118
 * element}.
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   119
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   120
 * For this purpose, a package element is <em>not</em> considered to
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   121
 * enclose the top-level types within that package. (A root element
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   122
 * representing a package is created when a {@code package-info} file
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   123
 * is processed.) Likewise, for this purpose, a module element is
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   124
 * <em>not</em> considered to enclose the packages within that
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   125
 * module. (A root element representing a module is created when a
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   126
 * {@code module-info} file is processed.)
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   127
 *
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   128
 * Annotations on {@linkplain
18669
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   129
 * java.lang.annotation.ElementType#TYPE_USE type uses}, as opposed to
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   130
 * annotations on elements, are ignored when computing whether or not
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   131
 * an annotation type is present.
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   132
 *
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   133
 * <p>An annotation is present if it meets the definition of being
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   134
 * present given in {@link AnnotatedConstruct}. In brief, an
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   135
 * annotation is considered present for the purposes of discovery if
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   136
 * it is directly present or present via inheritance. An annotation is
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   137
 * <em>not</em> considered present by virtue of being wrapped by a
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   138
 * container annotation. Operationally, this is equivalent to an
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   139
 * annotation being present on an element if and only if it would be
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   140
 * included in the results of {@link
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   141
 * Elements#getAllAnnotationMirrors(Element)} called on that element. Since
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   142
 * annotations inside container annotations are not considered
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   143
 * present, to properly process {@linkplain
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   144
 * java.lang.annotation.Repeatable repeatable annotation types},
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   145
 * processors are advised to include both the repeatable annotation
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   146
 * type and its containing annotation type in the set of {@linkplain
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   147
 * #getSupportedAnnotationTypes() supported annotation types} of a
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   148
 * processor.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
 * <p>Note that if a processor supports {@code "*"} and returns {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
 * true}, all annotations are claimed.  Therefore, a universal
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
 * processor being used to, for example, implement additional validity
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
 * checks should return {@code false} so as to not prevent other such
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
 * checkers from being able to run.
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
 * <p>If a processor throws an uncaught exception, the tool may cease
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
 * other active annotation processors.  If a processor raises an
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
 * error, the current round will run to completion and the subsequent
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
 * round will indicate an {@linkplain RoundEnvironment#errorRaised
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
 * error was raised}.  Since annotation processors are run in a
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
 * cooperative environment, a processor should throw an uncaught
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
 * exception only in situations where no error recovery or reporting
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
 * is feasible.
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
 * <p>The tool environment is not required to support annotation
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
 * processors that access environmental resources, either {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
 * RoundEnvironment per round} or {@linkplain ProcessingEnvironment
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
 * cross-round}, in a multi-threaded fashion.
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
 * <p>If the methods that return configuration information about the
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
 * annotation processor return {@code null}, return other invalid
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
 * input, or throw an exception, the tool infrastructure must treat
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
 * this as an error condition.
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
 * <p>To be robust when running in different tool implementations, an
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
 * annotation processor should have the following properties:
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
 * <ol>
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
 * <li>The result of processing a given input is not a function of the presence or absence
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
 * of other inputs (orthogonality).
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
 * <li>Processing the same input produces the same output (consistency).
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
 * <li>Processing input <i>A</i> followed by processing input <i>B</i>
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
 * is equivalent to processing <i>B</i> then <i>A</i>
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
 * (commutativity)
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
 * <li>Processing an input does not rely on the presence of the output
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
 * of other annotation processors (independence)
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
 * </ol>
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
 * <p>The {@link Filer} interface discusses restrictions on how
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
 * processors can operate on files.
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
 * <p>Note that implementors of this interface may find it convenient
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
 * to extend {@link AbstractProcessor} rather than implementing this
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
 * interface directly.
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
public interface Processor {
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     * Returns the options recognized by this processor.  An
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
     * implementation of the processing tool must provide a way to
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     * pass processor-specific options distinctly from options passed
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
     * to the tool itself, see {@link ProcessingEnvironment#getOptions
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
     * getOptions}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
     * <p>Each string returned in the set must be a period separated
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
     * sequence of {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
     * javax.lang.model.SourceVersion#isIdentifier identifiers}:
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
     * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
     * <dl>
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
     * <dt><i>SupportedOptionString:</i>
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     * <dd><i>Identifiers</i>
21476
3b3419329e1b 8026838: Fix new doclint issues in javax.annotation.processing
darcy
parents: 18669
diff changeset
   222
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
     * <dt><i>Identifiers:</i>
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     * <dd> <i>Identifier</i>
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
     * <dd> <i>Identifier</i> {@code .} <i>Identifiers</i>
21476
3b3419329e1b 8026838: Fix new doclint issues in javax.annotation.processing
darcy
parents: 18669
diff changeset
   226
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
     * <dt><i>Identifier:</i>
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
     * <dd>Syntactic identifier, including keywords and literals
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     * </dl>
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
     * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
     * <p> A tool might use this information to determine if any
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
     * options provided by a user are unrecognized by any processor,
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
     * in which case it may wish to report a warning.
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
     * @return the options recognized by this processor or an
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
     *         empty collection if none
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
     * @see javax.annotation.processing.SupportedOptions
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    Set<String> getSupportedOptions();
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
     * Returns the names of the annotation types supported by this
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
     * processor.  An element of the result may be the canonical
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     * (fully qualified) name of a supported annotation type.
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
     * Alternately it may be of the form &quot;<tt><i>name</i>.*</tt>&quot;
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
     * representing the set of all annotation types with canonical
42815
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   248
     * names beginning with &quot;<tt><i>name.</i></tt>&quot;.
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   249
     *
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   250
     * In either of those cases, the name of the annotation type can
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   251
     * be optionally preceded by a module name followed by a {@code
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   252
     * "/"} character. For example, if a processor supports {@code
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   253
     * "a.B"}, this can include multiple annotation types named {@code
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   254
     * a.B} which reside in different modules. To only support {@code
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   255
     * a.B} in the {@code Foo} module, instead use {@code "Foo/a.B"}.
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   256
     *
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   257
     * Finally, {@code "*"} by itself represents the set of all
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   258
     * annotation types, including the empty set.  Note that a
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   259
     * processor should not claim {@code "*"} unless it is actually
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   260
     * processing all files; claiming unnecessary annotations may
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   261
     * cause a performance slowdown in some environments.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
     * <p>Each string returned in the set must be accepted by the
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     * following grammar:
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
     * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     * <dl>
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     * <dt><i>SupportedAnnotationTypeString:</i>
42815
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   269
     * <dd><i>ModulePrefix</i><sub><i>opt</i></sub> <i>TypeName</i> <i>DotStar</i><sub><i>opt</i></sub>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     * <dd><tt>*</tt>
21476
3b3419329e1b 8026838: Fix new doclint issues in javax.annotation.processing
darcy
parents: 18669
diff changeset
   271
     *
42815
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   272
     * <dt><i>ModulePrefix:</i>
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   273
     * <dd><i>TypeName</i> <tt>/</tt>
050370edaade 8072988: Update javax.annotation.processing for modules
jlahoda
parents: 25874
diff changeset
   274
     *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
     * <dt><i>DotStar:</i>
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
     * <dd><tt>.</tt> <tt>*</tt>
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
     * </dl>
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
     * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
     *
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   280
     * where <i>TypeName</i> is as defined in
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   281
     * <cite>The Java&trade; Language Specification</cite>.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
     * @return the names of the annotation types supported by this processor
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
     * @see javax.annotation.processing.SupportedAnnotationTypes
9303
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   285
     * @jls 3.8 Identifiers
eae35c201e19 7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents: 5520
diff changeset
   286
     * @jls 6.5.5 Meaning of Type Names
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
    Set<String> getSupportedAnnotationTypes();
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
     * Returns the latest source version supported by this annotation
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
     * processor.
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
     * @return the latest source version supported by this annotation
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
     * processor.
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
     * @see javax.annotation.processing.SupportedSourceVersion
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
     * @see ProcessingEnvironment#getSourceVersion
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
    SourceVersion getSupportedSourceVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
     * Initializes the processor with the processing environment.
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
     * @param processingEnv environment for facilities the tool framework
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
     * provides to the processor
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
    void init(ProcessingEnvironment processingEnv);
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
     * Processes a set of annotation types on type elements
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
     * originating from the prior round and returns whether or not
18669
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   312
     * these annotation types are claimed by this processor.  If {@code
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   313
     * true} is returned, the annotation types are claimed and subsequent
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
     * processors will not be asked to process them; if {@code false}
18669
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   315
     * is returned, the annotation types are unclaimed and subsequent
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
     * processors may be asked to process them.  A processor may
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
     * always return the same boolean value or may vary the result
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
     * based on chosen criteria.
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
     * <p>The input set will be empty if the processor supports {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
     * "*"} and the root elements have no annotations.  A {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
     * Processor} must gracefully handle an empty set of annotations.
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
     * @param annotations the annotation types requested to be processed
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
     * @param roundEnv  environment for information about the current and prior round
18669
99572d59c916 7162089: Add support for repeating annotations to javax.annotation.processing
darcy
parents: 9303
diff changeset
   326
     * @return whether or not the set of annotation types are claimed by this processor
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   327
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   328
    boolean process(Set<? extends TypeElement> annotations,
06bc494ca11e Initial load
duke
parents:
diff changeset
   329
                    RoundEnvironment roundEnv);
06bc494ca11e Initial load
duke
parents:
diff changeset
   330
06bc494ca11e Initial load
duke
parents:
diff changeset
   331
   /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
    * Returns to the tool infrastructure an iterable of suggested
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
    * completions to an annotation.  Since completions are being asked
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
    * for, the information provided about the annotation may be
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
    * incomplete, as if for a source code fragment. A processor may
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
    * return an empty iterable.  Annotation processors should focus
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
    * their efforts on providing completions for annotation members
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
    * with additional validity constraints known to the processor, for
06bc494ca11e Initial load
duke
parents:
diff changeset
   339
    * example an {@code int} member whose value should lie between 1
06bc494ca11e Initial load
duke
parents:
diff changeset
   340
    * and 10 or a string member that should be recognized by a known
06bc494ca11e Initial load
duke
parents:
diff changeset
   341
    * grammar, such as a regular expression or a URL.
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
    * <p>Since incomplete programs are being modeled, some of the
06bc494ca11e Initial load
duke
parents:
diff changeset
   344
    * parameters may only have partial information or may be {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   345
    * null}.  At least one of {@code element} and {@code userText}
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
    * must be non-{@code null}.  If {@code element} is non-{@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
    * null}, {@code annotation} and {@code member} may be {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
    * null}.  Processors may not throw a {@code NullPointerException}
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
    * if some parameters are {@code null}; if a processor has no
06bc494ca11e Initial load
duke
parents:
diff changeset
   350
    * completions to offer based on the provided information, an
06bc494ca11e Initial load
duke
parents:
diff changeset
   351
    * empty iterable can be returned.  The processor may also return
06bc494ca11e Initial load
duke
parents:
diff changeset
   352
    * a single completion with an empty value string and a message
06bc494ca11e Initial load
duke
parents:
diff changeset
   353
    * describing why there are no completions.
06bc494ca11e Initial load
duke
parents:
diff changeset
   354
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   355
    * <p>Completions are informative and may reflect additional
06bc494ca11e Initial load
duke
parents:
diff changeset
   356
    * validity checks performed by annotation processors.  For
06bc494ca11e Initial load
duke
parents:
diff changeset
   357
    * example, consider the simple annotation:
06bc494ca11e Initial load
duke
parents:
diff changeset
   358
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   359
    * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   360
    * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   361
    * &#064;MersennePrime {
06bc494ca11e Initial load
duke
parents:
diff changeset
   362
    *    int value();
06bc494ca11e Initial load
duke
parents:
diff changeset
   363
    * }
06bc494ca11e Initial load
duke
parents:
diff changeset
   364
    * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   365
    * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   366
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   367
    * (A Mersenne prime is prime number of the form
06bc494ca11e Initial load
duke
parents:
diff changeset
   368
    * 2<sup><i>n</i></sup> - 1.) Given an {@code AnnotationMirror}
06bc494ca11e Initial load
duke
parents:
diff changeset
   369
    * for this annotation type, a list of all such primes in the
06bc494ca11e Initial load
duke
parents:
diff changeset
   370
    * {@code int} range could be returned without examining any other
06bc494ca11e Initial load
duke
parents:
diff changeset
   371
    * arguments to {@code getCompletions}:
06bc494ca11e Initial load
duke
parents:
diff changeset
   372
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
    * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
    * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   375
    * import static javax.annotation.processing.Completions.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
    * ...
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
    * return Arrays.asList({@link Completions#of(String) of}(&quot;3&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   378
    *                      of(&quot;7&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   379
    *                      of(&quot;31&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   380
    *                      of(&quot;127&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   381
    *                      of(&quot;8191&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   382
    *                      of(&quot;131071&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   383
    *                      of(&quot;524287&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   384
    *                      of(&quot;2147483647&quot;));
06bc494ca11e Initial load
duke
parents:
diff changeset
   385
    * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
    * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   387
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   388
    * A more informative set of completions would include the number
06bc494ca11e Initial load
duke
parents:
diff changeset
   389
    * of each prime:
06bc494ca11e Initial load
duke
parents:
diff changeset
   390
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
    * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
    * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
    * return Arrays.asList({@link Completions#of(String, String) of}(&quot;3&quot;,          &quot;M2&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
    *                      of(&quot;7&quot;,          &quot;M3&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
    *                      of(&quot;31&quot;,         &quot;M5&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
    *                      of(&quot;127&quot;,        &quot;M7&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
    *                      of(&quot;8191&quot;,       &quot;M13&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
    *                      of(&quot;131071&quot;,     &quot;M17&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
    *                      of(&quot;524287&quot;,     &quot;M19&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
    *                      of(&quot;2147483647&quot;, &quot;M31&quot;));
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
    * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
    * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
    * However, if the {@code userText} is available, it can be checked
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
    * to see if only a subset of the Mersenne primes are valid.  For
06bc494ca11e Initial load
duke
parents:
diff changeset
   406
    * example, if the user has typed
06bc494ca11e Initial load
duke
parents:
diff changeset
   407
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   408
    * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
    * <code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
    * &#064;MersennePrime(1
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
    * </code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
    * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
    * the value of {@code userText} will be {@code "1"}; and only
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
    * two of the primes are possible completions:
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
    * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   418
    * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
    * return Arrays.asList(of(&quot;127&quot;,        &quot;M7&quot;),
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
    *                      of(&quot;131071&quot;,     &quot;M17&quot;));
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
    * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   422
    * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   423
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   424
    * Sometimes no valid completion is possible.  For example, there
06bc494ca11e Initial load
duke
parents:
diff changeset
   425
    * is no in-range Mersenne prime starting with 9:
06bc494ca11e Initial load
duke
parents:
diff changeset
   426
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   427
    * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   428
    * <code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
    * &#064;MersennePrime(9
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
    * </code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
    * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
    * An appropriate response in this case is to either return an
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
    * empty list of completions,
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
    * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
    * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
    * return Collections.emptyList();
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
    * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
    * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
    * or a single empty completion with a helpful message
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
    * <blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
    * <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
    * return Arrays.asList(of(&quot;&quot;, &quot;No in-range Mersenne primes start with 9&quot;));
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
    * </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
    * </blockquote>
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
    * @param element the element being annotated
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
    * @param annotation the (perhaps partial) annotation being
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
    *                   applied to the element
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
    * @param member the annotation member to return possible completions for
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
    * @param userText source code text to be completed
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
    *
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
    * @return suggested completions to the annotation
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
    */
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
    Iterable<? extends Completion> getCompletions(Element element,
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
                                                  AnnotationMirror annotation,
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
                                                  ExecutableElement member,
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
                                                  String userText);
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
}