use of org.sonar.plugins.java.api.tree.StaticInitializerTree in project sonar-java by SonarSource.
the class JavaTreeModelTest method class_init_declaration.
@Test
public void class_init_declaration() {
BlockTree tree = (BlockTree) firstTypeMember("class T { { ; ; } }");
assertThat(tree.is(Tree.Kind.INITIALIZER)).isTrue();
assertThat(tree.body()).hasSize(2);
assertThat(tree.openBraceToken().text()).isEqualTo("{");
assertThat(tree.closeBraceToken().text()).isEqualTo("}");
assertThatChildrenIteratorHasSize(tree, 4);
tree = (BlockTree) firstTypeMember("class T { static { ; ; } }");
assertThat(tree.is(Tree.Kind.STATIC_INITIALIZER)).isTrue();
StaticInitializerTree staticInitializerTree = (StaticInitializerTree) tree;
assertThat(staticInitializerTree.body()).hasSize(2);
assertThat(staticInitializerTree.staticKeyword().text()).isEqualTo("static");
assertThat(staticInitializerTree.openBraceToken().text()).isEqualTo("{");
assertThat(staticInitializerTree.closeBraceToken().text()).isEqualTo("}");
assertThatChildrenIteratorHasSize(tree, 5);
}
use of org.sonar.plugins.java.api.tree.StaticInitializerTree in project sonar-java by SonarSource.
the class LeftCurlyBraceBaseTreeVisitor method visitBlock.
@Override
public void visitBlock(BlockTree tree) {
if (tree.is(Tree.Kind.STATIC_INITIALIZER)) {
StaticInitializerTree staticInitializerTree = (StaticInitializerTree) tree;
checkTokens(staticInitializerTree.staticKeyword(), staticInitializerTree.openBraceToken());
}
super.visitBlock(tree);
}
Aggregations