Search in sources :

Example 16 with FileObject

use of javax.tools.FileObject in project ballerina by ballerina-lang.

the class ClassIndexProcessor method writeSimpleNameIndexFile.

private void writeSimpleNameIndexFile(Set<String> elementList, String resourceName) throws IOException {
    FileObject file = readOldIndexFile(elementList, resourceName);
    if (file != null) {
        /**
         * Ugly hack for Eclipse JDT incremental compilation.
         * Eclipse JDT can't createResource() after successful getResource().
         * But we can file.openWriter().
         */
        try {
            writeIndexFile(elementList, resourceName, file);
            return;
        } catch (IllegalStateException e) {
        // Thrown by HotSpot Java Compiler
        }
    }
    writeIndexFile(elementList, resourceName, null);
}
Also used : FileObject(javax.tools.FileObject)

Example 17 with FileObject

use of javax.tools.FileObject in project ballerina by ballerina-lang.

the class ClassIndexProcessor method writeIndexFile.

private void writeIndexFile(Set<String> entries, String resourceName, FileObject overrideFile) throws IOException {
    FileObject file = overrideFile;
    if (file == null) {
        file = filer.createResource(StandardLocation.CLASS_OUTPUT, "", resourceName);
    }
    try (Writer writer = file.openWriter()) {
        for (String entry : entries) {
            writer.write(entry);
            writer.write("\n");
        }
    }
}
Also used : FileObject(javax.tools.FileObject) Writer(java.io.Writer)

Example 18 with FileObject

use of javax.tools.FileObject in project mvp4g2 by mvp4g.

the class ApplicationAnnotationScanner method restore.

private ApplicationMetaModel restore() {
    Properties props = new Properties();
    try {
        FileObject resource = this.processingEnvironment.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", this.createRelativeFileName());
        props.load(resource.openInputStream());
        return new ApplicationMetaModel(props);
    } catch (IOException e) {
    // every thing is ok -> no operation
    // this.processorUtils.createNoteMessage("no resource found for : >>" + this.createRelativeFileName() + "<<");
    }
    return null;
}
Also used : ApplicationMetaModel(com.github.mvp4g.mvp4g2.processor.model.ApplicationMetaModel) FileObject(javax.tools.FileObject) IOException(java.io.IOException) Properties(java.util.Properties)

Example 19 with FileObject

use of javax.tools.FileObject in project mvp4g2 by mvp4g.

the class HistoryAnnotationScanner method restore.

private HistoryMetaModel restore() {
    Properties props = new Properties();
    try {
        FileObject resource = this.processingEnvironment.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", this.createRelativeFileName());
        props.load(resource.openInputStream());
        return new HistoryMetaModel(props);
    } catch (IOException e) {
    // every thing is ok -> no operation
    // this.processorUtils.createNoteMessage("no resource found for : >>" + this.createRelativeFileName() + "<<");
    }
    return new HistoryMetaModel();
}
Also used : HistoryMetaModel(com.github.mvp4g.mvp4g2.processor.model.HistoryMetaModel) FileObject(javax.tools.FileObject) IOException(java.io.IOException) Properties(java.util.Properties)

Example 20 with FileObject

use of javax.tools.FileObject in project mvp4g2 by mvp4g.

the class PresenterAnnotationScanner method restore.

private PresenterMetaModel restore() {
    Properties props = new Properties();
    try {
        FileObject resource = this.processingEnvironment.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", this.createRelativeFileName());
        props.load(resource.openInputStream());
        return new PresenterMetaModel(props);
    } catch (IOException e) {
    // every thing is ok -> no operation
    // this.processorUtils.createNoteMessage("no resource found for : >>" + this.createRelativeFileName() + "<<");
    }
    return new PresenterMetaModel();
}
Also used : PresenterMetaModel(com.github.mvp4g.mvp4g2.processor.model.PresenterMetaModel) FileObject(javax.tools.FileObject) IOException(java.io.IOException) Properties(java.util.Properties)

Aggregations

FileObject (javax.tools.FileObject)91 IOException (java.io.IOException)57 TypeElement (javax.lang.model.element.TypeElement)19 File (java.io.File)18 PrintWriter (java.io.PrintWriter)16 Element (javax.lang.model.element.Element)14 Writer (java.io.Writer)13 Filer (javax.annotation.processing.Filer)13 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 Properties (java.util.Properties)10 InputStream (java.io.InputStream)8 URI (java.net.URI)8 FilerException (javax.annotation.processing.FilerException)7 MainInfo (com.predic8.membrane.annot.model.MainInfo)6 BufferedReader (java.io.BufferedReader)6 FileWriter (java.io.FileWriter)6