use of com.sun.tools.javac.tree.TreeScanner in project error-prone by google.
the class UnificationTest method expectMatches.
public void expectMatches(final Template<?> template, Match... expected) {
final Set<Match> expectedMatches = Sets.newHashSet(expected);
TreeScanner matchScanner = new TreeScanner() {
@Override
public void scan(JCTree tree) {
if (tree == null) {
return;
}
for (TemplateMatch templateMatch : template.match(tree, context)) {
Match match = Match.create(templateMatch);
if (!expectedMatches.remove(match)) {
fail(String.format("Unexpected match against template %s:%n%s", template, match));
}
}
super.scan(tree);
}
};
for (JCCompilationUnit unit : compilationUnits) {
matchScanner.scan(unit);
}
for (Match missingMatch : expectedMatches) {
fail(String.format("Expected match against template %s not found: %s", template, missingMatch));
}
}
Aggregations