SyntacticEquivalence { @VisibleForTesting protected static boolean areLeafsEquivalent(EsqlTree leftNode, EsqlTree rightNode) { if (leftNode instanceof IdentifierTree) { return Objects.equal(((IdentifierTree) leftNode).name(), ((IdentifierTree) rightNode).name()); } else if (leftNode instanceof SyntaxToken) { return Objects.equal(((SyntaxToken) leftNode).text(), ((SyntaxToken) rightNode).text()); } else { throw new IllegalArgumentException(); } } private  SyntacticEquivalence(); static boolean areEquivalent(List<? extends Tree> leftList, List<? extends Tree> rightList); static boolean areEquivalent(@Nullable Tree leftNode, @Nullable Tree rightNode); static ExpressionTree skipParentheses(ExpressionTree tree);  }
@Test(expected = IllegalArgumentException.class) public void are_leafs_equivalent() throws Exception { CallStatementTreeImpl tree1 = (CallStatementTreeImpl) parse("CALL f(a,a) ;", Tree.Kind.CALL_STATEMENT); assertThat(SyntacticEquivalence.areLeafsEquivalent((IdentifierTreeImpl) tree1.parameterList().get(0), (IdentifierTreeImpl) tree1.parameterList().get(1))).isTrue(); SyntacticEquivalence.areLeafsEquivalent(null, null); }