Search in sources :

Example 1 with EmptyStatementTreeImpl

use of org.sonar.java.model.statement.EmptyStatementTreeImpl in project sonar-java by SonarSource.

the class ListTreeImplTest method emptySeparators.

@Test
public void emptySeparators() throws Exception {
    Tree tree1 = new EmptyStatementTreeImpl(null);
    List<Tree> trees = Lists.newArrayList(tree1);
    List<SyntaxToken> separators = Lists.newArrayList();
    ListTreeImpl<Tree> listTree = new MyList(trees, separators);
    Iterable<Tree> result = listTree.children();
    assertThat(Lists.newArrayList(result)).containsExactly(tree1);
}
Also used : InternalSyntaxToken(org.sonar.java.model.InternalSyntaxToken) SyntaxToken(org.sonar.plugins.java.api.tree.SyntaxToken) EmptyStatementTreeImpl(org.sonar.java.model.statement.EmptyStatementTreeImpl) Tree(org.sonar.plugins.java.api.tree.Tree) Test(org.junit.Test)

Example 2 with EmptyStatementTreeImpl

use of org.sonar.java.model.statement.EmptyStatementTreeImpl in project sonar-java by SonarSource.

the class ListTreeImplTest method separators_order_in_children_iteration.

@Test
public void separators_order_in_children_iteration() throws Exception {
    Tree tree1 = new EmptyStatementTreeImpl(null);
    Tree tree2 = new EmptyStatementTreeImpl(null);
    Tree tree3 = new EmptyStatementTreeImpl(null);
    List<Tree> trees = Lists.newArrayList(tree1, tree2, tree3);
    SyntaxToken token1 = createToken("token1");
    SyntaxToken token2 = createToken("token2");
    List<SyntaxToken> separators = Lists.newArrayList(token1, token2);
    ListTreeImpl<Tree> listTree = new MyList(trees, separators);
    Iterable<Tree> result = listTree.children();
    assertThat(Lists.newArrayList(result)).containsExactly(tree1, token1, tree2, token2, tree3);
}
Also used : InternalSyntaxToken(org.sonar.java.model.InternalSyntaxToken) SyntaxToken(org.sonar.plugins.java.api.tree.SyntaxToken) EmptyStatementTreeImpl(org.sonar.java.model.statement.EmptyStatementTreeImpl) Tree(org.sonar.plugins.java.api.tree.Tree) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 InternalSyntaxToken (org.sonar.java.model.InternalSyntaxToken)2 EmptyStatementTreeImpl (org.sonar.java.model.statement.EmptyStatementTreeImpl)2 SyntaxToken (org.sonar.plugins.java.api.tree.SyntaxToken)2 Tree (org.sonar.plugins.java.api.tree.Tree)2