From b3e69a5f5db26cff6cb0042631b57027f82b6195 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Wed, 4 Nov 2015 15:44:54 +0300 Subject: [PATCH] Created common supertype for HierarchicalScope and MemberScope-- ResolutionScope --- .../jetbrains/kotlin/resolve/scopes/Scopes.kt | 17 +------- .../kotlin/resolve/scopes/MemberScope.kt | 23 +++-------- .../kotlin/resolve/scopes/ResolutionScope.kt | 39 +++++++++++++++++++ 3 files changed, 45 insertions(+), 34 deletions(-) create mode 100644 core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt index 69866994d27..0a9bba2a4ef 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt @@ -24,24 +24,9 @@ import org.jetbrains.kotlin.utils.Printer // see utils/ScopeUtils.kt -interface HierarchicalScope { +interface HierarchicalScope : ResolutionScope { val parent: HierarchicalScope? - /** - * All visible descriptors from current scope possibly filtered by the given name and kind filters - * (that means that the implementation is not obliged to use the filters but may do so when it gives any performance advantage). - */ - fun getContributedDescriptors( - kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL, - nameFilter: (Name) -> Boolean = MemberScope.ALL_NAME_FILTER - ): Collection - - fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? - - fun getContributedVariables(name: Name, location: LookupLocation): Collection - - fun getContributedFunctions(name: Name, location: LookupLocation): Collection - fun printStructure(p: Printer) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt index 5142e75344c..0e22e256d7f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/MemberScope.kt @@ -23,27 +23,14 @@ import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.toReadOnlyList import java.lang.reflect.Modifier -public interface MemberScope { - - public fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? - - @Deprecated("Should be removed soon") - public fun getPackage(name: Name): PackageViewDescriptor? - - public fun getContributedVariables(name: Name, location: LookupLocation): Collection - - public fun getContributedFunctions(name: Name, location: LookupLocation): Collection +public interface MemberScope : ResolutionScope { val ownerDescriptor: DeclarationDescriptor - /** - * All visible descriptors from current scope possibly filtered by the given name and kind filters - * (that means that the implementation is not obliged to use the filters but may do so when it gives any performance advantage). - */ - public fun getContributedDescriptors( - kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL, - nameFilter: (Name) -> Boolean = ALL_NAME_FILTER - ): Collection + public override fun getContributedVariables(name: Name, location: LookupLocation): Collection + + @Deprecated("Should be removed soon") + public fun getPackage(name: Name): PackageViewDescriptor? /** * Is supposed to be used in tests and debug only diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt new file mode 100644 index 00000000000..d371f4e7d54 --- /dev/null +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ResolutionScope.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.scopes + +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.incremental.components.LookupLocation +import org.jetbrains.kotlin.name.Name + +public interface ResolutionScope { + + public fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? + + public fun getContributedVariables(name: Name, location: LookupLocation): Collection + + public fun getContributedFunctions(name: Name, location: LookupLocation): Collection + + /** + * All visible descriptors from current scope possibly filtered by the given name and kind filters + * (that means that the implementation is not obliged to use the filters but may do so when it gives any performance advantage). + */ + public fun getContributedDescriptors( + kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL, + nameFilter: (Name) -> Boolean = MemberScope.ALL_NAME_FILTER + ): Collection +}