001 /*
002 * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package com.sun.source.tree;
027
028 import com.sun.source.tree.Tree;
029 import javax.lang.model.element.Element;
030 import javax.lang.model.element.ExecutableElement;
031 import javax.lang.model.element.TypeElement;
032 import javax.lang.model.type.DeclaredType;
033
034 /**
035 * Interface for determining locally available program elements, such as
036 * local variables and imports.
037 * Upon creation, a Scope is associated with a given program position;
038 * for example, a {@linkplain Tree tree node}. This position may be used to
039 * infer an enclosing method and/or class.
040 *
041 * <p>A Scope does not itself contain the details of the elements corresponding
042 * to the parameters, methods and fields of the methods and classes containing
043 * its position. However, these elements can be determined from the enclosing
044 * elements.
045 *
046 * <p>Scopes may be contained in an enclosing scope. The outermost scope contains
047 * those elements available via "star import" declarations; the scope within that
048 * contains the top level elements of the compilation unit, including any named
049 * imports.
050 *
051 * @since 1.6
052 */
053 public interface Scope {
054 /**
055 * Returns the enclosing scope.
056 */
057 public Scope getEnclosingScope();
058
059 /**
060 * Returns the innermost type element containing the position of this scope
061 */
062 public TypeElement getEnclosingClass();
063
064 /**
065 * Returns the innermost executable element containing the position of this scope.
066 */
067 public ExecutableElement getEnclosingMethod();
068
069 /**
070 * Returns the elements directly contained in this scope.
071 */
072 public Iterable<? extends Element> getLocalElements();
073 }