forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland "Android: Add third_party/auto for errorprone""
Original CL: https://crrev.com/c/739725 Fix: - errorprone_plugin_java depends on errorprone_java, which is only available on $default_toolchain. BUG=777572 TBR=fgorski@chromium.org,brettw@chromium.org,yfriedman@chromium.org,jbudorick@chromium.org,peter@chromium.org,torne@chromium.org,agrieve@chromium.org Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet Change-Id: I2dceece332036a98014943cff4ec82b152075622 Reviewed-on: https://chromium-review.googlesource.com/750645 Commit-Queue: Peter Wen <wnwen@chromium.org> Reviewed-by: Peter Wen <wnwen@chromium.org> Cr-Commit-Position: refs/heads/master@{#513513}
- Loading branch information
Peter Wen
authored and
Commit Bot
committed
Nov 2, 2017
1 parent
0c61a1e
commit d0cc6d6
Showing
25 changed files
with
223 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2017 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. | ||
|
||
import("//build/config/android/rules.gni") | ||
|
||
java_library("auto_common_java") { | ||
java_files = [ | ||
"src/common/src/main/java/com/google/auto/common/AnnotationMirrors.java", | ||
"src/common/src/main/java/com/google/auto/common/BasicAnnotationProcessor.java", | ||
"src/common/src/main/java/com/google/auto/common/MoreTypes.java", | ||
"src/common/src/main/java/com/google/auto/common/SuperficialValidation.java", | ||
"src/common/src/main/java/com/google/auto/common/AnnotationValues.java", | ||
"src/common/src/main/java/com/google/auto/common/MoreElements.java", | ||
"src/common/src/main/java/com/google/auto/common/Overrides.java", | ||
"src/common/src/main/java/com/google/auto/common/Visibility.java", | ||
] | ||
|
||
deps = [ | ||
"//third_party/guava:guava_java", | ||
] | ||
} | ||
|
||
java_library("auto_service_java") { | ||
java_files = [ | ||
"src/service/src/main/java/com/google/auto/service/AutoService.java", | ||
"src/service/src/main/java/com/google/auto/service/processor/AutoServiceProcessor.java", | ||
"src/service/src/main/java/com/google/auto/service/processor/package-info.java", | ||
"src/service/src/main/java/com/google/auto/service/processor/ServicesFiles.java", | ||
] | ||
|
||
deps = [ | ||
":auto_common_java", | ||
"//third_party/guava:guava_java", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
agrieve@chromium.org | ||
nyquist@chromium.org | ||
wnwen@chromium.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Name: Auto | ||
Short Name: auto | ||
URL: https://github.com/google/auto | ||
Version: 71802f2ae74dae2744abd999f8434e13055c4ee3 | ||
Date: November 1, 2017 | ||
License: Apache 2.0 | ||
License File: NOT_SHIPPED | ||
Security Critical: no | ||
|
||
Description: | ||
* A collection of source code generators for Java. | ||
* AutoService used for custom plugins in //tools/android/errorprone_plugin. | ||
|
||
Local Modifications: | ||
* Add BUILD.gn. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
agrieve@chromium.org | ||
jbudorick@chromium.org | ||
nyquist@chromium.org | ||
wnwen@chromium.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2017 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. | ||
|
||
import("//build/config/android/rules.gni") | ||
|
||
java_library("errorprone_plugin_java") { | ||
java_files = [ | ||
"src/org/chromium/tools/errorprone/plugin/NoSynchronizedMethodCheck.java", | ||
"src/org/chromium/tools/errorprone/plugin/NoSynchronizedThisCheck.java", | ||
] | ||
|
||
processors_javac = | ||
[ "com.google.auto.service.processor.AutoServiceProcessor" ] | ||
|
||
# Necessary to avoid dependency cycle | ||
enable_errorprone = false | ||
|
||
deps = [ | ||
"//third_party/auto:auto_service_java", | ||
"//third_party/errorprone:errorprone_java", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
agrieve@chromium.org | ||
nyquist@chromium.org | ||
wnwen@chromium.org |
52 changes: 52 additions & 0 deletions
52
...errorprone_plugin/src/org/chromium/tools/errorprone/plugin/NoSynchronizedMethodCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2017 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.tools.errorprone.plugin; | ||
|
||
import com.google.auto.service.AutoService; | ||
import com.google.errorprone.BugPattern; | ||
import com.google.errorprone.VisitorState; | ||
import com.google.errorprone.bugpatterns.BugChecker; | ||
import com.google.errorprone.fixes.SuggestedFixes; | ||
import com.google.errorprone.matchers.Description; | ||
import com.google.errorprone.util.ASTHelpers; | ||
import com.sun.source.tree.MethodTree; | ||
import com.sun.tools.javac.code.Symbol; | ||
|
||
import javax.lang.model.element.Modifier; | ||
|
||
/** | ||
* Triggers an error for public methods that use "synchronized" in their signature. | ||
*/ | ||
@AutoService(BugChecker.class) | ||
@BugPattern(name = "NoSynchronizedMethodCheck", category = BugPattern.Category.JDK, | ||
summary = "Use of synchronized in public method signature disallowed.", | ||
severity = BugPattern.SeverityLevel.ERROR, linkType = BugPattern.LinkType.CUSTOM, | ||
link = "https://stackoverflow.com/questions/20906548/why-is-synchronized-block-better-than-synchronized-method") | ||
public class NoSynchronizedMethodCheck extends BugChecker implements BugChecker.MethodTreeMatcher { | ||
@Override | ||
public Description matchMethod(MethodTree methodTree, VisitorState visitorState) { | ||
Symbol.MethodSymbol method = ASTHelpers.getSymbol(methodTree); | ||
// Skip methods that aren't synchronized and non-public methods | ||
if (!method.getModifiers().contains(Modifier.SYNCHRONIZED) | ||
|| !method.getModifiers().contains(Modifier.PUBLIC)) { | ||
return Description.NO_MATCH; | ||
} | ||
// Skip methods that are only public due to VisibleForTesting | ||
if (ASTHelpers.hasDirectAnnotationWithSimpleName(method, "VisibleForTesting")) { | ||
return Description.NO_MATCH; | ||
} | ||
// Skip non-public classes | ||
Symbol.ClassSymbol enclosingClass = ASTHelpers.enclosingClass(method); | ||
if (!enclosingClass.getModifiers().contains(Modifier.PUBLIC)) { | ||
return Description.NO_MATCH; | ||
} | ||
return buildDescription(methodTree) | ||
.addFix(SuggestedFixes.removeModifiers( | ||
methodTree, visitorState, Modifier.SYNCHRONIZED)) | ||
.setMessage(String.format( | ||
"Used synchronized modifier in public method %s", method.getSimpleName())) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.