Java Code Examples for javax.tools.JavaFileObject#openReader()
The following examples show how to use
javax.tools.JavaFileObject#openReader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiagnosticPrettyPrinter.java From buck with Apache License 2.0 | 6 votes |
private static Optional<String> getLine(JavaFileObject source, long line) { if (line < 0) { return Optional.empty(); } String toReturn = null; try (BufferedReader reader = new BufferedReader(source.openReader(true))) { for (long i = 0; i < line; i++) { toReturn = reader.readLine(); } } catch (IOException e) { // Do nothing. We're just trying to get some context, but we've failed. return Optional.empty(); } return Optional.ofNullable(toReturn); }
Example 2
Source File: ClassUsageTrackerTest.java From buck with Apache License 2.0 | 5 votes |
@Test public void readingFileByOpeningReaderShouldBeTracked() throws IOException { JavaFileObject javaFileObject = fileManager.getJavaFileForInput(null, SINGLE_FILE_NAME, JavaFileObject.Kind.CLASS); javaFileObject.openReader(false); assertFilesRead(TEST_JAR_PATH, SINGLE_FILE_NAME); }