Search in sources :

Example 11 with JavaFileObject

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

the class ClassUsageTrackerTest method readingFileFromGetJavaFileObjectsStringsOverloadShouldNotBeTracked.

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

Example 12 with JavaFileObject

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

the class JavaInMemoryFileManagerTest method testRecursiveListOperationReturnsNewlyCreatedFile.

@Test
public void testRecursiveListOperationReturnsNewlyCreatedFile() throws Exception {
    JavaFileObject fileObject1 = inMemoryFileManager.getJavaFileForOutput(StandardLocation.CLASS_OUTPUT, "jvm.java.JavaFileParser", JavaFileObject.Kind.CLASS, null);
    Iterator<JavaFileObject> recursiveIterable = inMemoryFileManager.list(StandardLocation.CLASS_OUTPUT, "jvm", Collections.singleton(JavaFileObject.Kind.CLASS), true).iterator();
    assertEquals(fileObject1, recursiveIterable.next());
    assertFalse(recursiveIterable.hasNext());
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Test(org.junit.Test)

Example 13 with JavaFileObject

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

the class JavaInMemoryFileManagerTest method testNonRecursiveListOperationDoesntReturnNewlyCreatedFileOnOtherDir.

@Test
public void testNonRecursiveListOperationDoesntReturnNewlyCreatedFileOnOtherDir() throws Exception {
    JavaFileObject fileObject1 = inMemoryFileManager.getJavaFileForOutput(StandardLocation.CLASS_OUTPUT, "jvm.java.JavaFileParser", JavaFileObject.Kind.CLASS, null);
    assertEquals("jvm/java/JavaFileParser.class", fileObject1.getName());
    Iterator<JavaFileObject> recursiveIterable = inMemoryFileManager.list(StandardLocation.CLASS_OUTPUT, "jvm", Collections.singleton(JavaFileObject.Kind.CLASS), false).iterator();
    assertFalse(recursiveIterable.hasNext());
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Test(org.junit.Test)

Example 14 with JavaFileObject

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

the class JavaInMemoryFileManagerTest method testNonRecursiveListOperationReturnsNewlyCreatedFile.

@Test
public void testNonRecursiveListOperationReturnsNewlyCreatedFile() throws Exception {
    JavaFileObject fileObject1 = inMemoryFileManager.getJavaFileForOutput(StandardLocation.CLASS_OUTPUT, "jvm.java.JavaFileParser", JavaFileObject.Kind.CLASS, null);
    Iterator<JavaFileObject> nonRecursiveIterable = inMemoryFileManager.list(StandardLocation.CLASS_OUTPUT, "jvm.java", Collections.singleton(JavaFileObject.Kind.CLASS), false).iterator();
    assertEquals(fileObject1, nonRecursiveIterable.next());
    assertFalse(nonRecursiveIterable.hasNext());
}
Also used : JavaFileObject(javax.tools.JavaFileObject) Test(org.junit.Test)

Example 15 with JavaFileObject

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

the class JavaInMemoryFileManagerTest method setUp.

@Before
public void setUp() {
    outputStream = new TestCustomZipOutputStream();
    DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
    inMemoryFileManager = new JavaInMemoryFileManager(ToolProvider.getSystemJavaCompiler().getStandardFileManager(diagnostics, null, null), Paths.get(URI.create("file:///tmp/test.jar!/")), outputStream, /*classesToBeRemovedFromJar */
    ImmutableSet.of());
}
Also used : JavaFileObject(javax.tools.JavaFileObject) DiagnosticCollector(javax.tools.DiagnosticCollector) TestCustomZipOutputStream(com.facebook.buck.testutil.TestCustomZipOutputStream) Before(org.junit.Before)

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