Coverage Report - com.sun.tools.javafx.api.JavafxcScope
 
Classes in this File Line Coverage Branch Coverage Complexity
JavafxcScope
0%
0/19
0%
0/18
0
JavafxcScope$1
0%
0/4
N/A
0
 
 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  
 
 26  
 package com.sun.tools.javafx.api;
 27  
 
 28  
 import javax.lang.model.element.Element;
 29  
 import javax.lang.model.element.ExecutableElement;
 30  
 import javax.lang.model.element.TypeElement;
 31  
 
 32  
 import com.sun.tools.javac.comp.AttrContext;
 33  
 import com.sun.tools.javac.comp.Env;
 34  
 
 35  
 /**
 36  
  * Provides an implementation of Scope.
 37  
  *
 38  
  * <p><b>This is NOT part of any API supported by Sun Microsystems.
 39  
  * If you write code that depends on this, you do so at your own
 40  
  * risk.  This code and its internal interfaces are subject to change
 41  
  * or deletion without notice.</b></p>
 42  
  *
 43  
  * @author Jonathan Gibbons;
 44  
  */
 45  0
 public class JavafxcScope implements com.sun.source.tree.Scope {
 46  
     protected final Env<AttrContext> env;
 47  
 
 48  
     /** Creates a new instance of JavacScope */
 49  0
     JavafxcScope(Env<AttrContext> env) {
 50  0
         env.getClass(); // null-check
 51  0
         this.env = env;
 52  0
     }
 53  
 
 54  
     public JavafxcScope getEnclosingScope() {
 55  0
         if (env.outer != null && env.outer != env)
 56  0
             return  new JavafxcScope(env.outer);
 57  
         else {
 58  
             // synthesize an outermost "star-import" scope
 59  0
             return new JavafxcScope(env) {
 60  
                 @Override
 61  
                 public boolean isStarImportScope() {
 62  0
                     return true;
 63  
                 }
 64  
                 @Override
 65  
                 public JavafxcScope getEnclosingScope() {
 66  0
                     return null;
 67  
                 }
 68  
                 @Override
 69  
                 public Iterable<? extends Element> getLocalElements() {
 70  0
                     return env.toplevel.starImportScope.getElements();
 71  
                 }
 72  
             };
 73  
         }
 74  
     }
 75  
 
 76  
     public TypeElement getEnclosingClass() {
 77  
         // hide the dummy class that javac uses to enclose the top level declarations
 78  0
         return (env.outer == null || env.outer == env ? null : env.enclClass.sym);
 79  
     }
 80  
 
 81  
     public ExecutableElement getEnclosingMethod() {
 82  0
         return (env.enclMethod == null ? null : env.enclMethod.sym);
 83  
     }
 84  
 
 85  
     public Iterable<? extends Element> getLocalElements() {
 86  0
         return env.info.getLocalElements();
 87  
     }
 88  
 
 89  
     public Env<AttrContext> getEnv() {
 90  0
         return env;
 91  
     }
 92  
 
 93  
     public boolean isStarImportScope() {
 94  0
         return false;
 95  
     }
 96  
 
 97  
     @Override
 98  
     public boolean equals(Object other) {
 99  0
         if (other instanceof JavafxcScope) {
 100  0
             JavafxcScope s = (JavafxcScope) other;
 101  0
             return (env.equals(s.env)
 102  
                 && isStarImportScope() == s.isStarImportScope());
 103  
         } else
 104  0
             return false;
 105  
     }
 106  
 
 107  
     @Override
 108  
     public int hashCode() {
 109  0
         return env.hashCode() + (isStarImportScope() ? 1 : 0);
 110  
     }
 111  
 
 112  
     @Override
 113  
     public String toString() {
 114  0
         return "JavafxcScope[env=" + env + ",starImport=" + isStarImportScope() + "]";
 115  
     }
 116  
 }