Search in sources :

Example 1 with AttributeDeclaration

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

the class GenerateJsVisitor method getDefaultExpression.

/**
 * Get the specifier expression for a Parameter, if one is available.
 */
SpecifierOrInitializerExpression getDefaultExpression(final Tree.Parameter param) {
    final SpecifierOrInitializerExpression expr;
    if (param instanceof Tree.ParameterDeclaration || param instanceof Tree.InitializerParameter) {
        Tree.MethodDeclaration md = null;
        if (param instanceof Tree.ParameterDeclaration) {
            Tree.TypedDeclaration td = ((Tree.ParameterDeclaration) param).getTypedDeclaration();
            if (td instanceof AttributeDeclaration) {
                expr = ((Tree.AttributeDeclaration) td).getSpecifierOrInitializerExpression();
            } else if (td instanceof Tree.MethodDeclaration) {
                md = (Tree.MethodDeclaration) td;
                expr = md.getSpecifierExpression();
            } else {
                param.addUnexpectedError("Don't know what to do with TypedDeclaration " + td.getClass().getName(), Backend.JavaScript);
                expr = null;
            }
        } else {
            expr = ((Tree.InitializerParameter) param).getSpecifierExpression();
        }
    } else {
        param.addUnexpectedError("Don't know what to do with defaulted/sequenced param " + param, Backend.JavaScript);
        expr = null;
    }
    return expr;
}
Also used : Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) SpecifierOrInitializerExpression(org.eclipse.ceylon.compiler.typechecker.tree.Tree.SpecifierOrInitializerExpression) AttributeDeclaration(org.eclipse.ceylon.compiler.typechecker.tree.Tree.AttributeDeclaration)

Aggregations

Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)1 AttributeDeclaration (org.eclipse.ceylon.compiler.typechecker.tree.Tree.AttributeDeclaration)1 SpecifierOrInitializerExpression (org.eclipse.ceylon.compiler.typechecker.tree.Tree.SpecifierOrInitializerExpression)1