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

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


        super.visit(that);
        inheritDefaultedArguments(that.getDeclarationModel());
    }

    private void inheritDefaultedArguments(Declaration d) {
        Declaration rd = d.getRefinedDeclaration();
        if (rd!=d && rd!=null) {
            List<ParameterList> tdpls = ((Functional) d).getParameterLists();
            List<ParameterList> rdpls = ((Functional) rd).getParameterLists();
            if (!tdpls.isEmpty() && !rdpls.isEmpty()) {
                List<Parameter> tdps = tdpls.get(0).getParameters();
View Full Code Here


        }
    }

    @Override public void visit(Tree.Declaration that) {
        super.visit(that);
        Declaration dec = that.getDeclarationModel();
        if (dec!=null) {
            boolean toplevel =
                dec.getContainer() instanceof Package;
            boolean member =
                dec.isClassOrInterfaceMember() &&
                    dec.isShared() &&
                    !(dec instanceof TypeParameter); //TODO: what about nested interfaces and abstract classes?!
           
            if (!toplevel && !member && dec.isShared()) {
                that.addError("shared declaration is not a member of a class, interface, or package", 1200);
            }
           
            boolean mayBeShared =
                    dec instanceof MethodOrValue ||
                    dec instanceof ClassOrInterface ||
                    dec instanceof TypeAlias;
            if (!mayBeShared && dec.isShared()) {
                that.addError("shared declaration is not a function, value, class, interface, or alias", 1200);
            }
           
            boolean mayBeRefined =
                    dec instanceof Value ||
                    dec instanceof Method ||
                    dec instanceof Class;
            if (!mayBeRefined) {
                checkNonrefinableDeclaration(that, dec);
            }
           
            if (!member) {
                checkNonMember(that, dec, mayBeShared);
            }
           
            /*if (!dec.isShared()) {
                checkUnshared(that, dec);
            }*/
           
            if (member) {
                checkMember(that, dec);
            }
            else if (isOverloadedVersion(dec)) {
                that.addError("name is not unique in scope: " + dec.getName());
            }
           
        }
       
    }
View Full Code Here

*/
public class Util {
   
    static TypedDeclaration getTypedMember(TypeDeclaration d, String name,
            List<ProducedType> signature, boolean ellipsis, Unit unit) {
        Declaration member = d.getMember(name, unit, signature, ellipsis);
        if (member instanceof TypedDeclaration)
            return (TypedDeclaration) member;
        else
            return null;
    }
View Full Code Here

            return null;
    }

    static TypeDeclaration getTypeMember(TypeDeclaration d, String name,
            List<ProducedType> signature, boolean ellipsis, Unit unit) {
        Declaration member = d.getMember(name, unit, signature, ellipsis);
        if (member instanceof TypeDeclaration)
            return (TypeDeclaration) member;
        else
            return null;
    }
View Full Code Here

    }

    static TypedDeclaration getTypedDeclaration(Scope scope,
            String name, List<ProducedType> signature, boolean ellipsis,
            Unit unit) {
        Declaration result = scope.getMemberOrParameter(unit,
                name, signature, ellipsis);
        if (result instanceof TypedDeclaration) {
          return (TypedDeclaration) result;
        }
        else {
View Full Code Here

    }
   
    static TypeDeclaration getTypeDeclaration(Scope scope,
            String name, List<ProducedType> signature, boolean ellipsis,
            Unit unit) {
        Declaration result = scope.getMemberOrParameter(unit,
                name, signature, ellipsis);
        if (result instanceof TypeDeclaration) {
          return (TypeDeclaration) result;
        }
        else {
View Full Code Here

        else if (!unit.isCallableType(type)) {
            if (!hasError(node)) {
                String extra = message(type,
                        " is not a subtype of 'Callable'", unit);
                if (node instanceof Tree.StaticMemberOrTypeExpression) {
                    Declaration d =
                            ((Tree.StaticMemberOrTypeExpression) node).getDeclaration();
                    if (d instanceof Interface) {
                        extra = ": '" + d.getName() + "' is an interface";
                    }
                    else if (d instanceof TypeAlias) {
                        extra = ": '" + d.getName() + "' is a type alias";
                    }
                    else if (d instanceof TypeParameter) {
                        extra = ": '" + d.getName() + "' is a type parameter";
                    }
                    else if (d instanceof Value) {
                        extra = ": value '" + d.getName() + "' has type '" +
                                type.getProducedTypeName(unit) +
                                "' which is not a subtype of 'Callable'";
                    }
                }
                node.addError(message + extra);
View Full Code Here

                .startsWith(Module.LANGUAGE_MODULE_NAME);
    }

    static String typeDescription(TypeDeclaration td, Unit unit) {
        if (td instanceof TypeParameter) {
            Declaration container = (Declaration) td.getContainer();
            return "type parameter '" + td.getName() + "' of '" +
                    container.getName(unit) + "'";
        }
        else {
            return "type '" + td.getName() + "'";
        }
    }
View Full Code Here

                if (ex!=null) {
                    Tree.Term t = ex.getTerm();
                    //TODO: eliminate parens
                    //TODO: take into account conjunctions/disjunctions
                    if (t instanceof Tree.BaseMemberExpression) {
                        Declaration d = ((Tree.BaseMemberExpression) t).getDeclaration();
                        if (isBooleanTrue(d)) {
                            continue;
                        }
                    }
                }
View Full Code Here

                if (ex!=null) {
                    Tree.Term t = ex.getTerm();
                    //TODO: eliminate parens
                    //TODO: take into account conjunctions/disjunctions
                    if (t instanceof Tree.BaseMemberExpression) {
                        Declaration d = ((Tree.BaseMemberExpression) t).getDeclaration();
                        if (isBooleanFalse(d)) {
                            return true;
                        }
                    }
                }
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.