Search in sources :

Example 1 with Variable

use of org.eclipse.ceylon.compiler.typechecker.tree.Tree.Variable in project ceylon by eclipse.

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 = new ListBuffer<JCCatch>();
    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(org.eclipse.ceylon.model.typechecker.model.Type) JCExpression(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression) Variable(org.eclipse.ceylon.compiler.typechecker.tree.Tree.Variable) ListBuffer(org.eclipse.ceylon.langtools.tools.javac.util.ListBuffer) CustomTree(org.eclipse.ceylon.compiler.typechecker.tree.CustomTree) JCTree(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) JCCatch(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCCatch) JCVariableDecl(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCVariableDecl)

Aggregations

CustomTree (org.eclipse.ceylon.compiler.typechecker.tree.CustomTree)1 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)1 Variable (org.eclipse.ceylon.compiler.typechecker.tree.Tree.Variable)1 JCTree (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree)1 JCCatch (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCCatch)1 JCExpression (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression)1 JCVariableDecl (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCVariableDecl)1 ListBuffer (org.eclipse.ceylon.langtools.tools.javac.util.ListBuffer)1 Type (org.eclipse.ceylon.model.typechecker.model.Type)1