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

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


                            }
                            scope = scope.getScope();
                        }
                        targs = new HashMap<>();
                        targs.putAll(pt.getTypeArguments());
                        Declaration cd = Util.getContainingDeclaration(pt.getDeclaration());
                        while (cd != null) {
                            if (cd instanceof Generic) {
                                for (TypeParameter tp : ((Generic)cd).getTypeParameters()) {
                                    if (parenttp.contains(tp)) {
                                        targs.put(tp, tp.getType());
View Full Code Here


            sb.add(d.getName());
            if (d instanceof Setter) {
                sb.add("$set");
            }
        } else {
            Declaration p = d;
            final int i = sb.size();
            while (p instanceof Declaration) {
                if (p instanceof Setter) {
                    sb.add(i, "$set");
                }
                sb.add(i, TypeUtils.modelName(p));
                //Build the path in reverse
                if (!p.isToplevel()) {
                    if (p instanceof com.redhat.ceylon.compiler.typechecker.model.Class) {
                        sb.add(i, p.isAnonymous() ? MetamodelGenerator.KEY_OBJECTS : MetamodelGenerator.KEY_CLASSES);
                    } else if (p instanceof com.redhat.ceylon.compiler.typechecker.model.Interface) {
                        sb.add(i, MetamodelGenerator.KEY_INTERFACES);
                    } else if (p instanceof Method) {
                        sb.add(i, MetamodelGenerator.KEY_METHODS);
                    } else if (p instanceof TypeAlias || p instanceof Setter) {
View Full Code Here

            }

        }
        if (!d.isToplevel()) {
            //Find the first container that is a Declaration
            Declaration _cont = Util.getContainingDeclaration(d);
            gen.out(",$cont:");
            boolean generateName = true;
            if (_cont.getName().startsWith("anonymous#")) {
                //Anon functions don't have metamodel so go up until we find a non-anon container
                Declaration _supercont = Util.getContainingDeclaration(_cont);
                while (_supercont != null && _supercont.getName().startsWith("anonymous#")) {
                    _supercont = Util.getContainingDeclaration(_supercont);
                }
                if (_supercont == null) {
                    //If the container is a package, add it because this isn't really toplevel
                    generateName = false;
View Full Code Here

                //Remove these annotations from the list
                anns = new ArrayList<Annotation>(d.getAnnotations().size());
                anns.addAll(d.getAnnotations());
                for (Iterator<Annotation> iter = anns.iterator(); iter.hasNext();) {
                    final Annotation a = iter.next();
                    final Declaration ad = d.getUnit().getPackage().getMemberOrParameter(d.getUnit(), a.getName(), null, false);
                    final String qn = ad.getQualifiedNameString();
                    if (qn.startsWith("ceylon.language::") && MetamodelGenerator.annotationBits.contains(qn.substring(17))) {
                        iter.remove();
                    }
                }
                if (anns.isEmpty()) {
                    return;
                }
            }
            gen.out(",", MetamodelGenerator.KEY_ANNOTATIONS, ":function(){return[");
            boolean first = true;
            for (Annotation a : anns) {
                Declaration ad = d.getUnit().getPackage().getMemberOrParameter(d.getUnit(), a.getName(), null, false);
                if (ad instanceof Method) {
                    if (first) first=false; else gen.out(",");
                    final boolean isDoc = "ceylon.language::doc".equals(ad.getQualifiedNameString());
                    if (!isDoc) {
                        gen.qualify(node, ad);
                        gen.out(gen.getNames().name(ad), "(");
                    }
                    if (a.getPositionalArguments() == null) {
View Full Code Here

        for (Declaration d0 : m1.getMembers()) {
            String n = d0.getQualifiedNameString();
            if (n.indexOf('.') < 0) {
                n += "(" + d0.getContainer().getQualifiedNameString() + ")";
            }
            Declaration d1 = findMatchingDeclaration(d0, m2.getMembers());
            Assert.assertNotNull(n + " not found in " + m2, d1);
            Assert.assertEquals(n + " declaration kinds differ", d0.getDeclarationKind(), d1.getDeclarationKind());
            if (d0.getContainer() == null) {
                Assert.assertNull(d1.getContainer());
            } else {
                Assert.assertEquals(d0.getContainer().getQualifiedNameString(), d1.getContainer().getQualifiedNameString());
            }
            if (d0 instanceof TypeDeclaration) {
                Assert.assertEquals(d0.getClass(), d1.getClass());
                compareTypeDeclarations((TypeDeclaration)d0, (TypeDeclaration)d1);
            }
            compareMembers(d0, d1);
        }
    }
View Full Code Here

        Assert.assertNotNull("langmod from js", jsmod);
        Assert.assertNotNull("clpack from source", srclang);
        Assert.assertNotNull("clpack from js", jslang);
        Assert.assertEquals(srclang.getMembers().size(), jslang.getMembers().size());
        for (Declaration d0 : srclang.getMembers()) {
            Declaration d1 = findMatchingDeclaration(d0, jslang.getMembers());
            Assert.assertNotNull(d0.getName() + " not found in js", d1);
            if (d0 instanceof ClassOrInterface && d1 instanceof Value) {
                d1 = ((Value)d1).getTypeDeclaration();
            }
            Assert.assertEquals(d0 + " wrong class!", d0.getClass(), d1.getClass());
            Assert.assertEquals(d0 + " wrong kind " + d1, d0.getDeclarationKind(), d1.getDeclarationKind());
            compareMembers(d0, d1);
        }
    }
View Full Code Here

        }
        List<TypeParameter> tparms = new ArrayList<TypeParameter>(typeParams.size());
        //To avoid circularity, this is done in two phases:
        //First create the type parameters
        for (Map<String,Object> tp : typeParams) {
            final Declaration maybe;
            if (tp.get(MetamodelGenerator.KEY_METATYPE) instanceof TypeParameter) {
                maybe = (TypeParameter)tp.get(MetamodelGenerator.KEY_METATYPE);
            } else {
                maybe = container.getDirectMember((String)tp.get(MetamodelGenerator.KEY_NAME), null, false);
            }
View Full Code Here

    /** Sets the refined declarations for the type's members. */
    private void refineMembers(ClassOrInterface coi) {
        //fill refined declarations
        for (Declaration d : coi.getMembers()) {
            if (d.isActual()) {
                Declaration refined = coi.getRefinedMember(d.getName(), getSignature(d), false);
                if (refined==null) refined = d;
                d.setRefinedDeclaration(refined);
            }
            if (d instanceof ClassOrInterface) {
                refineMembers((ClassOrInterface)d);
View Full Code Here

            alias = (TypeAlias)m.get(MetamodelGenerator.KEY_METATYPE);
            if (m.size() == 1) {
                return alias;
            }
        } else {
            Declaration maybe = parent.getDirectMember(name, null, false);
            if (maybe == null) {
                alias = new TypeAlias();
                alias.setContainer(parent);
                alias.setName(name);
                alias.setUnit(u2);
View Full Code Here

                    ((JsonPackage) rp).loadDeclarations();
                }
                final boolean nested = tname.indexOf('.') > 0;
                final String level1 = nested ? tname.substring(0, tname.indexOf('.')) : tname;
                if (rp != null && !nested) {
                    Declaration d = rp.getDirectMember(tname, null, false);
                    if (d instanceof TypeDeclaration) {
                        td = (TypeDeclaration)d;
                    } else if (d instanceof MethodOrValue) {
                        td = ((MethodOrValue)d).getTypeDeclaration();
                    }
                }
                if (td == null && rp instanceof JsonPackage) {
                    if (nested) {
                        td = ((JsonPackage)rp).loadNestedType(tname, typeParams);
                    } else {
                        td = (TypeDeclaration)((JsonPackage)rp).load(tname, typeParams);
                    }
                }
                //Then look in the top-level declarations
                if (nested && td == null) {
                    for (Declaration d : rp.getMembers()) {
                        if (d instanceof TypeDeclaration && level1.equals(d.getName())) {
                            td = (TypeDeclaration)d;
                        }
                    }
                    final String[] path = tname.split("\\.");
                    for (int i = 1; i < path.length; i++) {
View Full Code Here

TOP

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

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.