use of com.google.errorprone.refaster.annotation.NotMatches in project error-prone by google.
the class UTemplater method visitIdentifier.
@Override
public UExpression visitIdentifier(IdentifierTree tree, Void v) {
Symbol sym = ASTHelpers.getSymbol(tree);
if (sym instanceof ClassSymbol) {
return UClassIdent.create((ClassSymbol) sym);
} else if (sym != null && sym.isStatic()) {
return staticMember(sym);
} else if (freeVariables.containsKey(tree.getName().toString())) {
VarSymbol symbol = freeVariables.get(tree.getName().toString());
checkState(symbol == sym);
UExpression ident = UFreeIdent.create(tree.getName());
Matches matches = ASTHelpers.getAnnotation(symbol, Matches.class);
if (matches != null) {
ident = UMatches.create(getValue(matches), true, ident);
}
NotMatches notMatches = ASTHelpers.getAnnotation(symbol, NotMatches.class);
if (notMatches != null) {
ident = UMatches.create(getValue(notMatches), false, ident);
}
OfKind hasKind = ASTHelpers.getAnnotation(symbol, OfKind.class);
if (hasKind != null) {
EnumSet<Kind> allowed = EnumSet.copyOf(Arrays.asList(hasKind.value()));
ident = UOfKind.create(ident, ImmutableSet.copyOf(allowed));
}
// @Repeated annotations need to be checked last.
Repeated repeated = ASTHelpers.getAnnotation(symbol, Repeated.class);
if (repeated != null) {
ident = URepeated.create(tree.getName(), ident);
}
return ident;
}
if (sym == null) {
return UTypeVarIdent.create(tree.getName());
}
switch(sym.getKind()) {
case TYPE_PARAMETER:
return UTypeVarIdent.create(tree.getName());
default:
return ULocalVarIdent.create(tree.getName());
}
}
Aggregations