X Tutup
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ public void formatSource(CharSource input, CharSink output)
* @param timeoutForAll if true, total timeout is {@code timeout}, else timeout is {@code timeout * fileCount}
* @return the formatted java source
*/
public List<String> formatSourceFile(String file, boolean useExecutor, boolean reWrite,
long timeout, TimeUnit unit, boolean timeoutForAll)
public List<String> formatSourceFile(String file, boolean useExecutor, ExecutorService executorService,
boolean reWrite, long timeout, TimeUnit unit, boolean timeoutForAll)
throws IOException, FormatterException {
if (Strings.isNullOrEmpty(file)) {
return Collections.emptyList();
Expand All @@ -248,6 +248,9 @@ public List<String> formatSourceFile(String file, boolean useExecutor, boolean r
unit = TimeUnit.SECONDS;
timeoutForAll = false;
}
if (executorService == null) {
executorService = EXECUTOR_SERVICE;
}
File sourceFile = new File(file);
if (sourceFile.isFile()) {
// this is a file
Expand All @@ -262,7 +265,7 @@ public List<String> formatSourceFile(String file, boolean useExecutor, boolean r
formatted = "";
}
return ImmutableList.of(formatted); // do not update the file source.
}, EXECUTOR_SERVICE);
}, executorService);
try {
if (formattedFuture.get(timeout, unit) == null) {
return Collections.emptyList();
Expand Down Expand Up @@ -298,7 +301,7 @@ public List<String> formatSourceFile(String file, boolean useExecutor, boolean r
formatted = "";
}
return formatted;
}, EXECUTOR_SERVICE));
}, executorService));
}
// check the status.
CompletableFuture<List<String>> formattedResultFuture =
Expand Down
X Tutup