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

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


            else if (term instanceof Tree.InvocationExpression) {
                checkAnnotationInstantiation(a, e, pt);
            }
            else if (term instanceof Tree.BaseMemberExpression) {
                Tree.BaseMemberExpression bme = (Tree.BaseMemberExpression) term;
                Declaration d = bme.getDeclaration();
                if (a!=null && d!=null && d.isParameter()) {
                    Parameter p = ((MethodOrValue) d).getInitializerParameter();
                    if (!p.getDeclaration().equals(a)) {
                        e.addError("illegal annotation argument: must be a reference to a parameter of the annotation");
                    }
                }
                else if (d instanceof Value &&
                        (((Value) d).isEnumValue() || ((Value) d).getTypeDeclaration().isAnonymous())) {
                    //ok
                }
                else {
                    e.addError("illegal annotation argument: must be a literal value, metamodel reference, annotation instantiation, or parameter reference");
                }
            }
            else if (term instanceof Tree.QualifiedMemberExpression) {
                Tree.QualifiedMemberExpression qme = (Tree.QualifiedMemberExpression) term;
                Declaration d = qme.getDeclaration();
                if (d!=null && !d.isStaticallyImportable()) {
                    e.addError("illegal annotation argument: must be a literal value, metamodel reference, annotation instantiation, or parameter reference");
                   
                }
                else {
                    Tree.Primary p = qme.getPrimary();
View Full Code Here


            packageName = scopeIndex < 0 ? null : text.substring(0, scopeIndex);
        }
               
        String path = scopeIndex < 0 ? text : text.substring(scopeIndex + 2);
        String[] names = path.isEmpty() ? new String[0] : path.split("\\.");
        Declaration base = null;
        if (packageName==null) {
            if (names.length > 0) {
                base = that.getScope().getMemberOrParameter(that.getUnit(),
                    names[0], null, false);
            }
        }
        else {
            Package pack = that.getUnit().getPackage().getModule().getPackage(packageName);
            if (pack == null) {
                if (DOC_LINK_MODULE.equals(kind)) {
                    that.addUsageWarning(Warning.doclink,
                                "module does not exist: '" + packageName + "'");
                } else {
                    that.addUsageWarning(Warning.doclink,
                                "package does not exist: '" + packageName + "'");
                }
            }
            else {
                that.setPkg(pack);
                if (DOC_LINK_MODULE.equals(kind)) {
                    Package rootPack = pack.getModule().getRootPackage();
                    if (pack.equals(rootPack)) {
                        that.setModule(pack.getModule());
                    } else {
                        that.addUsageWarning(Warning.doclink,
                                    "module does not exist: '" + packageName + "'");
                    }
                }
                if (names.length > 0) {
                    base = pack.getDirectMember(names[0], null, false);
                }
            }
           
            if (DOC_LINK_MODULE.equals(kind) || DOC_LINK_PACKAGE.equals(kind)) {
                return;
            }
        }
        if (base==null) {
            that.addUsageWarning(Warning.doclink,
                    "declaration does not exist: '" +
                    (names.length > 0 ? names[0] : text) + "'");
        }
        else {
            that.setBase(base);
            if (names.length>1) {
                that.setQualified(new ArrayList<Declaration>(names.length-1));
            }
            for (int i=1; i<names.length; i++) {
                if (base instanceof Value) {
                    Value value = (Value) base;
                    if (!value.isParameter()
                            && !value.isTransient()
                            && value.getTypeDeclaration() != null
                            && value.getTypeDeclaration().isAnonymous()) {
                        base = value.getTypeDeclaration();
                    }
                }
                if (base instanceof TypeDeclaration || base instanceof Functional) {
                    Declaration qualified = base.getMember(names[i], null, false);
                    if (qualified==null) {
                        that.addUsageWarning(Warning.doclink,
                                    "member declaration or parameter does not exist: '" + names[i] + "'");
                        break;
                    }
View Full Code Here

    }

    @Override
    public void visit(Tree.Annotation that) {
        super.visit(that);
        Declaration dec = ((Tree.MemberOrTypeExpression) that.getPrimary()).getDeclaration();
        /*if (dec!=null && !dec.isToplevel()) {
            that.getPrimary().addError("annotation must be a toplevel function reference");
        }*/
        if (dec!=null) {
            if (!dec.isAnnotation()) {
                that.getPrimary().addError("not an annotation constructor");
            }
            else {
                checkAnnotationArguments(null, (Tree.InvocationExpression) that);
            }
View Full Code Here

    //      references are only resolved when we get to the
    //      containing InvocationExpression, and I did not want
    //      to add a whole new Visitor just for overloading errors
    @Override public void visit(Tree.MemberOrTypeExpression that) {
        super.visit(that);
        Declaration dec = that.getDeclaration();
        if (!that.getStaticMethodReferencePrimary() &&
                isAbstraction(dec)) {
            if (that.getStaticMethodReference() && !dec.isStaticallyImportable()) {
                that.addError("ambiguous static reference to overloaded method or class: '" +
                        dec.getName(that.getUnit()) + "' is overloaded");
            }
            else {
                List<ProducedType> sig = that.getSignature();
                if (sig==null) {
                    that.addError("ambiguous callable reference to overloaded method or class: '" +
                            dec.getName(that.getUnit()) + "' is overloaded");
                }
                else {
                    StringBuilder sb = new StringBuilder();
                    sb.append(" '");
                    for (ProducedType pt: sig) {
                        if (pt!=null) {
                            sb.append(pt.getProducedTypeName(that.getUnit()));
                        }
                        sb.append(", ");
                    }
                    if (!sig.isEmpty()) {
                        sb.setLength(sb.length()-2);
                    }
                    sb.append("'");
                    that.addError("ambiguous invocation of overloaded method or class: " +
                            "there must be exactly one overloaded declaration of '" +
                            dec.getName(that.getUnit()) +
                            "' that accepts the given argument types" + sb);
                }
            }
        }
    }
View Full Code Here

        }
        if (!dec.isFormal() && type.isDynamic()) {
            that.addError("non-formal member belongs to dynamic interface");
        }
        List<ProducedType> signature = getSignature(dec);
        Declaration root =
                type.getRefinedMember(dec.getName(), signature, false);
        boolean legallyOverloaded = !isOverloadedVersion(dec);
        if (root == null || root.equals(dec)) {
            dec.setRefinedDeclaration(dec);
            if (dec.isActual()) {
                that.addError("actual member does not refine any inherited member: " +
                        dec.getName(), 1300);
            }
            else if (!legallyOverloaded) {
                if (dec.isActual()) {
                    that.addError("overloaded member does not refine an inherited overloaded member: " +
                            dec.getName());
                }
                else {
                    that.addError("duplicate or overloaded member name: " + dec.getName());
                }
            }
        }
        else {
            dec.setRefinedDeclaration(root);
            if (root.isPackageVisibility() &&
                    !declaredInPackage(root, that.getUnit())) {
                that.addError("refined declaration is not visible: " +
                        message(root));
            }
            boolean found = false;
            TypeDeclaration rootType = (TypeDeclaration) root.getContainer();
            for (Declaration refined:
                    getInterveningRefinements(dec.getName(),
                            signature, root, type, rootType)) {
                if (isOverloadedVersion(refined)) {
                    //if this member is overloaded, the
View Full Code Here

          typeArgs = emptyList();
        }
       
        ProducedReference refinedMember = ci.getType().getTypedReference(refined, typeArgs);
        ProducedReference refiningMember = ci.getType().getTypedReference(dec, typeArgs);
        Declaration refinedMemberDec = refinedMember.getDeclaration();
    Declaration refiningMemberDec = refiningMember.getDeclaration();
    Node typeNode = getTypeErrorNode(that);
    if (refinedMemberIsDynamicallyTyped(refinedMemberDec, refiningMemberDec)) {
          checkRefiningMemberDynamicallyTyped(refined, refiningMemberDec, typeNode);
        }
    else if (refiningMemberIsDynamicallyTyped(refinedMemberDec, refiningMemberDec)) {
View Full Code Here

            }
            me = pe.getPrimary();
        }
        if (me instanceof Tree.BaseMemberExpression) {
            Tree.BaseMemberExpression bme = (Tree.BaseMemberExpression) me;
            Declaration d = getTypedDeclaration(bme.getScope(),
                    name(bme.getIdentifier()), sig, false, that.getUnit());
            if (d instanceof TypedDeclaration) {
                that.setDeclaration((TypedDeclaration) d);
                Scope cs = getRealScope(that.getScope().getContainer());
                if (cs instanceof ClassOrInterface &&
                        d.isClassOrInterfaceMember() &&
                        !d.getContainer().equals(cs) &&
                        ((ClassOrInterface) cs).inherits((ClassOrInterface) d.getContainer())) {
                    // interpret this specification as a
                    // refinement of an inherited member
                    if (d.getContainer()==that.getScope()) {
                        that.addError("parameter declaration hides refining member: '" +
                                d.getName() + "' (rename parameter)");
                    }
                    else if (d instanceof Value) {
                        refineValue((Value) d, bme, that, (ClassOrInterface) cs);
                    }
                    else if (d instanceof Method) {
                        refineMethod((Method) d, bme, that, (ClassOrInterface) cs);
                    }
                    else {
                        //TODO!
                        bme.addError("not a reference to a formal attribute: '" +
                                d.getName(that.getUnit()) + "'");
                    }
                }
            }
        }
    }
View Full Code Here

public class DeprecationVisitor extends Visitor {
   
    @Override
    public void visit(Tree.MemberOrTypeExpression that) {
        super.visit(that);
        Declaration d = that.getDeclaration();
    if (d!=null && d.isDeprecated()) {
        that.addUsageWarning(Warning.deprecation,
                    "declaration is deprecated: '" +
                        d.getName() + "'");
        }
    }
View Full Code Here

        }
    }
    @Override
    public void visit(Tree.ImportMemberOrType that) {
        super.visit(that);
        Declaration d = that.getDeclarationModel();
    if (d!=null && d.isDeprecated()) {
        that.addUsageWarning(Warning.deprecation,
                    "imported declaration is deprecated: '" +
                            d.getName() + "'");
        }
    }
View Full Code Here

        unit = that.getUnit();
        super.visit(that);
    }
       
    private Declaration beginReturnDeclaration(Declaration d) {
        Declaration od = returnDeclaration;
        returnDeclaration = d;
        return od;
    }
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.