001    /*
002     * Copyright 2010-2013 JetBrains s.r.o.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.jetbrains.jet.lang.resolve.scopes;
018    
019    import org.jetbrains.annotations.NotNull;
020    import org.jetbrains.annotations.Nullable;
021    import org.jetbrains.annotations.ReadOnly;
022    import org.jetbrains.annotations.TestOnly;
023    import org.jetbrains.jet.lang.descriptors.*;
024    import org.jetbrains.jet.lang.resolve.name.Name;
025    import org.jetbrains.jet.utils.Printer;
026    
027    import java.util.Collection;
028    import java.util.List;
029    
030    public interface JetScope {
031        JetScope EMPTY = new JetScopeImpl() {
032            @NotNull
033            @Override
034            public DeclarationDescriptor getContainingDeclaration() {
035                throw new UnsupportedOperationException("Don't take containing declaration of the EMPTY scope");
036            }
037    
038            @Override
039            public String toString() {
040                return "EMPTY";
041            }
042    
043            @Override
044            public void printScopeStructure(@NotNull Printer p) {
045                p.println("EMPTY");
046            }
047        };
048    
049        /**
050         * Should not return object (class object or enum entry) class descriptors.
051         */
052        @Nullable
053        ClassifierDescriptor getClassifier(@NotNull Name name);
054    
055        @Nullable
056        PackageViewDescriptor getPackage(@NotNull Name name);
057    
058        @NotNull
059        @ReadOnly
060        Collection<VariableDescriptor> getProperties(@NotNull Name name);
061    
062        @Nullable
063        VariableDescriptor getLocalVariable(@NotNull Name name);
064    
065        @NotNull
066        @ReadOnly
067        Collection<FunctionDescriptor> getFunctions(@NotNull Name name);
068    
069        @NotNull
070        DeclarationDescriptor getContainingDeclaration();
071    
072        @NotNull
073        @ReadOnly
074        Collection<DeclarationDescriptor> getDeclarationsByLabel(@NotNull Name labelName);
075    
076        /**
077         * All visible descriptors from current scope.
078         *
079         * @return All visible descriptors from current scope.
080         */
081        @NotNull
082        @ReadOnly
083        Collection<DeclarationDescriptor> getAllDescriptors();
084    
085        /**
086         * Adds receivers to the list in order of locality, so that the closest (the most local) receiver goes first
087         */
088        @NotNull
089        @ReadOnly
090        List<ReceiverParameterDescriptor> getImplicitReceiversHierarchy();
091    
092        @NotNull
093        @ReadOnly
094        Collection<DeclarationDescriptor> getOwnDeclaredDescriptors();
095    
096        @TestOnly
097        void printScopeStructure(@NotNull Printer p);
098    }