-
Notifications
You must be signed in to change notification settings - Fork 668
/
ProcessingEnvironment.java
145 lines (134 loc) · 5.45 KB
/
ProcessingEnvironment.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javax.annotation.processing;
import java.util.Locale;
import java.util.Map;
import javax.lang.model.SourceVersion;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
/**
* An annotation processing tool framework will {@linkplain
* Processor#init provide an annotation processor with an object
* implementing this interface} so the processor can use facilities
* provided by the framework to write new files, report error
* messages, and find other utilities.
*
* <p>Third parties may wish to provide value-add wrappers around the
* facility objects from this interface, for example a {@code Filer}
* extension that allows multiple processors to coordinate writing out
* a single source file. To enable this, for processors running in a
* context where their side effects via the API could be visible to
* each other, the tool infrastructure must provide corresponding
* facility objects that are {@code .equals}, {@code Filer}s that are
* {@code .equals}, and so on. In addition, the tool invocation must
* be able to be configured such that from the perspective of the
* running annotation processors, at least the chosen subset of helper
* classes are viewed as being loaded by the same class loader.
* (Since the facility objects manage shared state, the implementation
* of a wrapper class must know whether or not the same base facility
* object has been wrapped before.)
*
* @author Joseph D. Darcy
* @author Scott Seligman
* @author Peter von der Ahé
* @since 1.6
*/
// 注解处理器工作环境,从中可获取许多工具类实例
public interface ProcessingEnvironment {
/**
* Returns the messager used to report errors, warnings, and other
* notices.
*
* @return the messager
*/
// 获取Messager,以便生成日志信息
Messager getMessager();
/**
* Returns the filer used to create new source, class, or auxiliary
* files.
*
* @return the filer
*/
// 获取Filer,以便创建/读取文件
Filer getFiler();
/**
* Returns an implementation of some utility methods for
* operating on elements
*
* @return element utilities
*/
// 获取元素工具类
Elements getElementUtils();
/**
* Returns an implementation of some utility methods for
* operating on types.
*
* @return type utilities
*/
// 获取类型工具类
Types getTypeUtils();
/**
* Returns the processor-specific options passed to the annotation
* processing tool. Options are returned in the form of a map from
* option name to option value. For an option with no value, the
* corresponding value in the map is {@code null}.
*
* <p>See documentation of the particular tool infrastructure
* being used for details on how to pass in processor-specific
* options. For example, a command-line implementation may
* distinguish processor-specific options by prefixing them with a
* known string like {@code "-A"}; other tool implementations may
* follow different conventions or provide alternative mechanisms.
* A given implementation may also provide implementation-specific
* ways of finding options passed to the tool in addition to the
* processor-specific options.
*
* @return the processor-specific options passed to the tool
*/
// 返回传给注解处理器的参数(类似main方法中的args形参)
Map<String, String> getOptions();
/**
* Returns the source version that any generated {@linkplain
* Filer#createSourceFile source} and {@linkplain
* Filer#createClassFile class} files should conform to.
*
* @return the source version to which generated source and class
* files should conform to
*
* @see Processor#getSupportedSourceVersion
*/
// 返回注解处理器支持的java/class文件的版本
SourceVersion getSourceVersion();
/**
* Returns the current locale or {@code null} if no locale is in
* effect. The locale can be be used to provide localized
* {@linkplain Messager messages}.
*
* @return the current locale or {@code null} if no locale is in
* effect
*/
// 返回本地化信息
Locale getLocale();
}