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

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


    }
   
    @Override
    public void visit(Tree.MethodDefinition that) {
        super.visit(that);
        Method dec = that.getDeclarationModel();
        if (dec!=null && dec.isParameter() &&
                dec.getInitializerParameter().isHidden()) {
            that.getBlock().addError("function is an initializer parameter and may not have a body: '" +
                    dec.getName() + "'");
        }
    }
View Full Code Here


                    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() + "'");
                        }
View Full Code Here

        }
    }
   
    @Override
    public void visit(Tree.AnyMethod that) {
        Method m = new Method();
        that.setDeclarationModel(m);
        visitDeclaration(that, m);
        Scope o = enterScope(m);
        super.visit(that);
        exitScope(o);
        setParameterLists(m, that.getParameterLists(), that);
        Tree.Type type = that.getType();
        m.setDeclaredVoid(type instanceof Tree.VoidModifier);
        if (type instanceof Tree.ValueModifier) {
            type.addError("functions may not be declared using the keyword value");
        }
        if (type instanceof Tree.DynamicModifier) {
            m.setDynamicallyTyped(true);
        }
    }
View Full Code Here

        }
    }

    @Override
    public void visit(Tree.MethodArgument that) {
        Method m = new Method();
        that.setDeclarationModel(m);
        visitArgument(that, m);
        Scope o = enterScope(m);
        super.visit(that);
        exitScope(o);
        setParameterLists(m, that.getParameterLists(), that);
        m.setDeclaredVoid(that.getType() instanceof Tree.VoidModifier);
    }
View Full Code Here

   
    private int fid=0;

    @Override
    public void visit(Tree.FunctionArgument that) {
        Method m = new Method();
        m.setName("anonymous#"+fid++);
        m.setAnonymous(true);
        that.setDeclarationModel(m);
        visitArgument(that, m);
        Scope o = enterScope(m);
        Declaration d = beginDeclaration(that.getDeclarationModel());
        super.visit(that);
        endDeclaration(d);
        exitScope(o);
        setParameterLists(m, that.getParameterLists(), that);
        m.setDeclaredVoid(that.getType() instanceof Tree.VoidModifier);
    }
View Full Code Here

        super.visit(that);
        Tree.SpecifierExpression sie = that.getSpecifierExpression();
        if ( that.getDeclarationModel().isFormal() && sie!=null ) {
            that.addError("formal methods may not have a specification", 1307);
        }
        Method m = that.getDeclarationModel();
        Tree.Type type = that.getType();
        if (type instanceof Tree.FunctionModifier) {
            if (m.isToplevel()) {
                if (sie==null) {
                    type.addError("toplevel function must explicitly specify a return type");
                }
                else {
                    type.addError("toplevel function must explicitly specify a return type", 200);
                }
            }
            else if (m.isShared()) {
                type.addError("shared function must explicitly specify a return type", 200);
            }
        }
    }
View Full Code Here

    }
           
    @Override
    public void visit(Tree.MethodDefinition that) {
        super.visit(that);
        Method m = that.getDeclarationModel();
        if (that.getType() instanceof Tree.FunctionModifier) {
            if (m.isToplevel()) {
                that.getType().addError("toplevel function must explicitly specify a return type", 200);
            }
            else if (m.isShared() && !dynamic) {
                that.getType().addError("shared function must explicitly specify a return type", 200);
            }
        }
    }
View Full Code Here

        p.setDefaulted(getSpecifier(that)!=null);
        Tree.Type type = that.getTypedDeclaration().getType();
        p.setDeclaredAnything(type instanceof Tree.VoidModifier);
        that.setParameterModel(p);
        super.visit(that);
        Method m = (Method) that.getTypedDeclaration().getDeclarationModel();
        p.setModel(m);
        p.setName(m.getName());
        m.setInitializerParameter(p);
        parameterList.getParameters().add(p);
        if (type instanceof Tree.SequencedType) {
            type.addError("functional parameter type may not be variadic");
        }
        if (m.isFormal()) {
            that.addError("parameters may not be annotated formal", 1312);
        }
    }
View Full Code Here

    private String getUrl(Object to, Declaration anchor) {
        String url;
       
        List<Method> methods = new ArrayList<Method>();
        while(to instanceof Method){
            Method method = (Method) to;
            methods.add(method);
            to = method.getContainer();
        }
       
        if (isInCurrentModule(to)) {
            url = getLocalUrl(to);
        } else {
            url = getExternalUrl(to);
        }       
           
        if (url != null && anchor != null) {
            String sectionPackageAnchor = "#section-package";
            if (url.endsWith(sectionPackageAnchor)) {
                url = url.substring(0, url.length() - sectionPackageAnchor.length());
            }
            StringBuilder fragment = new StringBuilder();
            if(!methods.isEmpty()) {
                Collections.reverse(methods);
                for(Method method : methods) {
                    fragment.append(method.getName());
                    fragment.append("-");
                }
            }
            fragment.append(anchor.getName());
            url = url + "#" + fragment;
View Full Code Here

                    classes.add(c);
                }
            } else if (m instanceof Value) {
                attributes.add((MethodOrValue) m);
            } else if (m instanceof Method) {
                Method method = (Method) m;
                if( m.isAnnotation() ) {
                    annotationConstructors.add(method);
                } else {
                    methods.add(method);
                }
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.