155
155
* @author Peter von der Ahé
156
156
*/
157
157
public class JavacTrees extends DocTrees {
158
+ private final Modules modules ;
159
+ private final Resolve resolve ;
160
+ private final Enter enter ;
161
+ private final Log log ;
162
+ private final MemberEnter memberEnter ;
163
+ private final Attr attr ;
164
+ private final Check chk ;
165
+ private final TreeMaker treeMaker ;
166
+ private final JavacElements elements ;
167
+ private final JavacTaskImpl javacTaskImpl ;
168
+ private final Names names ;
169
+ private final Types types ;
170
+ private final DocTreeMaker docTreeMaker ;
171
+ private final JavaFileManager fileManager ;
172
+ private final ParserFactory parser ;
173
+ private final Symtab syms ;
158
174
159
- // in a world of a single context per compilation, these would all be final
160
- private Modules modules ;
161
- private Resolve resolve ;
162
- private Enter enter ;
163
- private Log log ;
164
- private MemberEnter memberEnter ;
165
- private Attr attr ;
166
- private Check chk ;
167
- private TreeMaker treeMaker ;
168
- private JavacElements elements ;
169
- private JavacTaskImpl javacTaskImpl ;
170
- private Names names ;
171
- private Types types ;
172
- private DocTreeMaker docTreeMaker ;
173
175
private BreakIterator breakIterator ;
174
- private JavaFileManager fileManager ;
175
- private ParserFactory parser ;
176
- private Symtab syms ;
177
176
178
177
private final Map <Type , Type > extraType2OriginalMap = new WeakHashMap <>();
179
178
@@ -202,14 +201,7 @@ public static JavacTrees instance(Context context) {
202
201
protected JavacTrees (Context context ) {
203
202
this .breakIterator = null ;
204
203
context .put (JavacTrees .class , this );
205
- init (context );
206
- }
207
-
208
- public void updateContext (Context context ) {
209
- init (context );
210
- }
211
204
212
- private void init (Context context ) {
213
205
modules = Modules .instance (context );
214
206
attr = Attr .instance (context );
215
207
chk = Check .instance (context );
@@ -225,9 +217,8 @@ private void init(Context context) {
225
217
parser = ParserFactory .instance (context );
226
218
syms = Symtab .instance (context );
227
219
fileManager = context .get (JavaFileManager .class );
228
- JavacTask t = context .get (JavacTask .class );
229
- if (t instanceof JavacTaskImpl taskImpl )
230
- javacTaskImpl = taskImpl ;
220
+ var task = context .get (JavacTask .class );
221
+ javacTaskImpl = (task instanceof JavacTaskImpl taskImpl ) ? taskImpl : null ;
231
222
}
232
223
233
224
@ Override @ DefinedBy (Api .COMPILER_TREE )
0 commit comments