I want to collect methods in a class that set a certain field e.g. int i = 2;
.
I know how to get the Statement
s of a method:
CompilationUnit cu = StaticJavaParser.parse("class A {private int i; public int SetI(int i){this.i=i;}}");
List<MethodDeclaration> methods = cu.findAll(MethodDeclaration.class);
Statement statements = md.getBody().get().getStatements().get(0);
if (statement.isReturnStmt())
var r = statement.asReturnStmt();
but assignments seem to be expressions and I have no Idea how to get to them. How can I get the (assignment) expressions in a method?