1 /* |
1 /* |
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
155 private boolean compilationInProgress = false; |
155 private boolean compilationInProgress = false; |
156 |
156 |
157 /** |
157 /** |
158 * Register that a compilation is about to start. |
158 * Register that a compilation is about to start. |
159 */ |
159 */ |
160 void beginContext(final Context context) { |
160 void beginContext(Context context) { |
161 if (compilationInProgress) |
161 if (compilationInProgress) |
162 throw new IllegalStateException("Compilation in progress"); |
162 throw new IllegalStateException("Compilation in progress"); |
163 compilationInProgress = true; |
163 compilationInProgress = true; |
164 final JavaFileManager givenFileManager = context.get(JavaFileManager.class); |
164 final JavaFileManager givenFileManager = context.get(JavaFileManager.class); |
165 context.put(JavaFileManager.class, (JavaFileManager)null); |
165 context.put(JavaFileManager.class, (JavaFileManager)null); |
166 context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() { |
166 context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() { |
167 public JavaFileManager make() { |
167 public JavaFileManager make(Context c) { |
168 if (givenFileManager != null) { |
168 if (givenFileManager != null) { |
169 context.put(JavaFileManager.class, givenFileManager); |
169 c.put(JavaFileManager.class, givenFileManager); |
170 return givenFileManager; |
170 return givenFileManager; |
171 } else { |
171 } else { |
172 return new JavacFileManager(context, true, null); |
172 return new JavacFileManager(c, true, null); |
173 } |
173 } |
174 } |
174 } |
175 }); |
175 }); |
176 } |
176 } |
177 |
177 |