src/java.compiler/share/classes/javax/annotation/processing/ProcessingEnvironment.java
author darcy
Mon, 15 Apr 2019 15:44:42 -0700
changeset 54539 bdbfa0115fc6
parent 47216 71c04702a3d5
permissions -rw-r--r--
8222378: Provide mechanism to query preview feature status for annotation processors Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
54539
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
     2
 * Copyright (c) 2005, 2019, 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.Map;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.util.Locale;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import javax.lang.model.SourceVersion;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import javax.lang.model.util.Elements;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import javax.lang.model.util.Types;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * An annotation processing tool framework will {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * Processor#init provide an annotation processor with an object
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * implementing this interface} so the processor can use facilities
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * provided by the framework to write new files, report error
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * messages, and find other utilities.
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * <p>Third parties may wish to provide value-add wrappers around the
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * facility objects from this interface, for example a {@code Filer}
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * extension that allows multiple processors to coordinate writing out
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * a single source file.  To enable this, for processors running in a
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * context where their side effects via the API could be visible to
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * each other, the tool infrastructure must provide corresponding
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * facility objects that are {@code .equals}, {@code Filer}s that are
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * {@code .equals}, and so on.  In addition, the tool invocation must
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * be able to be configured such that from the perspective of the
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 * running annotation processors, at least the chosen subset of helper
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
 * classes are viewed as being loaded by the same class loader.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
 * (Since the facility objects manage shared state, the implementation
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 * of a wrapper class must know whether or not the same base facility
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * object has been wrapped before.)
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * @author Joseph D. Darcy
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * @author Scott Seligman
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
public interface ProcessingEnvironment {
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * Returns the processor-specific options passed to the annotation
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     * processing tool.  Options are returned in the form of a map from
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * option name to option value.  For an option with no value, the
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * corresponding value in the map is {@code null}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * <p>See documentation of the particular tool infrastructure
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     * being used for details on how to pass in processor-specific
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * options.  For example, a command-line implementation may
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * distinguish processor-specific options by prefixing them with a
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * known string like {@code "-A"}; other tool implementations may
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     * follow different conventions or provide alternative mechanisms.
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * A given implementation may also provide implementation-specific
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * ways of finding options passed to the tool in addition to the
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * processor-specific options.
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * @return the processor-specific options passed to the tool
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    Map<String,String> getOptions();
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     * Returns the messager used to report errors, warnings, and other
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * notices.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * @return the messager
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    Messager getMessager();
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * Returns the filer used to create new source, class, or auxiliary
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * files.
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * @return the filer
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    Filer getFiler();
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     * Returns an implementation of some utility methods for
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * operating on elements
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     * @return element utilities
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
    Elements getElementUtils();
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * Returns an implementation of some utility methods for
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * operating on types.
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     * @return type utilities
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
    Types getTypeUtils();
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * Returns the source version that any generated {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     * Filer#createSourceFile source} and {@linkplain
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * Filer#createClassFile class} files should conform to.
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * @return the source version to which generated source and class
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     *         files should conform to
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * @see Processor#getSupportedSourceVersion
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    SourceVersion getSourceVersion();
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     * Returns the current locale or {@code null} if no locale is in
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     * effect.  The locale can be be used to provide localized
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     * {@linkplain Messager messages}.
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     * @return the current locale or {@code null} if no locale is in
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     * effect
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    Locale getLocale();
54539
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   134
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   135
    /**
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   136
     * Returns {@code true} if <em>preview features</em> are enabled
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   137
     * and {@code false} otherwise.
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   138
     * @return whether or not preview features are enabled
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   139
     *
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   140
     * @implSpec The default implementation of this method returns
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   141
     * {@code false}.
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   142
     *
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   143
     * @since 13
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   144
     */
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   145
    default boolean isPreviewEnabled() {
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   146
        return false;
bdbfa0115fc6 8222378: Provide mechanism to query preview feature status for annotation processors
darcy
parents: 47216
diff changeset
   147
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
}