use of com.github.javaparser.ast.body.InitializerDeclaration in project javaparser by javaparser.
the class CloneVisitor method visit.
@Override
public Node visit(InitializerDeclaration _n, Object _arg) {
JavadocComment javaDoc = cloneNodes(_n.getJavaDoc(), _arg);
BlockStmt block = cloneNodes(_n.getBlock(), _arg);
Comment comment = cloneNodes(_n.getComment(), _arg);
InitializerDeclaration r = new InitializerDeclaration(_n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), _n.isStatic(), block);
r.setComment(comment);
return r;
}
use of com.github.javaparser.ast.body.InitializerDeclaration in project javaparser by javaparser.
the class NodeWithMembers method addInitializer.
default BlockStmt addInitializer() {
BlockStmt block = new BlockStmt();
InitializerDeclaration initializerDeclaration = new InitializerDeclaration(false, block);
getMembers().add(initializerDeclaration);
initializerDeclaration.setParentNode((Node) this);
return block;
}
use of com.github.javaparser.ast.body.InitializerDeclaration in project javaparser by javaparser.
the class NodeWithMembers method addStaticInitializer.
default BlockStmt addStaticInitializer() {
BlockStmt block = new BlockStmt();
InitializerDeclaration initializerDeclaration = new InitializerDeclaration(true, block);
getMembers().add(initializerDeclaration);
initializerDeclaration.setParentNode((Node) this);
return block;
}
use of com.github.javaparser.ast.body.InitializerDeclaration in project javaparser by javaparser.
the class InitializerDeclarationTransformationsTest method instanceToStatic.
// JavaDoc
// Body
// IsStatic
@Test
public void instanceToStatic() throws IOException {
InitializerDeclaration it = consider("{ /*some comment*/ }");
it.setStatic(true);
assertTransformedToString("static { /*some comment*/ }", it);
}
use of com.github.javaparser.ast.body.InitializerDeclaration in project javaparser by javaparser.
the class InitializerDeclarationTransformationsTest method staticToInstance.
@Test
public void staticToInstance() throws IOException {
InitializerDeclaration it = consider("static { /*some comment*/ }");
it.setStatic(false);
assertTransformedToString("{ /*some comment*/ }", it);
}
Aggregations