public static ClientCodeWrapper instance(Context context) { ClientCodeWrapper instance = context.get(ClientCodeWrapper.class); if (instance == null) instance = new ClientCodeWrapper(context); return instance; }
protected MultiTaskListener(Context context) { context.put(taskListenerKey, this); ccw = ClientCodeWrapper.instance(context); }
public JavaFileObject wrap(JavaFileObject fo) { if (isTrusted(fo)) return fo; return new WrappedJavaFileObject(fo); }
Context context) { try { ClientCodeWrapper ccw = ClientCodeWrapper.instance(context); compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check for (JavaFileObject cu : compilationUnits) { if (cu.getKind() != JavaFileObject.Kind.SOURCE) { context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener)); fileManager = ccw.wrap(fileManager); context.put(JavaFileManager.class, fileManager);
public void remove(TaskListener listener) { for (int i = 0; i < listeners.length; i++) { if (ccw.unwrap(listeners[i]) == listener) { TaskListener[] newListeners = new TaskListener[listeners.length - 1]; System.arraycopy(listeners, 0, newListeners, 0, i); System.arraycopy(listeners, i + 1, newListeners, i, newListeners.length - i); listeners = newListeners; break; } } }
public Iterable<JavaFileObject> wrapJavaFileObjects(Iterable<? extends JavaFileObject> list) { List<JavaFileObject> wrapped = new ArrayList<JavaFileObject>(); for (JavaFileObject fo : list) wrapped.add(wrap(fo)); return Collections.unmodifiableList(wrapped); }
@Override public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException { try { return wrapJavaFileObjects(clientJavaFileManager.list(location, packageName, kinds, recurse)); } catch (ClientCodeException e) { throw e; } catch (RuntimeException e) { throw new ClientCodeException(e); } catch (Error e) { throw new ClientCodeException(e); } }
ClientCodeWrapper ccw = ClientCodeWrapper.instance(context); compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check for (JavaFileObject cu : compilationUnits) { if (cu.getKind() != JavaFileObject.Kind.SOURCE) { context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener)); fileManager = ccw.wrap(fileManager);
public void remove(TaskListener listener) { for (int i = 0; i < listeners.length; i++) { if (ccw.unwrap(listeners[i]) == listener) { TaskListener[] newListeners = new TaskListener[listeners.length - 1]; System.arraycopy(listeners, 0, newListeners, 0, i); System.arraycopy(listeners, i + 1, newListeners, i, newListeners.length - i); listeners = newListeners; break; } } }
public Iterable<JavaFileObject> wrapJavaFileObjects(Iterable<? extends JavaFileObject> list) { List<JavaFileObject> wrapped = new ArrayList<JavaFileObject>(); for (JavaFileObject fo : list) wrapped.add(wrap(fo)); return Collections.unmodifiableList(wrapped); }
@Override public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException { try { return wrapJavaFileObjects(clientJavaFileManager.list(location, packageName, kinds, recurse)); } catch (ClientCodeException e) { throw e; } catch (RuntimeException e) { throw new ClientCodeException(e); } catch (Error e) { throw new ClientCodeException(e); } }
ClientCodeWrapper ccw = ClientCodeWrapper.instance(context); compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check for (JavaFileObject cu : compilationUnits) { if (cu.getKind() != JavaFileObject.Kind.SOURCE) { context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener)); fileManager = ccw.wrap(fileManager);
@Override public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException { try { return wrap(clientJavaFileManager.getFileForOutput(location, packageName, relativeName, unwrap(sibling))); } catch (ClientCodeException e) { throw e; } catch (RuntimeException e) { throw new ClientCodeException(e); } catch (Error e) { throw new ClientCodeException(e); } }
Collection<TaskListener> unwrap(Collection<? extends TaskListener> listeners) { Collection<TaskListener> c = new ArrayList<TaskListener>(listeners.size()); for (TaskListener l: listeners) c.add(unwrap(l)); return c; }
public <T /*super JavaFileOject*/> DiagnosticListener<T> wrap(DiagnosticListener<T> dl) { if (isTrusted(dl)) return dl; return new WrappedDiagnosticListener<T>(dl); }
@Override public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException { try { return wrap(clientJavaFileManager.getJavaFileForInput(location, className, kind)); } catch (ClientCodeException e) { throw e; } catch (RuntimeException e) { throw new ClientCodeException(e); } catch (Error e) { throw new ClientCodeException(e); } }
protected MultiTaskListener(Context context) { context.put(taskListenerKey, this); ccw = ClientCodeWrapper.instance(context); }
public static ClientCodeWrapper instance(Context context) { ClientCodeWrapper instance = context.get(ClientCodeWrapper.class); if (instance == null) instance = new ClientCodeWrapper(context); return instance; }