From 6baf3ae737687fa371926257313fccb5de1186a9 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 1 Jul 2016 18:57:34 +0300 Subject: [PATCH] Minor, inline LexicalScope.Companion.empty --- .../org/jetbrains/kotlin/resolve/lazy/FileScopeFactory.kt | 2 +- .../kotlin/resolve/lazy/descriptors/LazyAnnotations.kt | 7 ++++--- .../src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt | 4 ---- compiler/tests/org/jetbrains/kotlin/types/typeTestUtils.kt | 2 +- .../src/org/jetbrains/kotlin/idea/kdoc/resolveKDocLink.kt | 4 ++-- .../quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt | 4 ++-- .../kotlin/idea/refactoring/CallableRefactoring.kt | 5 ++--- 7 files changed, 12 insertions(+), 16 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeFactory.kt index 9ed12ba3205..676a5fb2b77 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeFactory.kt @@ -113,7 +113,7 @@ class FileScopeFactory( val importingScope = LazyImportScope(scope, explicitImportResolver, LazyImportScope.FilteringKind.ALL, "Explicit imports in $debugName") - val lexicalScope = LexicalScope.empty(importingScope, packageFragment) + val lexicalScope = LexicalScope.Empty(importingScope, packageFragment) val importResolver = object : ImportResolver { override fun forceResolveAllImports() { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt index 5360a39533c..fb797c6ecc4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt @@ -60,7 +60,7 @@ class LazyAnnotations( entry: KtAnnotationEntry -> val descriptor = LazyAnnotationDescriptor(c, entry) - val target = entry.getUseSiteTarget()?.getAnnotationUseSiteTarget() + val target = entry.useSiteTarget?.getAnnotationUseSiteTarget() AnnotationWithTarget(descriptor, target) } @@ -132,8 +132,9 @@ class LazyAnnotationDescriptor( private val source = annotationEntry.toSourceElement() val scope = if (c.scope.ownerDescriptor is PackageFragmentDescriptor) { - LexicalScope.Companion.empty(c.scope, FileDescriptorForVisibilityChecks(source, c.scope.ownerDescriptor)) - } else { + LexicalScope.Empty(c.scope, FileDescriptorForVisibilityChecks(source, c.scope.ownerDescriptor)) + } + else { c.scope } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt index 606693d9d9f..7f969e119f9 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/Scopes.kt @@ -59,10 +59,6 @@ interface LexicalScope: HierarchicalScope { p.println("Empty lexical scope with owner = $ownerDescriptor and parent = $parent") } } - - companion object { - fun empty(parent: HierarchicalScope, ownerDescriptor: DeclarationDescriptor): LexicalScope = Empty(parent, ownerDescriptor) - } } enum class LexicalScopeKind(val withLocalDescriptors: Boolean) { diff --git a/compiler/tests/org/jetbrains/kotlin/types/typeTestUtils.kt b/compiler/tests/org/jetbrains/kotlin/types/typeTestUtils.kt index 4d33bd35ec1..aa9e922a755 100644 --- a/compiler/tests/org/jetbrains/kotlin/types/typeTestUtils.kt +++ b/compiler/tests/org/jetbrains/kotlin/types/typeTestUtils.kt @@ -21,4 +21,4 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope fun KotlinBuiltIns.builtInPackageAsLexicalScope() - = LexicalScope.empty(builtInsPackageScope.memberScopeAsImportingScope(), builtInsModule) \ No newline at end of file + = LexicalScope.Empty(builtInsPackageScope.memberScopeAsImportingScope(), builtInsModule) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/kdoc/resolveKDocLink.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/kdoc/resolveKDocLink.kt index 348b99f7f82..4f4d8b513bf 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/kdoc/resolveKDocLink.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/kdoc/resolveKDocLink.kt @@ -128,10 +128,10 @@ private fun getClassInnerScope(outerScope: LexicalScope, descriptor: ClassDescri fun getKDocLinkResolutionScope(resolutionFacade: ResolutionFacade, descriptor: DeclarationDescriptor): LexicalScope { return when (descriptor) { is PackageFragmentDescriptor -> - LexicalScope.empty(getPackageInnerScope(descriptor).memberScopeAsImportingScope(), descriptor) + LexicalScope.Empty(getPackageInnerScope(descriptor).memberScopeAsImportingScope(), descriptor) is PackageViewDescriptor -> - LexicalScope.empty(descriptor.memberScope.memberScopeAsImportingScope(), descriptor) + LexicalScope.Empty(descriptor.memberScope.memberScopeAsImportingScope(), descriptor) is ClassDescriptor -> getClassInnerScope(getOuterScope(descriptor, resolutionFacade), descriptor) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt index dd546ec85eb..9eacb11d5d8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/replaceWith/ReplaceWithAnnotationAnalyzer.kt @@ -257,7 +257,7 @@ object ReplaceWithAnnotationAnalyzer { } is PackageViewDescriptor -> - LexicalScope.empty(chainImportingScopes(listOf(descriptor.memberScope.memberScopeAsImportingScope()) + additionalScopes)!!, ownerDescriptor) + LexicalScope.Empty(chainImportingScopes(listOf(descriptor.memberScope.memberScopeAsImportingScope()) + additionalScopes)!!, ownerDescriptor) is ClassDescriptor -> { val outerScope = getResolutionScope(descriptor.containingDeclaration, ownerDescriptor, additionalScopes) ?: return null @@ -278,4 +278,4 @@ object ReplaceWithAnnotationAnalyzer { else -> return null // something local, should not work with ReplaceWith } } -} \ No newline at end of file +} diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt index 39ba65d5c81..910a69611d0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt @@ -33,7 +33,6 @@ import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde -import org.jetbrains.kotlin.idea.refactoring.canRefactor import org.jetbrains.kotlin.idea.util.getResolutionScope import org.jetbrains.kotlin.psi.KtBlockExpression import org.jetbrains.kotlin.psi.KtDeclarationWithBody @@ -194,7 +193,7 @@ fun DeclarationDescriptor.getContainingScope(): LexicalScope? { val containingDescriptor = containingDeclaration ?: return null return when (containingDescriptor) { is ClassDescriptorWithResolutionScopes -> containingDescriptor.scopeForInitializerResolution - is PackageFragmentDescriptor -> LexicalScope.empty(containingDescriptor.getMemberScope().memberScopeAsImportingScope(), this) + is PackageFragmentDescriptor -> LexicalScope.Empty(containingDescriptor.getMemberScope().memberScopeAsImportingScope(), this) else -> null } } @@ -203,4 +202,4 @@ fun DeclarationDescriptor.getContainingScope(): LexicalScope? { fun KtDeclarationWithBody.getBodyScope(bindingContext: BindingContext): LexicalScope? { val expression = bodyExpression?.children?.firstOrNull { it is KtExpression } ?: return null return expression.getResolutionScope(bindingContext, getResolutionFacade()) -} \ No newline at end of file +}