115 if (instance == null) |
115 if (instance == null) |
116 instance = new JavacTrees(context); |
116 instance = new JavacTrees(context); |
117 return instance; |
117 return instance; |
118 } |
118 } |
119 |
119 |
120 private JavacTrees(Context context) { |
120 protected JavacTrees(Context context) { |
121 context.put(JavacTrees.class, this); |
121 context.put(JavacTrees.class, this); |
122 init(context); |
122 init(context); |
123 } |
123 } |
124 |
124 |
125 public void updateContext(Context context) { |
125 public void updateContext(Context context) { |
284 } |
284 } |
285 } |
285 } |
286 |
286 |
287 |
287 |
288 JCCompilationUnit unit = (JCCompilationUnit) path.getCompilationUnit(); |
288 JCCompilationUnit unit = (JCCompilationUnit) path.getCompilationUnit(); |
289 Copier copier = new Copier(treeMaker.forToplevel(unit)); |
289 Copier copier = createCopier(treeMaker.forToplevel(unit)); |
290 |
290 |
291 Env<AttrContext> env = null; |
291 Env<AttrContext> env = null; |
292 JCMethodDecl method = null; |
292 JCMethodDecl method = null; |
293 JCVariableDecl field = null; |
293 JCVariableDecl field = null; |
294 |
294 |
370 } |
370 } |
371 |
371 |
372 /** |
372 /** |
373 * Makes a copy of a tree, noting the value resulting from copying a particular leaf. |
373 * Makes a copy of a tree, noting the value resulting from copying a particular leaf. |
374 **/ |
374 **/ |
375 static class Copier extends TreeCopier<JCTree> { |
375 protected static class Copier extends TreeCopier<JCTree> { |
376 JCTree leafCopy = null; |
376 JCTree leafCopy = null; |
377 |
377 |
378 Copier(TreeMaker M) { |
378 protected Copier(TreeMaker M) { |
379 super(M); |
379 super(M); |
380 } |
380 } |
381 |
381 |
382 @Override |
382 @Override |
383 public <T extends JCTree> T copy(T t, JCTree leaf) { |
383 public <T extends JCTree> T copy(T t, JCTree leaf) { |
384 T t2 = super.copy(t, leaf); |
384 T t2 = super.copy(t, leaf); |
385 if (t == leaf) |
385 if (t == leaf) |
386 leafCopy = t2; |
386 leafCopy = t2; |
387 return t2; |
387 return t2; |
388 } |
388 } |
|
389 } |
|
390 |
|
391 protected Copier createCopier(TreeMaker maker) { |
|
392 return new Copier(maker); |
389 } |
393 } |
390 |
394 |
391 /** |
395 /** |
392 * Gets the original type from the ErrorType object. |
396 * Gets the original type from the ErrorType object. |
393 * @param errorType The errorType for which we want to get the original type. |
397 * @param errorType The errorType for which we want to get the original type. |