Search in sources :

Example 1 with Variable

use of com.redhat.ceylon.compiler.typechecker.tree.Tree.Variable in project ceylon-compiler by ceylon.

the class StatementTransformer method transformCatchesPolymorphic.

/**
 * Transforms a list of {@code CatchClause}s to a corresponding list
 * of {@code JCCatch}.
 * @see #transformCatchesIfElseIf(java.util.List)
 */
private List<JCCatch> transformCatchesPolymorphic(java.util.List<Tree.CatchClause> catchClauses) {
    final ListBuffer<JCCatch> catches = ListBuffer.<JCCatch>lb();
    for (Tree.CatchClause catchClause : catchClauses) {
        at(catchClause);
        Tree.Variable variable = catchClause.getCatchVariable().getVariable();
        Type exceptionType = variable.getDeclarationModel().getType();
        JCExpression type = makeJavaType(exceptionType, JT_CATCH);
        JCVariableDecl param = make().VarDef(make().Modifiers(Flags.FINAL), names().fromString(variable.getIdentifier().getText()), type, null);
        catches.add(make().Catch(param, transform(catchClause.getBlock())));
    }
    return catches.toList();
}
Also used : Type(com.redhat.ceylon.model.typechecker.model.Type) JCExpression(com.sun.tools.javac.tree.JCTree.JCExpression) Variable(com.redhat.ceylon.compiler.typechecker.tree.Tree.Variable) CustomTree(com.redhat.ceylon.compiler.typechecker.tree.CustomTree) JCTree(com.sun.tools.javac.tree.JCTree) Tree(com.redhat.ceylon.compiler.typechecker.tree.Tree) JCCatch(com.sun.tools.javac.tree.JCTree.JCCatch) JCVariableDecl(com.sun.tools.javac.tree.JCTree.JCVariableDecl)

Aggregations

CustomTree (com.redhat.ceylon.compiler.typechecker.tree.CustomTree)1 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)1 Variable (com.redhat.ceylon.compiler.typechecker.tree.Tree.Variable)1 Type (com.redhat.ceylon.model.typechecker.model.Type)1 JCTree (com.sun.tools.javac.tree.JCTree)1 JCCatch (com.sun.tools.javac.tree.JCTree.JCCatch)1 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)1 JCVariableDecl (com.sun.tools.javac.tree.JCTree.JCVariableDecl)1