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 ClassDescriptor getObjectDescriptor(@NotNull Name name);
058
059 @NotNull
060 @ReadOnly
061 Collection<ClassDescriptor> getObjectDescriptors();
062
063 @Nullable
064 NamespaceDescriptor getNamespace(@NotNull Name name);
065
066 @NotNull
067 @ReadOnly
068 Collection<VariableDescriptor> getProperties(@NotNull Name name);
069
070 @Nullable
071 VariableDescriptor getLocalVariable(@NotNull Name name);
072
073 @NotNull
074 @ReadOnly
075 Collection<FunctionDescriptor> getFunctions(@NotNull Name name);
076
077 @NotNull
078 DeclarationDescriptor getContainingDeclaration();
079
080 @NotNull
081 @ReadOnly
082 Collection<DeclarationDescriptor> getDeclarationsByLabel(@NotNull LabelName labelName);
083
084 /**
085 * All visible descriptors from current scope.
086 *
087 * @return All visible descriptors from current scope.
088 */
089 @NotNull
090 @ReadOnly
091 Collection<DeclarationDescriptor> getAllDescriptors();
092
093 /**
094 * Adds receivers to the list in order of locality, so that the closest (the most local) receiver goes first
095 */
096 @NotNull
097 @ReadOnly
098 List<ReceiverParameterDescriptor> getImplicitReceiversHierarchy();
099
100 @NotNull
101 @ReadOnly
102 Collection<DeclarationDescriptor> getOwnDeclaredDescriptors();
103
104 @TestOnly
105 void printScopeStructure(@NotNull Printer p);
106 }