use of com.google.devtools.j2objc.ast.Initializer in project j2objc by google.
the class TreeConverter method convertAbstractTypeDeclaration.
private TreeNode convertAbstractTypeDeclaration(JCTree.JCClassDecl node, AbstractTypeDeclaration newNode) {
convertBodyDeclaration(node, node.getModifiers(), newNode, node.sym);
List<BodyDeclaration> bodyDeclarations = new ArrayList<>();
for (JCTree bodyDecl : node.getMembers()) {
Object member = convert(bodyDecl);
if (member instanceof BodyDeclaration) {
// Not true for enum constants.
bodyDeclarations.add((BodyDeclaration) member);
} else if (member instanceof Block) {
JCTree.JCBlock javacBlock = (JCTree.JCBlock) bodyDecl;
Block block = (Block) member;
bodyDeclarations.add(new Initializer(block, javacBlock.isStatic()));
}
}
return newNode.setName(convertSimpleName(node.sym, node.sym.asType(), getNamePosition(node))).setTypeElement(node.sym).setBodyDeclarations(bodyDeclarations);
}
use of com.google.devtools.j2objc.ast.Initializer in project j2objc by google.
the class TreeConverter method convertEnum.
private TreeNode convertEnum(JCTree.JCClassDecl node) {
if (node.sym.isAnonymous()) {
return convertClassDeclaration(node).setPosition(getPosition(node));
}
EnumDeclaration newNode = (EnumDeclaration) new EnumDeclaration();
convertBodyDeclaration(node, node.getModifiers(), newNode, node.sym);
newNode.setName(convertSimpleName(node.sym, node.type, getNamePosition(node))).setTypeElement(node.sym);
for (JCTree bodyDecl : node.getMembers()) {
if (bodyDecl.getKind() == Kind.VARIABLE) {
TreeNode var = convertVariableDeclaration((JCTree.JCVariableDecl) bodyDecl);
if (var.getKind() == TreeNode.Kind.ENUM_CONSTANT_DECLARATION) {
newNode.addEnumConstant((EnumConstantDeclaration) var);
} else {
newNode.addBodyDeclaration((BodyDeclaration) var);
}
} else if (bodyDecl.getKind() == Kind.BLOCK) {
JCTree.JCBlock javacBlock = (JCTree.JCBlock) bodyDecl;
Block block = (Block) convert(javacBlock);
newNode.addBodyDeclaration(new Initializer(block, javacBlock.isStatic()));
} else {
newNode.addBodyDeclaration((BodyDeclaration) convert(bodyDecl));
}
}
return newNode;
}
use of com.google.devtools.j2objc.ast.Initializer in project j2objc by google.
the class TreeConverter method convertInitializer.
private static TreeNode convertInitializer(org.eclipse.jdt.core.dom.Initializer node) {
Initializer newNode = new Initializer();
convertBodyDeclaration(node, newNode);
return newNode.setBody((Block) convert(node.getBody()));
}
Aggregations