-
What language are you writing rules for? Java
-
What have you tried, and what’s your challenge / stumbling block
@Override
public List<Tree.Kind> nodesToVisit() {
return Arrays.asList(Tree.Kind.MEMBER_SELECT);
}
@Override
public void visitNode(Tree tree) {
MemberSelectExpressionTree mse = (MemberSelectExpressionTree) tree;
String name = mse.identifier().name();
if(mse.is(Kind.MEMBER_SELECT) && name.equals("mockStatic")) {
System.out.println("name "+name);
}
}
How can I check if this member has a try-with-resources before when I use method mockStatic()?
This what I want to make sure the code looks like:
try (MockedStatic<StaticUtils> utilities = Mockito.mockStatic(StaticUtils.class)) {
<More code here>
}
or this is also valid
try (MockedStatic<StaticUtils> utilities = mockStatic(StaticUtils.class)) {
<More code here>
}
br,
//mike