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.LabelName;
025    import org.jetbrains.jet.lang.resolve.name.Name;
026    import org.jetbrains.jet.utils.Printer;
027    
028    import java.util.Collection;
029    import java.util.List;
030    
031    public interface JetScope {
032        JetScope EMPTY = new JetScopeImpl() {
033            @NotNull
034            @Override
035            public DeclarationDescriptor getContainingDeclaration() {
036                throw new UnsupportedOperationException("Don't take containing declaration of the EMPTY scope");
037            }
038    
039            @Override
040            public String toString() {
041                return "EMPTY";
042            }
043    
044            @Override
045            public void printScopeStructure(@NotNull Printer p) {
046                p.println("EMPTY");
047            }
048        };
049    
050        /**
051         * Should not return object (class object or enum entry) class descriptors.
052         */
053        @Nullable
054        ClassifierDescriptor getClassifier(@NotNull Name name);
055    
056        @Nullable
057        NamespaceDescriptor getNamespace(@NotNull Name name);
058    
059        @NotNull
060        @ReadOnly
061        Collection<VariableDescriptor> getProperties(@NotNull Name name);
062    
063        @Nullable
064        VariableDescriptor getLocalVariable(@NotNull Name name);
065    
066        @NotNull
067        @ReadOnly
068        Collection<FunctionDescriptor> getFunctions(@NotNull Name name);
069    
070        @NotNull
071        DeclarationDescriptor getContainingDeclaration();
072    
073        @NotNull
074        @ReadOnly
075        Collection<DeclarationDescriptor> getDeclarationsByLabel(@NotNull LabelName labelName);
076    
077        /**
078         * All visible descriptors from current scope.
079         *
080         * @return All visible descriptors from current scope.
081         */
082        @NotNull
083        @ReadOnly
084        Collection<DeclarationDescriptor> getAllDescriptors();
085    
086        /**
087         * Adds receivers to the list in order of locality, so that the closest (the most local) receiver goes first
088         */
089        @NotNull
090        @ReadOnly
091        List<ReceiverParameterDescriptor> getImplicitReceiversHierarchy();
092    
093        @NotNull
094        @ReadOnly
095        Collection<DeclarationDescriptor> getOwnDeclaredDescriptors();
096    
097        @TestOnly
098        void printScopeStructure(@NotNull Printer p);
099    }