EMMA Coverage Report (generated Thu Dec 06 15:52:10 GMT 2007)
[all classes][com.sun.tools.javac.api]

COVERAGE SUMMARY FOR SOURCE FILE [JavacScope.java]

nameclass, %method, %block, %line, %
JavacScope.java0%   (0/2)0%   (0/14)0%   (0/140)0%   (0/21)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class JavacScope0%   (0/1)0%   (0/10)0%   (0/123)0%   (0/18)
JavacScope (Env): void 0%   (0/1)0%   (0/9)0%   (0/4)
equals (Object): boolean 0%   (0/1)0%   (0/23)0%   (0/4)
getEnclosingClass (): TypeElement 0%   (0/1)0%   (0/17)0%   (0/1)
getEnclosingMethod (): ExecutableElement 0%   (0/1)0%   (0/11)0%   (0/1)
getEnclosingScope (): JavacScope 0%   (0/1)0%   (0/24)0%   (0/3)
getEnv (): Env 0%   (0/1)0%   (0/3)0%   (0/1)
getLocalElements (): Iterable 0%   (0/1)0%   (0/6)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/11)0%   (0/1)
isStarImportScope (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/17)0%   (0/1)
     
class JavacScope$10%   (0/1)0%   (0/4)0%   (0/17)0%   (0/4)
JavacScope$1 (JavacScope, Env): void 0%   (0/1)0%   (0/7)0%   (0/1)
getEnclosingScope (): JavacScope 0%   (0/1)0%   (0/2)0%   (0/1)
getLocalElements (): Iterable 0%   (0/1)0%   (0/6)0%   (0/1)
isStarImportScope (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)

1/*
2 * Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25 
26package com.sun.tools.javac.api;
27 
28import java.io.IOException;
29import java.lang.ref.SoftReference;
30import java.util.Iterator;
31 
32import javax.lang.model.element.Element;
33import javax.lang.model.element.ExecutableElement;
34import javax.lang.model.element.TypeElement;
35import javax.tools.JavaFileObject;
36 
37import com.sun.source.tree.Tree;
38import com.sun.source.util.SourcePositions;
39import com.sun.source.util.TreePath;
40import com.sun.source.util.Trees;
41import com.sun.tools.javac.code.Scope;
42import com.sun.tools.javac.code.Symbol.ClassSymbol;
43import com.sun.tools.javac.comp.Attr;
44import com.sun.tools.javac.comp.AttrContext;
45import com.sun.tools.javac.comp.Enter;
46import com.sun.tools.javac.comp.Env;
47import com.sun.tools.javac.comp.MemberEnter;
48import com.sun.tools.javac.comp.Resolve;
49import com.sun.tools.javac.tree.JCTree.JCClassDecl;
50import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
51import com.sun.tools.javac.tree.JCTree.JCExpression;
52import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
53import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
54import com.sun.tools.javac.tree.JCTree;
55import com.sun.tools.javac.tree.TreeCopier;
56import com.sun.tools.javac.tree.TreeInfo;
57import com.sun.tools.javac.tree.TreeMaker;
58import com.sun.tools.javac.util.Context;
59import com.sun.tools.javac.util.List;
60import com.sun.tools.javac.util.Log;
61 
62import static com.sun.source.tree.Tree.Kind.*;
63 
64 
65/**
66 * Provides an implementation of Scope.
67 *
68 * <p><b>This is NOT part of any API supported by Sun Microsystems.
69 * If you write code that depends on this, you do so at your own
70 * risk.  This code and its internal interfaces are subject to change
71 * or deletion without notice.</b></p>
72 *
73 * @author Jonathan Gibbons;
74 */
75public class JavacScope implements com.sun.source.tree.Scope {
76    protected final Env<AttrContext> env;
77 
78    /** Creates a new instance of JavacScope */
79    JavacScope(Env<AttrContext> env) {
80        env.getClass(); // null-check
81        this.env = env;
82    }
83 
84    public JavacScope getEnclosingScope() {
85        if (env.outer != null && env.outer != env)
86            return  new JavacScope(env.outer);
87        else {
88            // synthesize an outermost "star-import" scope
89            return new JavacScope(env) {
90                public boolean isStarImportScope() {
91                    return true;
92                }
93                public JavacScope getEnclosingScope() {
94                    return null;
95                }
96                public Iterable<? extends Element> getLocalElements() {
97                    return env.toplevel.starImportScope.getElements();
98                }
99            };
100        }
101    }
102 
103    public TypeElement getEnclosingClass() {
104        // hide the dummy class that javac uses to enclose the top level declarations
105        return (env.outer == null || env.outer == env ? null : env.enclClass.sym);
106    }
107 
108    public ExecutableElement getEnclosingMethod() {
109        return (env.enclMethod == null ? null : env.enclMethod.sym);
110    }
111 
112    public Iterable<? extends Element> getLocalElements() {
113        return env.info.getLocalElements();
114    }
115 
116    public Env<AttrContext> getEnv() {
117        return env;
118    }
119 
120    public boolean isStarImportScope() {
121        return false;
122    }
123 
124    public boolean equals(Object other) {
125        if (other instanceof JavacScope) {
126            JavacScope s = (JavacScope) other;
127            return (env.equals(s.env)
128                && isStarImportScope() == s.isStarImportScope());
129        } else
130            return false;
131    }
132 
133    public int hashCode() {
134        return env.hashCode() + (isStarImportScope() ? 1 : 0);
135    }
136 
137    public String toString() {
138        return "JavacScope[env=" + env + ",starImport=" + isStarImportScope() + "]";
139    }
140}

[all classes][com.sun.tools.javac.api]
EMMA 2.0.5312 (C) Vladimir Roubtsov