use of com.sun.source.tree.TreeVisitor in project error-prone by google.
the class StringLiteralTest method notMatches.
@Test
public void notMatches() {
// TODO(b/67738557): consolidate helpers for creating fake trees
LiteralTree tree = new LiteralTree() {
@Override
public Kind getKind() {
throw new UnsupportedOperationException();
}
@Override
public <R, D> R accept(TreeVisitor<R, D> visitor, D data) {
throw new UnsupportedOperationException();
}
@Override
public Object getValue() {
return "a string literal";
}
};
assertFalse(new StringLiteral("different string").matches(tree, null));
IdentifierTree idTree = new IdentifierTree() {
@Override
public Name getName() {
return null;
}
@Override
public Kind getKind() {
throw new UnsupportedOperationException();
}
@Override
public <R, D> R accept(TreeVisitor<R, D> visitor, D data) {
throw new UnsupportedOperationException();
}
};
assertFalse(new StringLiteral("test").matches(idTree, null));
// TODO(b/67738557): consolidate helpers for creating fake trees
LiteralTree intTree = new LiteralTree() {
@Override
public Object getValue() {
return 5;
}
@Override
public Kind getKind() {
throw new UnsupportedOperationException();
}
@Override
public <R, D> R accept(TreeVisitor<R, D> visitor, D data) {
throw new UnsupportedOperationException();
}
};
assertFalse(new StringLiteral("test").matches(intTree, null));
}
use of com.sun.source.tree.TreeVisitor in project error-prone by google.
the class StringLiteralTest method matches.
@Test
public void matches() {
// TODO(b/67738557): consolidate helpers for creating fake trees
LiteralTree tree = new LiteralTree() {
@Override
public Kind getKind() {
throw new UnsupportedOperationException();
}
@Override
public <R, D> R accept(TreeVisitor<R, D> visitor, D data) {
throw new UnsupportedOperationException();
}
@Override
public Object getValue() {
return "a string literal";
}
};
assertTrue(new StringLiteral("a string literal").matches(tree, null));
}
Aggregations