Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/javax/annotation/processing/ProcessingEnvironment.java
38913 views
/*1* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.annotation.processing;2627import java.util.Map;28import java.util.Locale;29import javax.lang.model.SourceVersion;30import javax.lang.model.util.Elements;31import javax.lang.model.util.Types;3233/**34* An annotation processing tool framework will {@linkplain35* Processor#init provide an annotation processor with an object36* implementing this interface} so the processor can use facilities37* provided by the framework to write new files, report error38* messages, and find other utilities.39*40* <p>Third parties may wish to provide value-add wrappers around the41* facility objects from this interface, for example a {@code Filer}42* extension that allows multiple processors to coordinate writing out43* a single source file. To enable this, for processors running in a44* context where their side effects via the API could be visible to45* each other, the tool infrastructure must provide corresponding46* facility objects that are {@code .equals}, {@code Filer}s that are47* {@code .equals}, and so on. In addition, the tool invocation must48* be able to be configured such that from the perspective of the49* running annotation processors, at least the chosen subset of helper50* classes are viewed as being loaded by the same class loader.51* (Since the facility objects manage shared state, the implementation52* of a wrapper class must know whether or not the same base facility53* object has been wrapped before.)54*55* @author Joseph D. Darcy56* @author Scott Seligman57* @author Peter von der Ahé58* @since 1.659*/60public interface ProcessingEnvironment {61/**62* Returns the processor-specific options passed to the annotation63* processing tool. Options are returned in the form of a map from64* option name to option value. For an option with no value, the65* corresponding value in the map is {@code null}.66*67* <p>See documentation of the particular tool infrastructure68* being used for details on how to pass in processor-specific69* options. For example, a command-line implementation may70* distinguish processor-specific options by prefixing them with a71* known string like {@code "-A"}; other tool implementations may72* follow different conventions or provide alternative mechanisms.73* A given implementation may also provide implementation-specific74* ways of finding options passed to the tool in addition to the75* processor-specific options.76*77* @return the processor-specific options passed to the tool78*/79Map<String,String> getOptions();8081/**82* Returns the messager used to report errors, warnings, and other83* notices.84*85* @return the messager86*/87Messager getMessager();8889/**90* Returns the filer used to create new source, class, or auxiliary91* files.92*93* @return the filer94*/95Filer getFiler();9697/**98* Returns an implementation of some utility methods for99* operating on elements100*101* @return element utilities102*/103Elements getElementUtils();104105/**106* Returns an implementation of some utility methods for107* operating on types.108*109* @return type utilities110*/111Types getTypeUtils();112113/**114* Returns the source version that any generated {@linkplain115* Filer#createSourceFile source} and {@linkplain116* Filer#createClassFile class} files should conform to.117*118* @return the source version to which generated source and class119* files should conform to120* @see Processor#getSupportedSourceVersion121*/122SourceVersion getSourceVersion();123124/**125* Returns the current locale or {@code null} if no locale is in126* effect. The locale can be be used to provide localized127* {@linkplain Messager messages}.128*129* @return the current locale or {@code null} if no locale is in130* effect131*/132Locale getLocale();133}134135136