Search in sources :

Example 36 with StatementTree

use of com.sun.source.tree.StatementTree in project j2objc by google.

the class TreeConverter method convertSwitch.

private TreeNode convertSwitch(SwitchTree node, TreePath parent) {
    TreePath path = getTreePath(parent, node);
    SwitchStatement newNode = new SwitchStatement().setExpression(convertWithoutParens(node.getExpression(), path));
    for (CaseTree switchCase : node.getCases()) {
        newNode.addStatement((SwitchCase) convert(switchCase, path));
        TreePath switchCasePath = getTreePath(path, switchCase);
        for (StatementTree s : switchCase.getStatements()) {
            newNode.addStatement((Statement) convert(s, switchCasePath));
        }
    }
    return newNode;
}
Also used : ExpressionStatementTree(com.sun.source.tree.ExpressionStatementTree) LabeledStatementTree(com.sun.source.tree.LabeledStatementTree) StatementTree(com.sun.source.tree.StatementTree) CaseTree(com.sun.source.tree.CaseTree) SwitchStatement(com.google.devtools.j2objc.ast.SwitchStatement) TreePath(com.sun.source.util.TreePath)

Example 37 with StatementTree

use of com.sun.source.tree.StatementTree 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)

Aggregations

StatementTree (com.sun.source.tree.StatementTree)37 MethodInvocationTree (com.sun.source.tree.MethodInvocationTree)19 ExpressionStatementTree (com.sun.source.tree.ExpressionStatementTree)18 BlockTree (com.sun.source.tree.BlockTree)16 Tree (com.sun.source.tree.Tree)16 ExpressionTree (com.sun.source.tree.ExpressionTree)12 TreePath (com.sun.source.util.TreePath)9 SuggestedFix (com.google.errorprone.fixes.SuggestedFix)8 MethodTree (com.sun.source.tree.MethodTree)8 MemberSelectTree (com.sun.source.tree.MemberSelectTree)7 TryTree (com.sun.source.tree.TryTree)7 VariableTree (com.sun.source.tree.VariableTree)7 CatchTree (com.sun.source.tree.CatchTree)6 JCTree (com.sun.tools.javac.tree.JCTree)6 ClassTree (com.sun.source.tree.ClassTree)5 IdentifierTree (com.sun.source.tree.IdentifierTree)5 MethodSymbol (com.sun.tools.javac.code.Symbol.MethodSymbol)5 VisitorState (com.google.errorprone.VisitorState)4 Description (com.google.errorprone.matchers.Description)4 EnhancedForLoopTree (com.sun.source.tree.EnhancedForLoopTree)4