use of javax.tools.FileObject in project dagger by square.
the class GraphAnalysisProcessor method writeDotFile.
void writeDotFile(TypeElement module, Map<String, Binding<?>> bindings) throws IOException {
JavaFileManager.Location location = StandardLocation.SOURCE_OUTPUT;
String path = getPackage(module).getQualifiedName().toString();
String file = module.getQualifiedName().toString().substring(path.length() + 1) + ".dot";
FileObject resource = processingEnv.getFiler().createResource(location, path, file, module);
Writer writer = resource.openWriter();
GraphVizWriter dotWriter = new GraphVizWriter(writer);
new GraphVisualizer().write(bindings, dotWriter);
dotWriter.close();
}
use of javax.tools.FileObject in project error-prone by google.
the class DocGenProcessor method init.
/**
* {@inheritDoc}
*/
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
try {
FileObject manifest = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, "", "bugPatterns.txt");
pw = new PrintWriter(new OutputStreamWriter(manifest.openOutputStream(), UTF_8));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of javax.tools.FileObject in project mvp4g2 by mvp4g.
the class ProcessorUtils method store.
public void store(IsMetaModel metaModel, String fileName) throws ProcessorException {
try {
FileObject fileObject = processingEnvironment.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", fileName);
PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(fileObject.openOutputStream()));
metaModel.createPropertes().store(printWriter, "");
printWriter.close();
} catch (IOException ex) {
throw new ProcessorException("Mvp4g2Processor: Unable to write file: >>" + fileName + "<< -> exception: " + ex.getMessage());
}
}
use of javax.tools.FileObject in project mvp4g2 by mvp4g.
the class EventAnnotationScanner method restore.
private EventMetaModel restore(Element element) {
Properties props = new Properties();
try {
FileObject resource = this.processingEnvironment.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", this.createRelativeFileName(element));
props.load(resource.openInputStream());
return new EventMetaModel(props);
} catch (IOException e) {
// every thing is ok -> no operation
// this.processorUtils.createNoteMessage("no resource found for : >>" + this.createRelativeFileName(element) + "<<");
}
return new EventMetaModel();
}
use of javax.tools.FileObject in project mvp4g2 by mvp4g.
the class EventBusAnnotationScanner method restore.
private EventBusMetaModel restore() {
Properties props = new Properties();
try {
FileObject resource = this.processingEnvironment.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", this.createRelativeFileName());
props.load(resource.openInputStream());
EventBusMetaModel model = new EventBusMetaModel(props);
List<EventMetaModel> eventModels = new ArrayList<>();
for (String eventInternalName : model.getEvents()) {
FileObject resourceEvent = this.processingEnvironment.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", this.createRelativeEventModelFileName(eventInternalName));
props.load(resourceEvent.openInputStream());
eventModels.add(new EventMetaModel(props));
}
eventModels.forEach(model::add);
return model;
} catch (IOException e) {
// every thing is ok -> no operation
// this.processorUtils.createNoteMessage("no resource found for : >>" + this.createRelativeFileName() + "<<");
}
return null;
}
Aggregations