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

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


        protected Substitution getSubstitution(Cond cond) {
            Substitution subs = super.getSubstitution(cond);
            if (subs == null) {
                return subs;
            }
            Scope scope = cond.getVariable().getScope().getScope();
            while (scope instanceof ConditionScope) {
                scope = scope.getScope();
            }
            subs.scopeClose(scope);
            // make sure we get a variable name now, and that it doesn't change over time, because
            // we will need this variable name in transformCommonResultDecl(), which declares it,
            // and it runs after we process inner conditions, and if we are an assert, inner conditions
View Full Code Here


            }
            return false;
        }
        if(declaration instanceof TypeParameter){
            // only look at it if it is defined outside our scope
            Scope typeParameterScope = declaration.getContainer();
            while(scope != null){
                if (Decl.equalScopes(scope,  typeParameterScope))
                    return false;
                scope = scope.getContainer();
            }
View Full Code Here

        TypeDeclaration paramTypeDecl = nonWideningType.getDeclaration();
        if (paramTypeDecl instanceof TypeParameter
                && Decl.equalScopeDecl(paramTypeDecl.getContainer(), method)) {
            return false;
        }
        Scope scope = paramTypeDecl.getContainer();
        while (scope != null && !(scope instanceof Package)) {
            if (Decl.equalScopeDecl(scope, method)) {
                return true;
            }
            scope = scope.getContainer();
        }
        return false;
    }
View Full Code Here

                    || decl instanceof Class
                    || gen().isSequencedAnnotation((Class)decl))) {
            throw new BugException(decl.getName());
        }
        java.util.List<Scope> l = new java.util.ArrayList<Scope>();
        Scope s = decl;
        do {
            l.add(s);
            s = s.getContainer();
        } while (!(s instanceof Package));
        Collections.reverse(l);
       
        if (flags.contains(DeclNameFlag.QUALIFIED)) {
            final List<String> packageName;
            if(!AbstractTransformer.isJavaArray(decl))
                packageName = ((Package) s).getName();
            else
                packageName = COM_REDHAT_CEYLON_LANGUAGE_PACKAGE;
            if (packageName.isEmpty() || !packageName.get(0).isEmpty()) {
                declarationBuilder.select("");
            }
            for (int ii = 0; ii < packageName.size(); ii++) {
                declarationBuilder.select(quoteIfJavaKeyword(packageName.get(ii)));
            }
        }
        for (int ii = 0; ii < l.size(); ii++) {
            Scope scope = l.get(ii);
            final boolean last = ii == l.size() - 1;
            appendTypeDeclaration(decl, flags, declarationBuilder, scope, last);
        }
        return declarationBuilder.result();
    }
View Full Code Here

            if (flags.contains(DeclNameFlag.COMPANION)
                || !(decl instanceof Interface)) {
                typeDeclarationBuilder.clear();
            } else if (flags.contains(DeclNameFlag.QUALIFIED)
                    || (decl instanceof Interface)) {
                Scope nonLocal = scope;
                while (!(nonLocal instanceof Declaration)) {
                    nonLocal = nonLocal.getContainer();
                }
                typeDeclarationBuilder.append(((Declaration)nonLocal).getPrefixedName());
                if (!Decl.equalScopes(scope, nonLocal)) {
                    typeDeclarationBuilder.append('$');
                    typeDeclarationBuilder.append(getLocalId(scope));
View Full Code Here

            if ((namingOptions & NA_WRAPPER) == 0
                    && (namingOptions & NA_WRAPPER_UNQUOTED) == 0) {
                throw new BugException("If you pass FQ you must pass WRAPPER or WRAPPER_UNQUOTED too, or there's no class name to qualify!");
            }
            List<String> outerNames = null;
            Scope s = decl.getContainer();
            while (s != null) {
                if (s instanceof Package) {
                    final List<String> packageName = ((Package) s).getName();
                    for (int ii = 0; ii < packageName.size(); ii++) {
                        if (ii == 0 && packageName.get(ii).isEmpty()) {
                            continue;
                        }
                        builder.select(quoteIfJavaKeyword(packageName.get(ii)));
                    }
                    break;
                } else if (s instanceof ClassOrInterface) {
                    if (outerNames == null) {
                        outerNames = new ArrayList<String>(2);
                    }
                    outerNames.add(getQuotedClassName((ClassOrInterface) s, 0));
                } else if (s instanceof TypedDeclaration) {
                    if (outerNames == null) {
                        outerNames = new ArrayList<String>(2);
                    }
                    outerNames.add(quoteIfJavaKeyword(((TypedDeclaration) s).getName()));
                }
                s = s.getContainer();
            }
            if (outerNames != null) {
                for (int ii = outerNames.size()-1; ii >= 0; ii--) {
                    String outerName = outerNames.get(ii);
                    builder.select(outerName);
View Full Code Here

                s.internalClose();
            }
        }
       
        for (Map.Entry<Scope, com.sun.tools.javac.util.List<Substitution>> entry : scopedSubstitutions.entrySet()) {
            Scope s = entry.getKey();
            while (true) {
                if (s.equals(scope)) {
                    throw new RuntimeException("Unclosed scoped substitution(s) " + entry.getValue() + " whose scope is contained within " + scope);
                }
                s = s.getScope();
                if (s == null || s instanceof Package) {
                    break;
                }
            }
        }
View Full Code Here

        String name;
        if(tp.isCaptured()){
            // must build unique name
            StringBuilder sb = new StringBuilder();
            LinkedList<Declaration> decls = new LinkedList<Declaration>();
            Scope scope = tp;
            while(scope != null && scope instanceof Package == false){
                if(scope instanceof Declaration)
                    decls.add((Declaration) scope);
                scope = scope.getContainer();
            }
            Iterator<Declaration> iterator = decls.descendingIterator();
            while(iterator.hasNext()){
                sb.append(iterator.next().getName());
                if(iterator.hasNext())
View Full Code Here

            private final Scope scope;
            SubstitutionKey(TypedDeclaration decl) {
                super();
                this.name = decl.getName();
                TypedDeclaration orig = decl.getOriginalDeclaration();
                Scope stop = (orig != null ? orig : decl).getContainer();
                Scope scope = decl.getContainer();
                while (!Decl.equalScopes(scope, stop)) {
                    if (!(scope instanceof ControlBlock)) {
                        break;
                    }
                    scope = scope.getContainer();
                }
                this.scope = scope;
            }
View Full Code Here

    }
   
    protected ProducedType getParameterTypeForValueType(ProducedReference producedReference, Parameter param) {
        // we need to find the interface for this method
        ProducedType paramType = param.getModel().getReference().getFullType().getType();
        Scope paramContainer = param.getModel().getContainer();
        if(paramContainer instanceof TypedDeclaration){
            TypedDeclaration method = (TypedDeclaration) paramContainer;
            if(method.getContainer() instanceof TypeDeclaration){
                TypeDeclaration container = (TypeDeclaration) method.getContainer();
                ProducedType qualifyingType = producedReference.getQualifyingType();
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.