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