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