Package com.redhat.ceylon.compiler.typechecker.model

Examples of com.redhat.ceylon.compiler.typechecker.model.Parameter


        super.visit(that);
        Tree.SpecifierOrInitializerExpression sie = that.getSpecifierOrInitializerExpression();
        Value dec = that.getDeclarationModel();
        if (dec!=null && dec.isParameter() &&
                dec.getInitializerParameter().isHidden()) {
            Parameter param = dec.getInitializerParameter();
            if (that.getType() instanceof Tree.SequencedType) {
                param.setSequenced(true);
                param.setAtLeastOne(((Tree.SequencedType)that.getType()).getAtLeastOne());
            }
            if (sie!=null) {
                sie.addError("value is an initializer parameter and may not have an initial value: '" +
                        dec.getName() + "'");
            }
View Full Code Here


    @Override
    public void visit(Tree.InitializerParameter that) {
        super.visit(that);
        //i.e. an attribute initializer parameter
        Parameter p = that.getParameterModel();
        Declaration a = that.getScope().getDirectMember(p.getName(), null, false);
        if (a==null) {
            //Now done in ExpressionVisitor!
//            that.addError("parameter declaration does not exist: '" + p.getName() + "'");
        }
        else if (!isLegalParameter(a)) {
            that.addError("parameter is not a reference value or function: '" + p.getName() + "'");
        }
        else {
            if (a.isFormal()) {
                that.addError("parameter is a formal attribute: '" + p.getName() + "'", 320);
            }
            /*else if (a.isDefault()) {
                that.addError("initializer parameter refers to a default attribute: " +
                        d.getName());
            }*/
            MethodOrValue mov = (MethodOrValue) a;
            mov.setInitializerParameter(p);
            p.setModel(mov);
        }
        /*if (d.isHidden() && d.getDeclaration() instanceof Method) {
            if (a instanceof Method) {
                that.addWarning("initializer parameters for inner methods of methods not yet supported");
            }
            if (a instanceof Value && ((Value) a).isVariable()) {
                that.addWarning("initializer parameters for variables of methods not yet supported");
            }
        }*/
        if (a instanceof Generic && !((Generic) a).getTypeParameters().isEmpty()) {
            that.addError("parameter declaration has type parameters: '" +
                    p.getName() + "' may not declare type parameters");
        }
        if (p.isDefaulted()) {
            checkDefaultArg(that.getSpecifierExpression(), p);
        }
    }
View Full Code Here

    @Override
    public void visit(Tree.AnyAttribute that) {
        super.visit(that);
        if (that.getType() instanceof Tree.SequencedType) {
            Value v = (Value) that.getDeclarationModel();
            Parameter p = v.getInitializerParameter();
            if (p==null) {
                that.getType().addError("value is not a parameter, so may not be variadic: '" +
                        v.getName() + "'");
            }
            else {
                p.setSequenced(true);
            }
        }
    }
View Full Code Here

        }
    }
   
    @Override public void visit(Tree.ParameterDeclaration that) {
        super.visit(that);
        Parameter p = that.getParameterModel();
        if (p.isDefaulted()) {
            if (p.getDeclaration().isParameter()) {
                getSpecifier(that).addError("parameter of callable parameter may not have default argument");
            }
            checkDefaultArg(getSpecifier(that), p);
        }
    }
View Full Code Here

    public void visit(Tree.AttributeSetterDefinition that) {
        Setter s = new Setter();
        that.setDeclarationModel(s);
        visitDeclaration(that, s);
        Scope o = enterScope(s);
        Parameter p = new Parameter();
        p.setHidden(true);
        Value v = new Value();
        v.setInitializerParameter(p);
        p.setModel(v);
        v.setName(s.getName());
        p.setName(s.getName());
        p.setDeclaration(s);
        visitElement(that, v);
        unit.addDeclaration(v);
        Scope sc = getContainer(that);
        sc.addMember(v);
       
View Full Code Here

        super.visit(that);
    }
   
    @Override
    public void visit(Tree.InitializerParameter that) {
        Parameter p = new Parameter();
        p.setDeclaration(declaration);
        p.setDefaulted(that.getSpecifierExpression()!=null);
        p.setHidden(true);
        p.setName(that.getIdentifier().getText());
        that.setParameterModel(p);
//        visitDeclaration(that, p);
        super.visit(that);
        parameterList.getParameters().add(p);
    }
View Full Code Here

                .getSpecifierExpression();
    }
   
    @Override
    public void visit(Tree.ValueParameterDeclaration that) {
        Parameter p = new Parameter();
        p.setDeclaration(declaration);
        p.setDefaulted(getSpecifier(that)!=null);
        Tree.Type type = that.getTypedDeclaration().getType();
        p.setSequenced(type instanceof Tree.SequencedType);
        that.setParameterModel(p);
        super.visit(that);
        Value v = (Value) that.getTypedDeclaration().getDeclarationModel();
        p.setName(v.getName());
        p.setModel(v);
        v.setInitializerParameter(p);
        parameterList.getParameters().add(p);
        if (p.isSequenced() && p.isDefaulted()) {
            getSpecifier(that).addError("variadic parameter may not specify default argument");
        }
        if (p.isSequenced() && ((Tree.SequencedType) type).getAtLeastOne()) {
//            that.getType().addWarning("nonempty variadic parameters are not yet supported");
            p.setAtLeastOne(true);
        }
        if (v.isFormal()) {
            that.addError("parameters may not be annotated formal", 1312);
        }
//        if (v.isVariable()) {
View Full Code Here

//        }
    }

    @Override
    public void visit(Tree.FunctionalParameterDeclaration that) {
        Parameter p = new Parameter();
        p.setDeclaration(declaration);
        p.setDefaulted(getSpecifier(that)!=null);
        Tree.Type type = that.getTypedDeclaration().getType();
        p.setDeclaredAnything(type instanceof Tree.VoidModifier);
        that.setParameterModel(p);
        super.visit(that);
        Method m = (Method) that.getTypedDeclaration().getDeclarationModel();
        p.setModel(m);
        p.setName(m.getName());
        m.setInitializerParameter(p);
        parameterList.getParameters().add(p);
        if (type instanceof Tree.SequencedType) {
            type.addError("functional parameter type may not be variadic");
        }
View Full Code Here

                        Method fp = (Method)fpClass.getDirectMember("functionalParameter", null, false);
                        Assert.assertNotNull(fp);
                        Assert.assertEquals(1, fp.getParameterLists().size());
                        Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
                        Assert.assertEquals("Anything(Anything(String))", typeName(fp));
                        Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertTrue(paramF.isDeclaredAnything());
                        Assert.assertEquals("f", paramF.getName());
                        Assert.assertTrue(paramF.getModel() instanceof Method);
                        Method modelF = (Method)paramF.getModel();
                        Assert.assertTrue(modelF.isDeclaredVoid());
                        Assert.assertEquals("Anything(String)", typeName(modelF));
                        Assert.assertEquals("f", modelF.getName());
                        Assert.assertEquals(1, modelF.getParameterLists().size());
                        Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
                        Parameter paramS = modelF.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("s", paramS.getName());
                        Assert.assertTrue(paramS.getModel() instanceof Value);
                        Value modelS = (Value)paramS.getModel();
                        Assert.assertEquals("s", modelS.getName());
                        Assert.assertEquals("String", typeName(modelS));
                    }
                    { // callableValueParameter
                        Method fp = (Method)fpClass.getDirectMember("callableValueParameter", null, false);
                        Assert.assertNotNull(fp);
                        Assert.assertEquals(1, fp.getParameterLists().size());
                        Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
                        Assert.assertEquals("Anything(Anything(String))", typeName(fp));
                        Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("f", paramF.getName());
                        Assert.assertFalse(paramF.isDeclaredAnything());
                        Assert.assertTrue(paramF.getModel() instanceof Value);
                        Value modelF = (Value)paramF.getModel();
                        Assert.assertEquals("f", modelF.getName());
                        Assert.assertEquals("Anything(String)", typeName(modelF));
                    }
                    { // functionalParameterNested
                        Method fp = (Method)fpClass.getDirectMember("functionalParameterNested", null, false);
                        Assert.assertNotNull(fp);
                        Assert.assertEquals(1, fp.getParameterLists().size());
                        Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
                        Assert.assertEquals("Anything(Anything(Anything(String)))", typeName(fp));
                        Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("f", paramF.getName());
                        Assert.assertTrue(paramF.isDeclaredAnything());
                        Assert.assertTrue(paramF.getModel() instanceof Method);
                        Method modelF = (Method)paramF.getModel();
                        Assert.assertEquals("Anything(Anything(String))", typeName(modelF));
                        Assert.assertEquals("f", modelF.getName());
                        Assert.assertTrue(modelF.isDeclaredVoid());
                        Assert.assertEquals(1, modelF.getParameterLists().size());
                        Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
                        Parameter paramF2 = modelF.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertTrue(paramF2.isDeclaredAnything());
                        Assert.assertEquals("f2", paramF2.getName());
                        Assert.assertTrue(paramF2.getModel() instanceof Method);
                        Method modelF2 = (Method)paramF2.getModel();
                        Assert.assertEquals("Anything(String)", typeName(modelF2));
                        Assert.assertEquals("f2", modelF2.getName());
                        Assert.assertTrue(modelF2.isDeclaredVoid());
                        Assert.assertEquals(1, modelF2.getParameterLists().size());
                        Assert.assertEquals(1, modelF2.getParameterLists().get(0).getParameters().size());
                        Parameter paramS = modelF2.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("s", paramS.getName());
                        Assert.assertTrue(paramS.getModel() instanceof Value);
                        Value modelS = (Value)paramS.getModel();
                        Assert.assertEquals("s", modelS.getName());
                        Assert.assertEquals("String", typeName(modelS));
                    }
                    { // functionalParameterNested2
                        Method fp = (Method)fpClass.getDirectMember("functionalParameterNested2", null, false);
                        Assert.assertNotNull(fp);
                        Assert.assertEquals(1, fp.getParameterLists().size());
                        Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
                        Assert.assertEquals("Anything(Anything(Anything(String, Anything(Boolean, Integer))))", typeName(fp));
                       
                        Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("f", paramF.getName());
                        Assert.assertTrue(paramF.getModel() instanceof Method);
                        Method modelF = (Method)paramF.getModel();
                        Assert.assertEquals("f", modelF.getName());
                        Assert.assertEquals("Anything(Anything(String, Anything(Boolean, Integer)))", typeName(modelF));
                        Assert.assertEquals(1, modelF.getParameterLists().size());
                        Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
                       
                        Parameter paramF2 = modelF.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("f2", paramF2.getName());
                        Assert.assertTrue(paramF2.getModel() instanceof Method);
                        Method modelF2 = (Method)paramF2.getModel();
                        Assert.assertEquals("Anything(String, Anything(Boolean, Integer))", typeName(modelF2));
                        Assert.assertEquals("f2", modelF2.getName());
                        Assert.assertEquals(1, modelF2.getParameterLists().size());
                        Assert.assertEquals(2, modelF2.getParameterLists().get(0).getParameters().size());
                       
                        Parameter paramS = modelF2.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("s", paramS.getName());
                        Assert.assertTrue(paramS.getModel() instanceof Value);
                        Value modelS = (Value)paramS.getModel();
                        Assert.assertEquals("String", typeName(modelS));
                        Assert.assertEquals("s", modelS.getName());
                       
                        Parameter paramF3 = modelF2.getParameterLists().get(0).getParameters().get(1);
                        Assert.assertEquals("f3", paramF3.getName());
                        Assert.assertTrue(paramF3.getModel() instanceof Method);
                        Method modelF3 = (Method)paramF3.getModel();
                        Assert.assertEquals("Anything(Boolean, Integer)", typeName(modelF3));
                        Assert.assertEquals("f3", modelF3.getName());
                        Assert.assertEquals(1, modelF3.getParameterLists().size());
                        Assert.assertEquals(2, modelF3.getParameterLists().get(0).getParameters().size());
                       
                        Parameter paramB1 = modelF3.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("b1", paramB1.getName());
                        Assert.assertTrue(paramB1.getModel() instanceof Value);
                        Value modelB1 = (Value)paramB1.getModel();
                        Assert.assertEquals("Boolean", typeName(modelB1));
                        Assert.assertEquals("b1", modelB1.getName());
                       
                        Parameter paramI2 = modelF3.getParameterLists().get(0).getParameters().get(1);
                        Assert.assertEquals("i2", paramI2.getName());
                        Assert.assertTrue(paramI2.getModel() instanceof Value);
                        Value modelI2 = (Value)paramI2.getModel();
                        Assert.assertEquals("i2", modelI2.getName());
                        Assert.assertEquals("Integer", typeName(modelI2));
                    }
                    { // functionalParameterMpl
                        Method fp = (Method)fpClass.getDirectMember("functionalParameterMpl", null, false);
                        Assert.assertNotNull(fp);
                        Assert.assertEquals(1, fp.getParameterLists().size());
                        Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
                        Assert.assertEquals("Anything(Anything(Integer)(String))", typeName(fp));
                       
                        Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertTrue(paramF.isDeclaredAnything());
                        Assert.assertEquals("mpl", paramF.getName());
                        Assert.assertTrue(paramF.getModel() instanceof Method);
                        Method modelF = (Method)paramF.getModel();
                        Assert.assertTrue(modelF.isDeclaredVoid());
                        Assert.assertEquals("Anything(Integer)(String)", typeName(modelF));
                        Assert.assertEquals("mpl", modelF.getName());
                        Assert.assertEquals(2, modelF.getParameterLists().size());
                        Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
                        Assert.assertEquals(1, modelF.getParameterLists().get(1).getParameters().size());
                       
                        Parameter paramS = modelF.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("s", paramS.getName());
                        Assert.assertTrue(paramS.getModel() instanceof Value);
                        Value modelS = (Value)paramS.getModel();
                        Assert.assertEquals("s", modelS.getName());
                        Assert.assertEquals("String", typeName(modelS));
                       
                        Parameter paramS2 = modelF.getParameterLists().get(1).getParameters().get(0);
                        Assert.assertEquals("i2", paramS2.getName());
                        Assert.assertTrue(paramS2.getModel() instanceof Value);
                        Value modelS2 = (Value)paramS2.getModel();
                        Assert.assertEquals("i2", modelS2.getName());
                        Assert.assertEquals("Integer", typeName(modelS2));
                    }
                    { // functionalParameterMpl2
                        Method fp = (Method)fpClass.getDirectMember("functionalParameterMpl2", null, false);
                        Assert.assertNotNull(fp);
                        Assert.assertEquals(1, fp.getParameterLists().size());
                        Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
                       
                        Parameter paramMpl = fp.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("mpl", paramMpl.getName());
                        Assert.assertTrue(paramMpl.getModel() instanceof Method);
                        Method modelMpl = (Method)paramMpl.getModel();
                        Assert.assertEquals("mpl", modelMpl.getName());
                        Assert.assertEquals(2, modelMpl.getParameterLists().size());
                        Assert.assertEquals(1, modelMpl.getParameterLists().get(0).getParameters().size());
                        Assert.assertEquals(1, modelMpl.getParameterLists().get(1).getParameters().size());
                       
                        Parameter paramS = modelMpl.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("s", paramS.getName());
                        Assert.assertTrue(paramS.getModel() instanceof Value);
                        Value modelS = (Value)paramS.getModel();
                        Assert.assertEquals("s", modelS.getName());
                        Assert.assertEquals("String", typeName(modelS));
                       
                        Parameter paramF = modelMpl.getParameterLists().get(1).getParameters().get(0);
                        Assert.assertEquals("f", paramF.getName());
                        Assert.assertTrue(paramF.getModel() instanceof Method);
                        Method modelF = (Method)paramF.getModel();
                        Assert.assertEquals("f", modelF.getName());
                        Assert.assertEquals(1, modelF.getParameterLists().size());
                        Assert.assertEquals(2, modelF.getParameterLists().get(0).getParameters().size());
                       
                        Parameter paramB1 = modelF.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("b1", paramB1.getName());
                        Assert.assertTrue(paramB1.getModel() instanceof Value);
                        Value modelB1 = (Value)paramB1.getModel();
                        Assert.assertEquals("b1", modelB1.getName());
                        Assert.assertEquals("Boolean", typeName(modelB1));
                       
                        Parameter paramI2 = modelF.getParameterLists().get(0).getParameters().get(1);
                        Assert.assertEquals("i2", paramI2.getName());
                        Assert.assertTrue(paramI2.getModel() instanceof Value);
                        Value modelI2 = (Value)paramI2.getModel();
                        Assert.assertEquals("i2", modelI2.getName());
                        Assert.assertEquals("Integer", typeName(modelI2));
                       
                    }
                    { // functionalParameterMpl3
                        Method fp = (Method)fpClass.getDirectMember("functionalParameterMpl3", null, false);
                        Assert.assertNotNull(fp);
                        Assert.assertEquals(1, fp.getParameterLists().size());
                        Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
                       
                        Parameter paramMpl = fp.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("mpl", paramMpl.getName());
                        Assert.assertTrue(paramMpl.getModel() instanceof Method);
                        Method modelMpl = (Method)paramMpl.getModel();
                        Assert.assertEquals("mpl", modelMpl.getName());
                        Assert.assertEquals(2, modelMpl.getParameterLists().size());
                        Assert.assertEquals(1, modelMpl.getParameterLists().get(0).getParameters().size());
                        Assert.assertEquals(1, modelMpl.getParameterLists().get(1).getParameters().size());
                       
                        Parameter paramF = modelMpl.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("f", paramF.getName());
                        Assert.assertTrue(paramF.getModel() instanceof Method);
                        Method modelF = (Method)paramF.getModel();
                        Assert.assertEquals("f", modelF.getName());
                        Assert.assertEquals(1, modelF.getParameterLists().size());
                        Assert.assertEquals(2, modelF.getParameterLists().get(0).getParameters().size());
                       
                        Parameter paramB1 = modelF.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("b1", paramB1.getName());
                        Assert.assertTrue(paramB1.getModel() instanceof Value);
                        Value modelB1 = (Value)paramB1.getModel();
                        Assert.assertEquals("b1", modelB1.getName());
                        Assert.assertEquals("Boolean", typeName(modelB1));
                       
                        Parameter paramI2 = modelF.getParameterLists().get(0).getParameters().get(1);
                        Assert.assertEquals("i2", paramI2.getName());
                        Assert.assertTrue(paramI2.getModel() instanceof Value);
                        Value modelI2 = (Value)paramI2.getModel();
                        Assert.assertEquals("i2", modelI2.getName());
                        Assert.assertEquals("Integer", typeName(modelI2));
                       
                        Parameter paramS = modelMpl.getParameterLists().get(1).getParameters().get(0);
                        Assert.assertEquals("s", paramS.getName());
                        Assert.assertTrue(paramS.getModel() instanceof Value);
                        Value modelS = (Value)paramS.getModel();
                        Assert.assertEquals("s", modelS.getName());
                        Assert.assertEquals("String", typeName(modelS));
                    }
                    { // functionalParameterReturningCallable
                        Method fp = (Method)fpClass.getDirectMember("functionalParameterReturningCallable", null, false);
                        Assert.assertNotNull(fp);
                        Assert.assertEquals(1, fp.getParameterLists().size());
                        Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
                        Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("f", paramF.getName());
                        Assert.assertTrue(paramF.getModel() instanceof Method);
                        Method modelF = (Method)paramF.getModel();
                        Assert.assertEquals("f", modelF.getName());
                        Assert.assertEquals("Type[Anything()]", modelF.getType().toString());
                        Assert.assertEquals(1, modelF.getParameterLists().size());
                        Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
                        Parameter paramS = modelF.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("s", paramS.getName());
                        Assert.assertTrue(paramS.getModel() instanceof Value);
                        Value modelS = (Value)paramS.getModel();
                        Assert.assertEquals("s", modelS.getName());
                        Assert.assertEquals("Type[String]", modelS.getType().toString());
                    }
                    { // functionalParameterReturningCallable
                        Method fp = (Method)fpClass.getDirectMember("functionalParameterTakingCallable", null, false);
                        Assert.assertNotNull(fp);
                        Assert.assertEquals(1, fp.getParameterLists().size());
                        Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
                        Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("f", paramF.getName());
                        Assert.assertTrue(paramF.getModel() instanceof Method);
                        Method modelF = (Method)paramF.getModel();
                        Assert.assertEquals("f", modelF.getName());
                        Assert.assertEquals("Type[Anything]", modelF.getType().toString());
                        Assert.assertEquals(1, modelF.getParameterLists().size());
                        Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
                        Parameter paramF2 = modelF.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("f2", paramF2.getName());
                        Assert.assertTrue(paramF2.getModel() instanceof Value);
                        Value modelF2 = (Value)paramF2.getModel();
                        Assert.assertEquals("f2", modelF2.getName());
                        Assert.assertEquals("Type[Anything(String)]", modelF2.getType().toString());
                    }
                    { // functionalParameterVariadicStar
                        Method fp = (Method)fpClass.getDirectMember("functionalParameterVariadicStar", null, false);
                        Assert.assertNotNull(fp);
                        Assert.assertEquals(1, fp.getParameterLists().size());
                        Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
                        Assert.assertEquals("Anything(Anything(String*))", typeName(fp));
                        Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertTrue(paramF.isDeclaredAnything());
                        Assert.assertEquals("f", paramF.getName());
                        Assert.assertTrue(paramF.getModel() instanceof Method);
                        Method modelF = (Method)paramF.getModel();
                        Assert.assertTrue(modelF.isDeclaredVoid());
                        Assert.assertEquals("Anything(String*)", typeName(modelF));
                        Assert.assertEquals("f", modelF.getName());
                        Assert.assertEquals(1, modelF.getParameterLists().size());
                        Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
                        Parameter paramS = modelF.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("s", paramS.getName());
                        Assert.assertTrue(paramS.isSequenced());
                        Assert.assertFalse(paramS.isAtLeastOne());
                        Assert.assertTrue(paramS.getModel() instanceof Value);
                        Value modelS = (Value)paramS.getModel();
                        Assert.assertEquals("s", modelS.getName());
                        Assert.assertEquals("String[]", typeName(modelS));
                    }
                    { // functionalParameterVariadicPlus
                        Method fp = (Method)fpClass.getDirectMember("functionalParameterVariadicPlus", null, false);
                        Assert.assertNotNull(fp);
                        Assert.assertEquals(1, fp.getParameterLists().size());
                        Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
                        Assert.assertEquals("Anything(Anything(String+))", typeName(fp));
                        Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertTrue(paramF.isDeclaredAnything());
                        Assert.assertEquals("f", paramF.getName());
                        Assert.assertTrue(paramF.getModel() instanceof Method);
                        Method modelF = (Method)paramF.getModel();
                        Assert.assertTrue(modelF.isDeclaredVoid());
                        Assert.assertEquals("Anything(String+)", typeName(modelF));
                        Assert.assertEquals("f", modelF.getName());
                        Assert.assertEquals(1, modelF.getParameterLists().size());
                        Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
                        Parameter paramS = modelF.getParameterLists().get(0).getParameters().get(0);
                        Assert.assertEquals("s", paramS.getName());
                        Assert.assertTrue(paramS.isSequenced());
                        Assert.assertTrue(paramS.isAtLeastOne());
                        Assert.assertTrue(paramS.getModel() instanceof Value);
                        Value modelS = (Value)paramS.getModel();
                        Assert.assertEquals("s", modelS.getName());
                        Assert.assertEquals("[String+]", typeName(modelS));
                    }
                }

View Full Code Here

   
    // FIXME There is a similar implementation in ClassGen!
    public List<JCStatement> transform(Tree.AttributeDeclaration decl) {
        ListBuffer<JCStatement> result = ListBuffer.<JCStatement> lb();
        // If the attribute is really from a parameter then don't generate a local variable
        Parameter parameter = CodegenUtil.findParamForDecl(decl);
        if (parameter == null) {
           
            final Name attrName = names().fromString(naming.substitute(decl.getDeclarationModel()));
           
            ProducedType t = decl.getDeclarationModel().getType();
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.Parameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.