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

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


            final String modAlias = imported ? gen.getNames().moduleAlias(t.getUnit().getPackage().getModule()) : null;
            if (modAlias != null && !modAlias.isEmpty()) {
                gen.out(modAlias, ".");
            }
            if (t.getContainer() instanceof ClassOrInterface) {
                final Scope scope = node == null ? null : Util.getContainingClassOrInterface(node.getScope());
                List<ClassOrInterface> parents = new ArrayList<>();
                ClassOrInterface parent = (ClassOrInterface)t.getContainer();
                parents.add(0, parent);
                while (parent.getContainer() instanceof ClassOrInterface) {
                    parent = (ClassOrInterface)parent.getContainer();
View Full Code Here


                    final Map<TypeParameter,ProducedType> targs;
                    if (pt.getDeclaration().isToplevel()) {
                        targs = pt.getTypeArguments();
                    } else {
                        //Gather all type parameters from containers
                        Scope scope = node.getScope();
                        final HashSet<TypeParameter> parenttp = new HashSet<>();
                        while (scope != null) {
                            if (scope instanceof Generic) {
                                for (TypeParameter tp : ((Generic)scope).getTypeParameters()) {
                                    parenttp.add(tp);
                                }
                            }
                            scope = scope.getScope();
                        }
                        targs = new HashMap<>();
                        targs.putAll(pt.getTypeArguments());
                        Declaration cd = Util.getContainingDeclaration(pt.getDeclaration());
                        while (cd != null) {
View Full Code Here

    }

    /** Finds the owner of the type parameter and outputs a reference to the corresponding type argument. */
    static void resolveTypeParameter(final Node node, final TypeParameter tp,
            final GenerateJsVisitor gen, final boolean skipSelfDecl) {
        Scope parent = node.getScope();
        int outers = 0;
        while (parent != null && parent != tp.getContainer()) {
            if (parent instanceof TypeDeclaration && !((TypeDeclaration) parent).isAnonymous()) {
                outers++;
            }
            parent = parent.getScope();
        }
        if (tp.getContainer() instanceof ClassOrInterface) {
            if (parent == tp.getContainer()) {
                if (!skipSelfDecl) {
                    ClassOrInterface ontoy = Util.getContainingClassOrInterface(node.getScope());
View Full Code Here

    }

    /** Returns the qualified name of a declaration, skipping any containing methods. */
    public static String qualifiedNameSkippingMethods(Declaration d) {
        final StringBuilder p = new StringBuilder(d.getName());
        Scope s = d.getContainer();
        while (s != null) {
            if (s instanceof com.redhat.ceylon.compiler.typechecker.model.Package) {
                final String pkname = ((com.redhat.ceylon.compiler.typechecker.model.Package)s).getNameAsString();
                if (!pkname.isEmpty()) {
                    p.insert(0, "::");
                    p.insert(0, pkname);
                }
            } else if (s instanceof TypeDeclaration) {
                p.insert(0, '.');
                p.insert(0, ((TypeDeclaration)s).getName());
            }
            s = s.getContainer();
        }
        return p.toString();
    }
View Full Code Here

        if (decl instanceof TypeDeclaration && (forSelf || !decl.isAnonymous())) {
            // The generated suffix consists of the names of the enclosing types.
            StringBuilder sb = new StringBuilder();
            // Use the original declaration if it's an overriden class: an overriding
            // member must have the same name as the member it overrides.
            Scope scope = originalDeclaration(decl).getContainer();
            while (scope instanceof TypeDeclaration) {
                sb.append('$');
                sb.append(((TypeDeclaration) scope).getName());
                scope = scope.getContainer();
            }
            suffix = sb.toString();
        }
        return suffix;
    }
View Full Code Here

    private void checkExtensionOfMemberType(Node that, TypeDeclaration td,
            ProducedType type) {
        ProducedType qt = type.getQualifyingType();
        if (qt!=null && td instanceof ClassOrInterface &&
            !type.getDeclaration().isStaticallyImportable()) {
            Scope s = td;
            while (s!=null) {
                s = s.getContainer();
                if (s instanceof TypeDeclaration) {
                  TypeDeclaration otd = (TypeDeclaration) s;
                    if (otd.getType().isSubtypeOf(qt)) {
                        return;
                    }
View Full Code Here

            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
View Full Code Here

    private void printDeclaration(StringBuilder ptn,
            Declaration declaration, boolean fullyQualified,
            Unit unit) {
        // type parameters are not fully qualified
        if (fullyQualified && !(declaration instanceof TypeParameter)) {
            Scope container = declaration.getContainer();
            while(container != null
                    && container instanceof Package == false
                    && container instanceof Declaration == false){
                container = container.getContainer();
            }
            if(container != null){
                if(container instanceof Package){
                    String q = container.getQualifiedNameString();
                    if(!q.isEmpty())
                        ptn.append(q).append("::");
                }else{
                    printDeclaration(ptn, (Declaration) container,
                            fullyQualified, unit);
View Full Code Here

    public Unit getCompilationUnit() {
        return unit;
    }
   
    private Scope enterScope(Scope innerScope) {
        Scope outerScope = scope;
        scope = innerScope;
        return outerScope;
    }
View Full Code Here

                checkForDuplicateDeclaration(that, model);
            }
        }
        //that.setDeclarationModel(model);
        unit.addDeclaration(model);
        Scope sc = getContainer(that);
        sc.addMember(model);
       
        handleDeclarationAnnotations(that, model);       
       
        setVisibleScope(model);
       
View Full Code Here

TOP

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

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.