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

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


            }
        }
    }

    public static boolean abbreviateEntry(ProducedType pt) {
        Unit unit = pt.getDeclaration().getUnit();
        if (pt.getDeclaration() instanceof Class &&
                pt.getDeclaration().equals(unit.getEntryDeclaration()) &&
                pt.getTypeArgumentList().size()==2) {
            ProducedType kt = unit.getKeyType(pt);
            ProducedType vt = unit.getValueType(pt);
            return kt!=null && vt!=null; /*&&
                    kt.isPrimitiveAbbreviatedType() &&
                    vt.isPrimitiveAbbreviatedType();*/
        }
        else {
View Full Code Here


        }
    }

    public static boolean abbreviateEmpty(ProducedType pt) {
        if (pt.getDeclaration() instanceof Interface) {
            Unit unit = pt.getDeclaration().getUnit();
            return pt.getDeclaration().equals(unit.getEmptyDeclaration());
        }
        return false;
    }
View Full Code Here

        return false;
    }

    public static boolean abbreviateOptional(ProducedType pt) {
        if (pt.getDeclaration() instanceof UnionType) {
            Unit unit = pt.getDeclaration().getUnit();
            UnionType ut = (UnionType) pt.getDeclaration();
            return ut.getCaseTypes().size()==2 &&
                    isElementOfUnion(ut, unit.getNullDeclaration()); /*&&
                    minus(unit.getNullDeclaration()).isPrimitiveAbbreviatedType();*/
        }
        else {
            return false;
        }
View Full Code Here

        }
    }

    public static boolean abbreviateSequence(ProducedType pt) {
        if (pt.getDeclaration() instanceof Interface) {
            Unit unit = pt.getDeclaration().getUnit();
            if (pt.getDeclaration().equals(unit.getSequenceDeclaration())) {
                ProducedType et = unit.getIteratedType(pt);
                return et!=null;// && et.isPrimitiveAbbreviatedType();
            }
        }
        return false;
    }
View Full Code Here

        return false;
    }

    public static boolean abbreviateSequential(ProducedType pt) {
        if (pt.getDeclaration() instanceof Interface) {
            Unit unit = pt.getDeclaration().getUnit();
            if (pt.getDeclaration().equals(unit.getSequentialDeclaration())) {
                ProducedType et = unit.getIteratedType(pt);
                return et!=null;// && et.isPrimitiveAbbreviatedType();
            }
        }
        return false;
    }
View Full Code Here

        return false;
    }

    public static boolean abbreviateIterable(ProducedType pt) {
        if (pt.getDeclaration() instanceof Interface) {
            Unit unit = pt.getDeclaration().getUnit();
            if (pt.getDeclaration().equals(unit.getIterableDeclaration())) {
                ProducedType et = unit.getIteratedType(pt);
                if (et!=null && pt.getTypeArgumentList().size()==2) {
                    ProducedType at = pt.getTypeArgumentList().get(1);
                    if (at!=null) {
                        TypeDeclaration d = at.getDeclaration();
                        return d instanceof NothingType ||
                                d instanceof ClassOrInterface &&
                                d.equals(unit.getNullDeclaration());
                    }
                }// && et.isPrimitiveAbbreviatedType();
            }
        }
        return false;
View Full Code Here

   
    private static boolean isTupleTypeWellformed(ProducedType args) {
        if (args==null || args.getTypeArgumentList().size()<3) {
            return false;
        }
        Unit u = args.getDeclaration().getUnit();
        List<ProducedType> elemtypes = u.getTupleElementTypes(args);
        if (u.isTupleLengthUnbounded(args)) {
            int lastIndex = elemtypes.size()-1;
            ProducedType last = elemtypes.get(lastIndex);
            elemtypes.set(lastIndex, u.getSequentialElementType(last));
        }
        if (elemtypes==null) {
            return false;
        }
        UnionType ut = new UnionType(u);
View Full Code Here

        }
    }

    private String getTupleElementTypeNames(ProducedType args, Unit unit) {
        if (args!=null) {
            Unit u = args.getDeclaration().getUnit();
            boolean defaulted=false;
            if (args.getDeclaration() instanceof UnionType) {
                List<ProducedType> cts = args.getDeclaration().getCaseTypes();
                if (cts.size()==2) {
                    TypeDeclaration lc = cts.get(0).getDeclaration();
                    if (lc instanceof Interface &&
                            lc.equals(u.getEmptyDeclaration())) {
                        args = cts.get(1);
                        defaulted = true;
                    }
                    TypeDeclaration rc = cts.get(1).getDeclaration();
                    if (lc instanceof Interface &&
                            rc.equals(u.getEmptyDeclaration())) {
                        args = cts.get(0);
                        defaulted = true;
                    }
                }
            }
            if (args.getDeclaration() instanceof ClassOrInterface) {
                if (args.getDeclaration().equals(u.getTupleDeclaration())) {
                    List<ProducedType> tal = args.getTypeArgumentList();
                    if (tal.size()>=3) {
                        ProducedType first = tal.get(1);
                        ProducedType rest = tal.get(2);
                        if (first!=null && rest!=null) {
                            String argtype = getProducedTypeName(first, unit);
                            if (rest.getDeclaration() instanceof Interface &&
                                    rest.getDeclaration().equals(u.getEmptyDeclaration())) {
                                return defaulted ? argtype + "=" : argtype;
                            }
                            String argtypes = getTupleElementTypeNames(rest, unit);
                            if (argtypes!=null) {
                                return defaulted ?
                                        argtype + "=, " + argtypes :
                                            argtype + ", " + argtypes;
                            }
                        }
                    }
                }
                else if (args.getDeclaration().equals(u.getEmptyDeclaration())) {
                    return defaulted ? "=" : "";
                }
                else if (!defaulted &&
                        args.getDeclaration().equals(u.getSequentialDeclaration())) {
                    ProducedType elementType = u.getIteratedType(args);
                    if (elementType!=null) {
                        String etn = getProducedTypeName(elementType, unit);
                        if (isPrimitiveAbbreviatedType(elementType)) {
                            return etn + "*";
                        }
                        else {
                            return lt() + etn + gt() + "*";
                        }
                    }
                }
                else if (!defaulted &&
                        args.getDeclaration().equals(u.getSequenceDeclaration())) {
                    ProducedType elementType = u.getIteratedType(args);
                    if (elementType!=null) {
                        String etn = getProducedTypeName(elementType, unit);
                        if (isPrimitiveAbbreviatedType(elementType)) {
                            return etn + "+";
                        }
View Full Code Here

                boolean isControl;
                do {
                    Declaration member =
                            s.getDirectMember(model.getName(), null, false);
                    if (member!=null) {
                        Unit unit = model.getUnit();
                        if (member instanceof Method &&
                            model instanceof Method &&
                            s instanceof ClassOrInterface) {
                            Method abstraction;
                            if (!((Method) member).isAbstraction()) {
                                abstraction = new Method();
                                abstraction.setAbstraction(true);
                                abstraction.setType(new UnknownType(unit).getType());
                                abstraction.setName(model.getName());
                                abstraction.setShared(true);
                                abstraction.setActual(true);
                                abstraction.setContainer(s);
                                abstraction.setScope(s);
                                abstraction.setUnit(unit);
                                ((Method) member).setOverloaded(true);
                                abstraction.setOverloads(new ArrayList<Declaration>());
                                abstraction.getOverloads().add(member);
                                s.getMembers().add(abstraction);
                            }
                            else {
                                abstraction = (Method) member;
                            }
                            ((Method) model).setOverloaded(true);
                            abstraction.getOverloads().add(model);
                        }
                        else {
                            that.addError("duplicate declaration name: '" +
                                    model.getName() + "'");
                        }
                        unit.getDuplicateDeclarations().add(member);
                    }
                    isControl = s instanceof ControlBlock;
                    s = s.getContainer();
                }
                while (isControl);
View Full Code Here

            } else if (abbreviateTuple(pt) && !link.contains("'Go to ceylon.language::Tuple'")) {
                containsTuple = true;
            }
        }
       
        Unit unit = producedType.getDeclaration().getUnit();
       
        if( containsOptional || containsSequential || containsSequence || containsIterable || containsEntry || containsCallable || containsTuple ) {
            StringBuilder sb = new StringBuilder();
            sb.append("<span class='link-dropdown'>");
            sb.append(link.replaceAll("class='link'", "class='link type-identifier'"));
            sb.append("<span class='dropdown'>");
            sb.append("<a class='dropdown-toggle' data-toggle='dropdown' href='#'><b title='Show more links' class='caret'></b></a>");
            sb.append("<ul class='dropdown-menu'>");   
            if( containsOptional ) {
                sb.append(getLinkMenuItem(unit.getNullDeclaration(), "abbreviations X? means Null|X"));
            }
            if( containsSequential ) {
                sb.append(getLinkMenuItem(unit.getSequentialDeclaration(), "abbreviation X[] or [X*] means Sequential&lt;X&gt;"));
            }
            if( containsSequence ) {
                sb.append(getLinkMenuItem(unit.getSequenceDeclaration(), "abbreviation [X+] means Sequence&lt;X&gt;"));
            }
            if( containsIterable ) {
                sb.append(getLinkMenuItem(unit.getIterableDeclaration(), "abbreviation {X+} or {X*} means Iterable&lt;X,Nothing&gt; or Iterable&lt;X,Null&gt;"));
            }
            if( containsEntry ) {
                sb.append(getLinkMenuItem(unit.getEntryDeclaration(), "abbreviation X-&gt;Y means Entry&lt;X,Y&gt;"));
            }
            if( containsCallable ) {
                sb.append(getLinkMenuItem(unit.getCallableDeclaration(), "abbreviation X(Y,Z) means Callable&lt;X,[Y,Z]&gt;"));
            }
            if( containsTuple ) {
                sb.append(getLinkMenuItem(unit.getTupleDeclaration(), "abbreviation [X,Y] means Tuple&lt;X|Y,X,Tuple&lt;Y,Y,[]&gt;&gt;"));
            }
            sb.append("</ul>"); // dropdown-menu
            sb.append("</span>"); // dropdown
            sb.append("</span>"); // link-dropdown
           
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.