Search in sources :

Example 1 with TypeDeclarationStatement

use of com.google.devtools.j2objc.ast.TypeDeclarationStatement in project j2objc by google.

the class TreeConverter method convertBlock.

private TreeNode convertBlock(JCTree.JCBlock node) {
    Block newNode = new Block();
    for (StatementTree stmt : node.getStatements()) {
        TreeNode tree = convert(stmt);
        if (tree instanceof AbstractTypeDeclaration) {
            tree = new TypeDeclarationStatement().setDeclaration((AbstractTypeDeclaration) tree);
        }
        newNode.addStatement((Statement) tree);
    }
    return newNode;
}
Also used : StatementTree(com.sun.source.tree.StatementTree) TreeNode(com.google.devtools.j2objc.ast.TreeNode) TypeDeclarationStatement(com.google.devtools.j2objc.ast.TypeDeclarationStatement) Block(com.google.devtools.j2objc.ast.Block) AbstractTypeDeclaration(com.google.devtools.j2objc.ast.AbstractTypeDeclaration)

Example 2 with TypeDeclarationStatement

use of com.google.devtools.j2objc.ast.TypeDeclarationStatement in project j2objc by google.

the class TreeConverter method convertBlock.

private TreeNode convertBlock(BlockTree node, TreePath parent) {
    TreePath path = getTreePath(parent, node);
    Block newNode = new Block();
    for (StatementTree stmt : node.getStatements()) {
        TreeNode tree = convert(stmt, path);
        if (tree instanceof AbstractTypeDeclaration) {
            tree = new TypeDeclarationStatement().setDeclaration((AbstractTypeDeclaration) tree);
        }
        newNode.addStatement((Statement) tree);
    }
    return newNode;
}
Also used : ExpressionStatementTree(com.sun.source.tree.ExpressionStatementTree) LabeledStatementTree(com.sun.source.tree.LabeledStatementTree) StatementTree(com.sun.source.tree.StatementTree) TreePath(com.sun.source.util.TreePath) TreeNode(com.google.devtools.j2objc.ast.TreeNode) TypeDeclarationStatement(com.google.devtools.j2objc.ast.TypeDeclarationStatement) Block(com.google.devtools.j2objc.ast.Block) AbstractTypeDeclaration(com.google.devtools.j2objc.ast.AbstractTypeDeclaration)

Example 3 with TypeDeclarationStatement

use of com.google.devtools.j2objc.ast.TypeDeclarationStatement in project j2objc by google.

the class InnerClassExtractor method endHandleType.

private void endHandleType(AbstractTypeDeclaration node) {
    int insertIdx = typeOrderStack.remove(typeOrderStack.size() - 1);
    TreeNode parentNode = node.getParent();
    if (!(parentNode instanceof CompilationUnit)) {
        // Remove this type declaration from its current location.
        node.remove();
        if (parentNode instanceof TypeDeclarationStatement) {
            parentNode.remove();
        }
        addCaptureFields(node);
        // Make this node non-private, if necessary, and add it to the unit's type
        // list.
        node.removeModifiers(Modifier.PRIVATE);
        unitTypes.add(insertIdx, node);
        // Check for erroneous WeakOuter annotation on static inner class.
        TypeElement type = node.getTypeElement();
        if (ElementUtil.isStatic(type) && ElementUtil.hasAnnotation(type, WeakOuter.class)) {
            ErrorUtil.warning("static class " + type.getQualifiedName() + " has WeakOuter annotation");
        }
    }
}
Also used : CompilationUnit(com.google.devtools.j2objc.ast.CompilationUnit) TreeNode(com.google.devtools.j2objc.ast.TreeNode) TypeDeclarationStatement(com.google.devtools.j2objc.ast.TypeDeclarationStatement) TypeElement(javax.lang.model.element.TypeElement) WeakOuter(com.google.j2objc.annotations.WeakOuter)

Aggregations

TreeNode (com.google.devtools.j2objc.ast.TreeNode)3 TypeDeclarationStatement (com.google.devtools.j2objc.ast.TypeDeclarationStatement)3 AbstractTypeDeclaration (com.google.devtools.j2objc.ast.AbstractTypeDeclaration)2 Block (com.google.devtools.j2objc.ast.Block)2 StatementTree (com.sun.source.tree.StatementTree)2 CompilationUnit (com.google.devtools.j2objc.ast.CompilationUnit)1 WeakOuter (com.google.j2objc.annotations.WeakOuter)1 ExpressionStatementTree (com.sun.source.tree.ExpressionStatementTree)1 LabeledStatementTree (com.sun.source.tree.LabeledStatementTree)1 TreePath (com.sun.source.util.TreePath)1 TypeElement (javax.lang.model.element.TypeElement)1