Search in sources :

Example 76 with FileObject

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();
}
Also used : JavaFileManager(javax.tools.JavaFileManager) FileObject(javax.tools.FileObject) PrintWriter(java.io.PrintWriter) StringWriter(java.io.StringWriter) Writer(java.io.Writer)

Example 77 with FileObject

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);
    }
}
Also used : OutputStreamWriter(java.io.OutputStreamWriter) FileObject(javax.tools.FileObject) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 78 with FileObject

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());
    }
}
Also used : OutputStreamWriter(java.io.OutputStreamWriter) FileObject(javax.tools.FileObject) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 79 with FileObject

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();
}
Also used : FileObject(javax.tools.FileObject) IOException(java.io.IOException) Properties(java.util.Properties) EventMetaModel(com.github.mvp4g.mvp4g2.processor.model.EventMetaModel)

Example 80 with FileObject

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;
}
Also used : ArrayList(java.util.ArrayList) EventBusMetaModel(com.github.mvp4g.mvp4g2.processor.model.EventBusMetaModel) FileObject(javax.tools.FileObject) IOException(java.io.IOException) Properties(java.util.Properties) EventMetaModel(com.github.mvp4g.mvp4g2.processor.model.EventMetaModel)

Aggregations

FileObject (javax.tools.FileObject)98 IOException (java.io.IOException)61 File (java.io.File)21 TypeElement (javax.lang.model.element.TypeElement)19 PrintWriter (java.io.PrintWriter)17 Writer (java.io.Writer)16 Filer (javax.annotation.processing.Filer)14 Element (javax.lang.model.element.Element)14 BufferedWriter (java.io.BufferedWriter)12 ArrayList (java.util.ArrayList)12 OutputStream (java.io.OutputStream)11 JavaFileObject (javax.tools.JavaFileObject)11 OutputStreamWriter (java.io.OutputStreamWriter)10 URI (java.net.URI)10 Properties (java.util.Properties)10 InputStream (java.io.InputStream)8 FileWriter (java.io.FileWriter)7 FilerException (javax.annotation.processing.FilerException)7 MainInfo (com.predic8.membrane.annot.model.MainInfo)6 BufferedReader (java.io.BufferedReader)6