Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1199)

Unified Diff: Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/JsDocValidator.java

Issue 669123005: DevTools: [JSDocValidator] Pass JS file names through a temporary file (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/scripts/jsdoc-validator/jsdoc-validator.jar ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/JsDocValidator.java
diff --git a/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/JsDocValidator.java b/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/JsDocValidator.java
index 2631e4ba3086058f158f06573238e069f70d9f01..fa4392c64ed60ae98c3fbbf8e5d4049e04110baf 100644
--- a/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/JsDocValidator.java
+++ b/Source/devtools/scripts/jsdoc-validator/src/org/chromium/devtools/jsdoc/JsDocValidator.java
@@ -4,6 +4,10 @@
package org.chromium.devtools.jsdoc;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -17,16 +21,45 @@ import java.util.concurrent.Future;
public class JsDocValidator {
+ private static final String FILES_LIST_NAME = "--files-list-name";
+
private void run(String[] args) {
- int threadCount = Math.min(args.length, Runtime.getRuntime().availableProcessors());
+ if (args.length == 0) {
+ System.err.println("At least 1 argument is expected");
+ System.exit(1);
+ }
+ String[] files;
+ if (FILES_LIST_NAME.equals(args[0])) {
+ files = readFileNames(args);
+ } else {
+ files = args;
+ }
+ int threadCount = Math.min(files.length, Runtime.getRuntime().availableProcessors());
ExecutorService executor = Executors.newFixedThreadPool(threadCount);
try {
- runWithExecutor(args, executor);
+ runWithExecutor(files, executor);
} finally {
executor.shutdown();
}
}
+ private String[] readFileNames(String[] args) {
+ if (args.length != 2) {
+ System.err.println("A single file name is expected to follow " + FILES_LIST_NAME);
+ System.exit(1);
+ }
+ try {
+ List<String> list = Files.readAllLines(
+ FileSystems.getDefault().getPath(args[1]), Charset.forName("UTF-8"));
+ return list.toArray(new String[list.size()]);
+ } catch (IOException e) {
+ System.err.println("Unable to read list file " + args[1]);
+ e.printStackTrace();
+ System.exit(1);
+ return new String[0];
+ }
+ }
+
private void runWithExecutor(String[] args, ExecutorService executor) {
List<Future<ValidatorContext>> futures = new ArrayList<>(args.length);
Map<Future<ValidatorContext>, String> fileNamesByFuture = new HashMap<>();
« no previous file with comments | « Source/devtools/scripts/jsdoc-validator/jsdoc-validator.jar ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698