use of com.sun.source.tree.VariableTree in project j2objc by google.
the class TreeConverter method convertEnum.
private TreeNode convertEnum(ClassTree node, TreePath parent) {
TreePath path = getTreePath(parent, node);
TypeElement element = (TypeElement) getElement(path);
if (ElementUtil.isAnonymous(element)) {
return convertClassDeclaration(node, parent).setPosition(getPosition(node));
}
EnumDeclaration newNode = new EnumDeclaration();
convertBodyDeclaration(node, parent, node.getModifiers(), newNode);
newNode.setName(convertSimpleName(element, getTypeMirror(path), getNamePosition(node))).setTypeElement(element);
for (Tree bodyDecl : node.getMembers()) {
if (bodyDecl.getKind() == Kind.VARIABLE) {
TreeNode var = convertVariableDeclaration((VariableTree) bodyDecl, path);
if (var.getKind() == TreeNode.Kind.ENUM_CONSTANT_DECLARATION) {
newNode.addEnumConstant((EnumConstantDeclaration) var);
} else {
newNode.addBodyDeclaration((BodyDeclaration) var);
}
} else if (bodyDecl.getKind() == Kind.BLOCK) {
BlockTree javacBlock = (BlockTree) bodyDecl;
Block block = (Block) convert(javacBlock, path);
newNode.addBodyDeclaration(new Initializer(block, javacBlock.isStatic()));
} else {
newNode.addBodyDeclaration((BodyDeclaration) convert(bodyDecl, path));
}
}
return newNode;
}
Aggregations