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

Unified Diff: third_party/errorprone/src/org/chromium/errorprone/ChromiumErrorProneCompiler.java

Issue 1136573002: Use the Errorprone Compiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Full Sync and Update Created 5 years, 6 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 | « third_party/errorprone/errorprone.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/errorprone/src/org/chromium/errorprone/ChromiumErrorProneCompiler.java
diff --git a/third_party/errorprone/src/org/chromium/errorprone/ChromiumErrorProneCompiler.java b/third_party/errorprone/src/org/chromium/errorprone/ChromiumErrorProneCompiler.java
new file mode 100644
index 0000000000000000000000000000000000000000..706c6412138c65b344d227ee84685c0b8ff8c48f
--- /dev/null
+++ b/third_party/errorprone/src/org/chromium/errorprone/ChromiumErrorProneCompiler.java
@@ -0,0 +1,57 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.errorprone;
+
+import com.google.errorprone.BugPattern;
+import com.google.errorprone.ErrorProneOptions;
+import com.google.errorprone.ErrorProneScanner;
+import com.google.errorprone.ErrorReportingJavaCompiler;
+import com.google.errorprone.JDKCompatible;
+import com.google.errorprone.Scanner;
+import com.google.errorprone.bugpatterns.BugChecker;
+
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.List;
+
+import java.io.PrintWriter;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.tools.JavaFileObject;
+
+/**
+ * Configures (and compiles with) the error-prone java compiler.
+ */
+public class ChromiumErrorProneCompiler {
+
+ public static void main(String[] args) {
+ System.exit(compile(args));
+ }
+
+ private static int compile(String[] args) {
+ PrintWriter printWriter = new PrintWriter(System.err, true);
+ Main main = new Main("javac (chromium-error-prone)", printWriter);
+ Context context = new Context();
+ JavacFileManager.preRegister(context);
+
+ ErrorProneOptions epOptions = ErrorProneOptions.processArgs(args);
+ final Set<String> disabledChecks = new HashSet<String>(epOptions.getDisabledChecks());
+
+ Scanner scannerInContext = new ErrorProneScanner(new ErrorProneScanner.EnabledPredicate() {
+ @Override
+ public boolean isEnabled(Class<? extends BugChecker> check, BugPattern annotation) {
+ return !disabledChecks.contains(check.getCanonicalName());
+ }
+ });
+ context.put(Scanner.class, scannerInContext);
+
+ ErrorReportingJavaCompiler.preRegister(context);
+ return JDKCompatible.runCompile(
+ main, epOptions.getRemainingArgs(), context, List.<JavaFileObject>nil(), null);
+ }
+
+}
« no previous file with comments | « third_party/errorprone/errorprone.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698