From 32bfd53101b8f68dbb6d16e25f8e59a0507f2a09 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 12 Jun 2015 15:10:08 +0300 Subject: [PATCH] Renames --- .../resolve/scopes/WritableScopeImpl.kt | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/WritableScopeImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/WritableScopeImpl.kt index 2d35d82f218..1550feb62b9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/WritableScopeImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/WritableScopeImpl.kt @@ -35,19 +35,17 @@ import org.jetbrains.kotlin.util.collectionUtils.concatInOrder public class WritableScopeImpl @jvmOverloads constructor( outerScope: JetScope, private val ownerDeclarationDescriptor: DeclarationDescriptor, - protected val redeclarationHandler: RedeclarationHandler, + private val redeclarationHandler: RedeclarationHandler, private val debugName: String, private val labeledDeclaration: DeclarationDescriptor? = null ) : AbstractScopeAdapter(), WritableScope { - private val explicitlyAddedDescriptors = SmartList() + private val addedDescriptors = SmartList() - private var functionGroups: MutableMap? = null - - private var variableOrClassDescriptors: MutableMap? = null + private var functionsByName: MutableMap? = null + private var variablesAndClassifiersByName: MutableMap? = null private var implicitReceiver: ReceiverParameterDescriptor? = null - private var implicitReceiverHierarchy: List? = null override fun getContainingDeclaration(): DeclarationDescriptor = ownerDeclarationDescriptor @@ -80,8 +78,8 @@ public class WritableScopeImpl @jvmOverloads constructor( override fun takeSnapshot(): JetScope { checkMayRead() - if (lastSnapshot == null || lastSnapshot!!.descriptorLimit != explicitlyAddedDescriptors.size()) { - lastSnapshot = Snapshot(explicitlyAddedDescriptors.size()) + if (lastSnapshot == null || lastSnapshot!!.descriptorLimit != addedDescriptors.size()) { + lastSnapshot = Snapshot(addedDescriptors.size()) } return lastSnapshot!! } @@ -92,7 +90,7 @@ public class WritableScopeImpl @jvmOverloads constructor( changeLockLevel(WritableScope.LockLevel.READING) val result = ArrayList() - result.addAll(explicitlyAddedDescriptors) + result.addAll(addedDescriptors) result.addAll(workerScope.getDescriptors(kindFilter, nameFilter)) return result } @@ -119,11 +117,11 @@ public class WritableScopeImpl @jvmOverloads constructor( val descriptorIndex = addDescriptor(descriptor) - if (variableOrClassDescriptors == null) { - variableOrClassDescriptors = HashMap() + if (variablesAndClassifiersByName == null) { + variablesAndClassifiersByName = HashMap() } //TODO: could not use += because of KT-8050 - variableOrClassDescriptors!![name] = variableOrClassDescriptors!![name] + descriptorIndex + variablesAndClassifiersByName!![name] = variablesAndClassifiersByName!![name] + descriptorIndex } @@ -147,12 +145,12 @@ public class WritableScopeImpl @jvmOverloads constructor( val descriptorIndex = addDescriptor(functionDescriptor) - if (functionGroups == null) { - functionGroups = HashMap(1) + if (functionsByName == null) { + functionsByName = HashMap(1) } val name = functionDescriptor.getName() //TODO: could not use += because of KT-8050 - functionGroups!![name] = functionGroups!![name] + descriptorIndex + functionsByName!![name] = functionsByName!![name] + descriptorIndex } override fun getFunctions(name: Name): Collection { @@ -197,12 +195,12 @@ public class WritableScopeImpl @jvmOverloads constructor( super.getImplicitReceiversHierarchy() } - override fun getOwnDeclaredDescriptors(): Collection = explicitlyAddedDescriptors + override fun getOwnDeclaredDescriptors(): Collection = addedDescriptors - private fun variableOrClassDescriptorByName(name: Name, descriptorLimit: Int = explicitlyAddedDescriptors.size()): DeclarationDescriptor? { + private fun variableOrClassDescriptorByName(name: Name, descriptorLimit: Int = addedDescriptors.size()): DeclarationDescriptor? { if (descriptorLimit == 0) return null - var list = variableOrClassDescriptors?.get(name) + var list = variablesAndClassifiersByName?.get(name) while (list != null) { val descriptorIndex = list.head if (descriptorIndex < descriptorLimit) { @@ -213,10 +211,10 @@ public class WritableScopeImpl @jvmOverloads constructor( return null } - private fun functionsByName(name: Name, descriptorLimit: Int = explicitlyAddedDescriptors.size()): List? { + private fun functionsByName(name: Name, descriptorLimit: Int = addedDescriptors.size()): List? { if (descriptorLimit == 0) return null - var list = functionGroups?.get(name) + var list = functionsByName?.get(name) while (list != null) { if (list.head < descriptorLimit) { return list.toDescriptors() @@ -227,11 +225,11 @@ public class WritableScopeImpl @jvmOverloads constructor( } private fun addDescriptor(descriptor: DeclarationDescriptor): Int { - explicitlyAddedDescriptors.add(descriptor) - return explicitlyAddedDescriptors.size() - 1 + addedDescriptors.add(descriptor) + return addedDescriptors.size() - 1 } - private fun Int.descriptorByIndex() = explicitlyAddedDescriptors[this] + private fun Int.descriptorByIndex() = addedDescriptors[this] override fun toString(): String { return javaClass.getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(this)) + " " + debugName + " for " + getContainingDeclaration() @@ -276,7 +274,7 @@ public class WritableScopeImpl @jvmOverloads constructor( val result = ArrayList(workerResult.size() + descriptorLimit) for (i in 0..descriptorLimit-1) { - result.add(explicitlyAddedDescriptors[i]) + result.add(addedDescriptors[i]) } result.addAll(workerResult) return result @@ -306,7 +304,7 @@ public class WritableScopeImpl @jvmOverloads constructor( ?: workerScope.getClassifier(name) } - override fun getOwnDeclaredDescriptors(): Collection = explicitlyAddedDescriptors.truncated(descriptorLimit) + override fun getOwnDeclaredDescriptors(): Collection = addedDescriptors.truncated(descriptorLimit) private fun List.truncated(newSize: Int) = if (newSize == size()) this else subList(0, newSize)