Search in sources :

Example 6 with JavaFileObject

use of javax.tools.JavaFileObject in project buck by facebook.

the class ClassUsageTrackerTest method fileTypeIsTracked.

private boolean fileTypeIsTracked(JavaFileObject.Kind kind) throws IOException {
    final JavaFileObject javaFileObject = fileManager.getJavaFileForInput(null, kind.toString(), kind);
    javaFileObject.openInputStream();
    return fileWasRead(TEST_JAR_PATH, SINGLE_FILE_NAME);
}
Also used : JavaFileObject(javax.tools.JavaFileObject)

Example 7 with JavaFileObject

use of javax.tools.JavaFileObject in project buck by facebook.

the class ClassUsageTrackerTest method readingFileByOpeningStreamShouldBeTracked.

@Test
public void readingFileByOpeningStreamShouldBeTracked() throws IOException {
    final JavaFileObject javaFileObject = fileManager.getJavaFileForInput(null, SINGLE_FILE_NAME, JavaFileObject.Kind.CLASS);
    javaFileObject.openInputStream();
    assertFilesRead(TEST_JAR_PATH, SINGLE_FILE_NAME);
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Test(org.junit.Test)

Example 8 with JavaFileObject

use of javax.tools.JavaFileObject in project buck by facebook.

the class ClassUsageTrackerTest method readingFileFromGetJavaFileObjectsFileOverloadShouldNotBeTracked.

@Test
public void readingFileFromGetJavaFileObjectsFileOverloadShouldNotBeTracked() throws IOException {
    final Iterable<? extends JavaFileObject> javaFileObjects = fileManager.getJavaFileObjects(SINGLE_FILE);
    for (JavaFileObject javaFileObject : javaFileObjects) {
        javaFileObject.openInputStream();
    }
    assertNoFilesRead();
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Test(org.junit.Test)

Example 9 with JavaFileObject

use of javax.tools.JavaFileObject in project buck by facebook.

the class ClassUsageTrackerTest method readingFileWithGetCharContentShouldBeTracked.

@Test
public void readingFileWithGetCharContentShouldBeTracked() throws IOException {
    final JavaFileObject javaFileObject = fileManager.getJavaFileForInput(null, SINGLE_FILE_NAME, JavaFileObject.Kind.CLASS);
    javaFileObject.getCharContent(false);
    assertFilesRead(TEST_JAR_PATH, SINGLE_FILE_NAME);
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Test(org.junit.Test)

Example 10 with JavaFileObject

use of javax.tools.JavaFileObject in project buck by facebook.

the class ClassUsageTrackerTest method readingFileFromGetJavaFileObjectsFromFilesShouldNotBeTracked.

@Test
public void readingFileFromGetJavaFileObjectsFromFilesShouldNotBeTracked() throws IOException {
    final Iterable<? extends JavaFileObject> javaFileObjects = fileManager.getJavaFileObjectsFromFiles(Lists.newArrayList(SINGLE_FILE));
    for (JavaFileObject javaFileObject : javaFileObjects) {
        javaFileObject.openInputStream();
    }
    assertNoFilesRead();
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Test(org.junit.Test)

Aggregations

JavaFileObject (javax.tools.JavaFileObject)663 Test (org.junit.Test)473 ButterKnifeProcessor (butterknife.compiler.ButterKnifeProcessor)121 IOException (java.io.IOException)52 JavaCompiler (javax.tools.JavaCompiler)40 StorIOContentResolverProcessor (com.pushtorefresh.storio.contentresolver.annotations.processor.StorIOContentResolverProcessor)38 StorIOSQLiteProcessor (com.pushtorefresh.storio.sqlite.annotations.processor.StorIOSQLiteProcessor)35 File (java.io.File)32 Diagnostic (javax.tools.Diagnostic)30 DiagnosticCollector (javax.tools.DiagnosticCollector)28 SimpleJavaFileObject (javax.tools.SimpleJavaFileObject)25 StandardJavaFileManager (javax.tools.StandardJavaFileManager)25 ArrayList (java.util.ArrayList)24 TypeElement (javax.lang.model.element.TypeElement)21 Result (com.sun.tools.javac.main.Main.Result)20 Writer (java.io.Writer)17 PrintWriter (java.io.PrintWriter)16 CompilationTask (javax.tools.JavaCompiler.CompilationTask)14 JCTree (com.sun.tools.javac.tree.JCTree)10 StringWriter (java.io.StringWriter)10