-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
20 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,17 +43,13 @@ | |
* @author [email protected] (Liam Miller-Cushon) | ||
*/ | ||
public final class GuardedByUtils { | ||
public static ImmutableSet<String> getGuardValues(Symbol sym, GuardedByFlags flags) { | ||
public static ImmutableSet<String> getGuardValues(Symbol sym) { | ||
List<Attribute.Compound> rawAttributes = sym.getRawAttributes(); | ||
if (rawAttributes.isEmpty()) { | ||
return ImmutableSet.of(); | ||
} | ||
return rawAttributes.stream() | ||
.filter( | ||
a -> | ||
flags.restrictToErrorProneGuardedBy() | ||
? a.type.tsym.flatName().contentEquals(GUARDED_BY) | ||
: a.getAnnotationType().asElement().getSimpleName().contentEquals("GuardedBy")) | ||
.filter(a -> a.type.tsym.flatName().contentEquals(GUARDED_BY)) | ||
.flatMap( | ||
a -> | ||
MoreAnnotations.getValue(a, "value") | ||
|
@@ -62,9 +58,9 @@ public static ImmutableSet<String> getGuardValues(Symbol sym, GuardedByFlags fla | |
.collect(toImmutableSet()); | ||
} | ||
|
||
static ImmutableSet<String> getGuardValues(Tree tree, GuardedByFlags flags) { | ||
static ImmutableSet<String> getGuardValues(Tree tree) { | ||
Symbol sym = getSymbol(tree); | ||
return sym == null ? ImmutableSet.of() : getGuardValues(sym, flags); | ||
return sym == null ? ImmutableSet.of() : getGuardValues(sym); | ||
} | ||
|
||
private static final String GUARDED_BY = "com.google.errorprone.annotations.concurrent.GuardedBy"; | ||
|
@@ -107,7 +103,7 @@ static GuardedByValidationResult ok() { | |
|
||
public static GuardedByValidationResult isGuardedByValid( | ||
Tree tree, VisitorState state, GuardedByFlags flags) { | ||
ImmutableSet<String> guards = GuardedByUtils.getGuardValues(tree, flags); | ||
ImmutableSet<String> guards = GuardedByUtils.getGuardValues(tree); | ||
if (guards.isEmpty()) { | ||
return GuardedByValidationResult.ok(); | ||
} | ||
|
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