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

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


    private void collectAnnotationConstructors() {
        for (Module module : modules) {
            for (Package pkg : getPackages(module)) {
                for (Declaration decl : pkg.getMembers()) {
                    if (decl instanceof Method && decl.isAnnotation() && shouldInclude(decl)) {
                        Method annotationCtor = (Method) decl;
                        TypeDeclaration annotationType = annotationCtor.getTypeDeclaration();
                        List<Method> annotationConstructorList = annotationConstructors.get(annotationType);
                        if (annotationConstructorList == null) {
                            annotationConstructorList = new ArrayList<Method>();
                            annotationConstructors.put(annotationType, annotationConstructorList);
                        }
View Full Code Here


                    Package p = mod.getDirectPackage(packageForJavaModelLoading());
                    Assert.assertNotNull(p);
                    Declaration fpClass = p.getDirectMember("FunctionalParameterParameterNames", Collections.<ProducedType>emptyList(), false);
                    Assert.assertNotNull(fpClass);
                    { // functionalParameter
                        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();
View Full Code Here

                Assert.assertNotNull(p);
                Declaration javaType = p.getDirectMember("JavaType", null, false);
                Assert.assertNotNull(javaType);
               
                // check the method which returns a java list
                Method javaListMethod = (Method) javaType.getDirectMember("javaList", null, false);
                Assert.assertNotNull(javaListMethod);
                Assert.assertEquals("List<out Object>", javaListMethod.getType().getProducedTypeName());
                Parameter javaListParam = javaListMethod.getParameterLists().get(0).getParameters().get(0);
                Assert.assertNotNull(javaListParam);
                Assert.assertEquals("List<out Object>?", javaListParam.getType().getProducedTypeName());

                // check the method which returns a Ceylon list
                Method ceylonListMethod = (Method) javaType.getDirectMember("ceylonList", null, false);
                Assert.assertNotNull(ceylonListMethod);
                Assert.assertEquals("List<Object>", ceylonListMethod.getType().getProducedTypeName());
                Parameter ceylonListParam = ceylonListMethod.getParameterLists().get(0).getParameters().get(0);
                Assert.assertNotNull(ceylonListParam);
                Assert.assertEquals("List<Object>?", ceylonListParam.getType().getProducedTypeName());

                Method equalsMethod = (Method) javaType.getDirectMember("equals", null, false);
                Assert.assertNotNull(equalsMethod);
                Assert.assertTrue(equalsMethod.isActual());
                Assert.assertTrue(equalsMethod.getRefinedDeclaration() != equalsMethod);

                Value hashAttribute = (Value) javaType.getDirectMember("hash", null, false);
                Assert.assertNotNull(hashAttribute);
                Assert.assertTrue(hashAttribute.isActual());
                Assert.assertTrue(hashAttribute.getRefinedDeclaration() != hashAttribute);

                Value stringAttribute = (Value) javaType.getDirectMember("string", null, false);
                Assert.assertNotNull(stringAttribute);
                Assert.assertTrue(stringAttribute.isActual());
                Assert.assertTrue(stringAttribute.getRefinedDeclaration() != stringAttribute);

                Method cloneMethod = (Method) javaType.getDirectMember("clone", null, false);
                Assert.assertNotNull(cloneMethod);
                Assert.assertFalse(cloneMethod.isActual());
                Assert.assertTrue(cloneMethod.getRefinedDeclaration() == cloneMethod);

                Method finalizeMethod = (Method) javaType.getDirectMember("finalize", null, false);
                Assert.assertNotNull(finalizeMethod);
                Assert.assertFalse(finalizeMethod.isActual());
                Assert.assertTrue(finalizeMethod.getRefinedDeclaration() == finalizeMethod);
}
        });
    }
View Full Code Here

                Assert.assertNotNull(p);
                Declaration javaDep = p.getDirectMember("JavaDeprecated", null, false);
                Assert.assertNotNull(javaDep);
                Assert.assertEquals(javaDep.toString(), 1, numDeprecated(javaDep));
               
                Method javaMethod = (Method) javaDep.getDirectMember("m", null, false);
                Assert.assertNotNull(javaMethod);
                Assert.assertEquals(javaMethod.toString(), 1, numDeprecated(javaMethod));
               
                Parameter javaParameter = javaMethod.getParameterLists().get(0).getParameters().get(0);
                Assert.assertNotNull(javaParameter);
                Assert.assertEquals(javaParameter.toString(), 1, numDeprecated(javaParameter.getModel()));
               
                Value javaField = (Value) javaDep.getDirectMember("s", null, false);
                Assert.assertNotNull(javaField);
                Assert.assertEquals(javaField.toString(), 1, numDeprecated(javaField));
               
                // Check there is only 1 model Annotation, when annotation with ceylon's deprecated...
                javaMethod = (Method) javaDep.getDirectMember("ceylonDeprecation", null, false);
                Assert.assertNotNull(javaMethod);
                Assert.assertEquals(javaMethod.toString(), 1, numDeprecated(javaMethod));
               
                // ... or both the ceylon and java deprecated
                javaMethod = (Method) javaDep.getDirectMember("bothDeprecation", null, false);
                Assert.assertNotNull(javaMethod);
                Assert.assertEquals(javaMethod.toString(), 1, numDeprecated(javaMethod));
            }

            private int numDeprecated(Declaration javaDep) {
                int num = 0;
                for (Annotation a : javaDep.getAnnotations()) {
View Full Code Here

           && !(refinedDeclaration instanceof Functional && Decl.isMpl((Functional)refinedDeclaration))){
            declaration.setUnboxed(true);
        } else if (Decl.isValueParameter(declaration)
                && CodegenUtil.isContainerFunctionalParameter(declaration)
                && Strategy.createMethod((MethodOrValue)declaration.getContainer())) {
            Method functionalParameter = (Method)declaration.getContainer();
            TypedDeclaration refinedFrom = (TypedDeclaration)CodegenUtil.getTopmostRefinedDeclaration(functionalParameter, optimisedMethodSpecifiersToMethods);
            if (Decl.equal(refinedFrom, functionalParameter) ) {
                // Don't consider Anything to be unboxed, since this is a parameter
                // note a method return type (where void would be considered unboxed).
                declaration.setUnboxed(!declaration.getUnit().getAnythingDeclaration().getType().isExactly(declaration.getType()));
View Full Code Here

    }

    @Override
    public void visit(SpecifierStatement that) {
        TypedDeclaration declaration = that.getDeclaration();
        Method optimisedDeclaration = null;
        // make sure we detect the shortcut refinement inlining cases
        if(declaration instanceof Method){
            if(that.getSpecifierExpression() != null
                    && that.getSpecifierExpression() instanceof LazySpecifierExpression == false){
                Tree.Term term = Decl.unwrapExpressionsUntilTerm(that.getSpecifierExpression().getExpression());
View Full Code Here

        // a type parameter and if so if one of the type arguments is erased,
        // in that case we mark the expression itself as erased as well
        if (that.getPrimary() instanceof StaticMemberOrTypeExpression) {
            StaticMemberOrTypeExpression expr = (StaticMemberOrTypeExpression)that.getPrimary();
            if (expr.getDeclaration() instanceof Method) {
                Method mth = (Method)expr.getDeclaration();
                if (isTypeParameter(mth.getType())
                        && hasErasedTypeParameter(expr.getTarget(), expr.getTypeArguments().getTypeModels())) {
                    CodegenUtil.markTypeErased(that);
                    CodegenUtil.markUntrustedType(that);
                }
            }
View Full Code Here

        }
    }

    @Override
    public void visit(Tree.AnyMethod that){
        Method model = that.getDeclarationModel();
        int mpl = model.getParameterLists().size();
        String prefix = null;
        if(mpl > 1){
            prefix = this.prefix;
            for(int i=1;i<mpl;i++)
                enterAnonymousClass();
        }
        collect(that, model);
        // stop at locals, who get a type generated for them
        if(model.isMember())
            super.visit(that);
        if(mpl > 1){
            for(int i=1;i<mpl;i++)
                exitAnonymousClass();
            this.prefix = prefix;
View Full Code Here

                        && (isAnnotationConstructor( ((Tree.BaseMemberOrTypeExpression)primary).getDeclaration())
                          || isAnnotationClass( ((Tree.BaseMemberOrTypeExpression)primary).getDeclaration()))) {
                    final AnnotationInvocation prevInstantiation = this.instantiation;
                    this.instantiation = new AnnotationInvocation();
                    if (isAnnotationConstructor( ((Tree.BaseMemberOrTypeExpression)primary).getDeclaration())) {
                        Method constructor = (Method)((Tree.BaseMemberOrTypeExpression)primary).getDeclaration();
                        instantiation.setConstructorDeclaration(constructor);
                        instantiation.getConstructorParameters().addAll(((AnnotationInvocation)constructor.getAnnotationConstructor()).getConstructorParameters());
                    }
                    checkingDefaults = true;
                   
                    super.visit(d);
                   
View Full Code Here

    public void visit(Tree.BaseMemberExpression bme) {
        if (annotationConstructor != null) {
            Declaration declaration = bme.getDeclaration();
            if (checkingInvocationPrimary
                    && isAnnotationConstructor(bme.getDeclaration())) {
                Method ctor = (Method)bme.getDeclaration();
                instantiation.setPrimary(ctor);
                if (ctor.getAnnotationConstructor() != null) {
                    instantiation.getConstructorParameters().addAll(((AnnotationInvocation)ctor.getAnnotationConstructor()).getConstructorParameters());
                }
            } else if (checkingArguments || checkingDefaults) {
                if (declaration instanceof Value && ((Value)declaration).isParameter()) {
                    Value constructorParameter = (Value)declaration;
                    ParameterAnnotationTerm a = new ParameterAnnotationTerm();
View Full Code Here

TOP

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

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.