ExpressionUtils { public static boolean isSimpleAssignment(AssignmentExpressionTree tree) { if (!tree.is(Tree.Kind.ASSIGNMENT)) { return false; } ExpressionTree variable = ExpressionUtils.skipParentheses(tree.variable()); return variable.is(Tree.Kind.IDENTIFIER) || isSelectOnThisOrSuper(tree); } private  ExpressionUtils(); static boolean isSimpleAssignment(AssignmentExpressionTree tree); static boolean isSelectOnThisOrSuper(AssignmentExpressionTree tree); static boolean isSelectOnThisOrSuper(MemberSelectExpressionTree tree); static IdentifierTree extractIdentifier(AssignmentExpressionTree tree); static Optional<Symbol> extractIdentifierSymbol(ExpressionTree tree); static boolean isInvocationOnVariable(MethodInvocationTree mit, @Nullable Symbol variable, boolean defaultReturn); static ExpressionTree skipParentheses(ExpressionTree tree); static boolean isNullLiteral(ExpressionTree tree); static boolean isSecuringByte(ExpressionTree expression); static IdentifierTree methodName(MethodInvocationTree mit); @CheckForNull static MethodTree getEnclosingMethod(ExpressionTree expr); static Optional<Symbol> getAssignedSymbol(ExpressionTree exp); static boolean isThis(ExpressionTree expression); @CheckForNull static Object resolveAsConstant(ExpressionTree tree);  }
@Test void test_simple_assignments() throws Exception { File file = new File("src/test/java/org/sonar/java/model/ExpressionUtilsTest.java"); CompilationUnitTree tree = JParserTestUtils.parse(file); MethodTree methodTree = (MethodTree) ((ClassTree) tree.types().get(0)).members().get(1); List<AssignmentExpressionTree> assignments = findAssignmentExpressionTrees(methodTree); assertThat(assignments).hasSize(4); assertThat(ExpressionUtils.isSimpleAssignment(assignments.get(0))).isTrue(); assertThat(ExpressionUtils.isSimpleAssignment(assignments.get(1))).isTrue(); assertThat(ExpressionUtils.isSimpleAssignment(assignments.get(2))).isFalse(); assertThat(ExpressionUtils.isSimpleAssignment(assignments.get(3))).isFalse(); }