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

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


    }
   
    @Override
    public void visit(Tree.ImportModule that) {
        super.visit(that);
        Unit unit = that.getUnit();
        checkAnnotations(that.getAnnotationList(),
                unit.getImportDeclarationType(), null);
    }
View Full Code Here


        if (c.isAnnotation()) {
            checkAnnotationType(that, c);
        }
       
        TypeDeclaration dm = that.getDeclarationModel();
        Unit unit = that.getUnit();
        checkAnnotations(that.getAnnotationList(),
                unit.getClassDeclarationType(),
                unit.getClassMetatype(dm.getType()));
    }
View Full Code Here

    @Override
    public void visit(Tree.AnyInterface that) {
        super.visit(that);
        TypeDeclaration dm = that.getDeclarationModel();
        Unit unit = that.getUnit();
        checkAnnotations(that.getAnnotationList(),
                unit.getInterfaceDeclarationType(),
                unit.getInterfaceMetatype(dm.getType()));
    }
View Full Code Here

   
    @Override
    public void visit(Tree.AnyAttribute that) {
        super.visit(that);
        TypedDeclaration dm = that.getDeclarationModel();
        Unit unit = that.getUnit();
        checkAnnotations(that.getAnnotationList(),
                unit.getValueDeclarationType(dm),
                unit.getValueMetatype(dm.getTypedReference()));
    }
View Full Code Here

        if (a.isAnnotation()) {
            checkAnnotationConstructor(that, a);
        }
       
        TypedDeclaration dm = that.getDeclarationModel();
        Unit unit = that.getUnit();
        checkAnnotations(that.getAnnotationList(),
                unit.getFunctionDeclarationType(),
                unit.getFunctionMetatype(dm.getTypedReference()));
    }
View Full Code Here

        }
    }

    private void checkAnnotations(AnnotationList annotationList,
            ProducedType declarationType, ProducedType metatype) {
        Unit unit = annotationList.getUnit();
        List<Annotation> anns = annotationList.getAnnotations();
        for (Annotation ann: anns) {
            ProducedType t = ann.getTypeModel();
            if (t!=null) {
                ProducedType pet = t.getSupertype(unit.getConstrainedAnnotationDeclaration());
                if (pet!=null && pet.getTypeArgumentList().size()>2) {
                    ProducedType ct = pet.getTypeArgumentList().get(2);
                    ProducedType mt = declarationType; //intersectionType(declarationType,metatype, unit);
                    checkAssignable(mt, ct, ann,
                            "annotated program element does not satisfy annotation constraints");
                }
            }
        }
        for (int i=0; i<anns.size(); i++) {
            ProducedType t = anns.get(i).getTypeModel();
            if (t!=null && t.getDeclaration().inherits(unit.getOptionalAnnotationDeclaration())) {
                for (int j=0; j<i; j++) {
                    ProducedType ot = anns.get(j).getTypeModel();
                    if (ot!=null && ot.getDeclaration().equals(t.getDeclaration())) {
                        anns.get(i).addError("duplicate annotation: there are multiple annotations of type '" +
                                t.getDeclaration().getName() + "'");
View Full Code Here

    return err.getTreeNode().getLocation() + " of " +
                file(err.getTreeNode());
  }

  private String file(Node that) {
    Unit unit = that.getUnit();
    String relativePath = unit.getRelativePath();
        return !relativePath.isEmpty() ?
        relativePath :
        unit.getFilename();
  }
View Full Code Here

    public void removePhasedUnitForRelativePath(String relativePath) {
        String path = relativePathToPath.get(relativePath);
        ReturnedType phasedUnit = fromStoredType(phasedUnitPerPath.get(path), path);
        if (phasedUnit != null) {
            Unit unit = phasedUnit.getUnit();
            if (unit != null) {
                unit.getPackage().removeUnit(unit);
            }
        }
        relativePathToPath.remove(relativePath);
        phasedUnitPerPath.remove(path);
    }
View Full Code Here

        }
        return null;
    }

    protected Unit createUnit() {
        return new Unit();
    }
View Full Code Here

        if (pt==null || pt.getDeclaration()==null) {
            return "unknown";
        }
        else {
            if (printAbbreviated()) {
                Unit u = pt.getDeclaration().getUnit();
                if (abbreviateOptional(pt)) {
                    ProducedType dt = pt.eliminateNull();
                    String dtn = getProducedTypeName(dt, unit);
                    if (isPrimitiveAbbreviatedType(dt)) {
                        return dtn + "?";
                    }
                    else {
                        return lt() + dtn + gt() + "?";
                    }
                }
                if (abbreviateEmpty(pt)) {
                    return "[]";
                }
                if (abbreviateSequential(pt)) {
                    ProducedType it = u.getIteratedType(pt);
                    String etn = getProducedTypeName(it, unit);
                    if (isPrimitiveAbbreviatedType(it)) {
                        return etn + "[]";
                    }
                    else {
                        return lt() + etn + gt() + "[]";
                    }
                }
                if (abbreviateSequence(pt)) {
                    ProducedType it = u.getIteratedType(pt);
                    String etn = getProducedTypeName(it, unit);
                    if (isPrimitiveAbbreviatedType(it) ||
                            it.getDeclaration() instanceof UnionType ||
                            it.getDeclaration() instanceof IntersectionType ) {
                        return "[" + etn + "+]";
                    }
                    else {
                        return "[" + lt() + etn + gt() + "+]";
                    }
                }
                if (abbreviateIterable(pt)) {
                    ProducedType it = u.getIteratedType(pt);
                    ProducedType nt = pt.getTypeArgumentList().get(1);
                    if (it.isNothing() && !nt.isNothing()) {
                      return "{}";
                    }
                    String itn = getProducedTypeName(it, unit);
                    String many = nt.isNothing() ? "+" : "*";
                    if (isPrimitiveAbbreviatedType(it) ||
                            it.getDeclaration() instanceof UnionType ||
                            it.getDeclaration() instanceof IntersectionType) {
                        return "{" + itn + many + "}";
                    }
                    else {
                        return "{" + lt() + itn + gt() + many + "}";
                    }
                }
                if (abbreviateEntry(pt)) {
                    return getProducedTypeName(u.getKeyType(pt), unit) +
                            "-" + gt()
                            + getProducedTypeName(u.getValueType(pt), unit);
                }
                if (abbreviateCallable(pt)) {
                    List<ProducedType> tal = pt.getTypeArgumentList();
                    ProducedType rt = tal.get(0);
                    ProducedType at = tal.get(1);
View Full Code Here

TOP

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

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.