Search in sources :

Example 1 with ContinueStatementTree

use of org.sonar.plugins.java.api.tree.ContinueStatementTree in project sonar-java by SonarSource.

the class JavaTreeModelTest method continue_statement.

/**
 * 14.16. The continue Statement
 */
@Test
public void continue_statement() {
    ContinueStatementTree tree = (ContinueStatementTree) firstMethodFirstStatement("class T { void m() { continue ; } }");
    assertThat(tree.is(Tree.Kind.CONTINUE_STATEMENT)).isTrue();
    assertThat(tree.continueKeyword().text()).isEqualTo("continue");
    assertThat(tree.label()).isNull();
    assertThat(tree.semicolonToken().text()).isEqualTo(";");
    assertThatChildrenIteratorHasSize(tree, 2);
    tree = (ContinueStatementTree) firstMethodFirstStatement("class T { void m() { continue label ; } }");
    assertThat(tree.is(Tree.Kind.CONTINUE_STATEMENT)).isTrue();
    assertThat(tree.continueKeyword().text()).isEqualTo("continue");
    assertThat(tree.label().name()).isEqualTo("label");
    assertThat(tree.semicolonToken().text()).isEqualTo(";");
    assertThatChildrenIteratorHasSize(tree, 3);
}
Also used : ContinueStatementTree(org.sonar.plugins.java.api.tree.ContinueStatementTree) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 ContinueStatementTree (org.sonar.plugins.java.api.tree.ContinueStatementTree)1