Minor optimization of lookup tracker records
This commit is contained in:
+1
-1
@@ -77,7 +77,7 @@ class CompilerCallbackServicesFacadeServer(
|
||||
}
|
||||
}
|
||||
|
||||
private val lookupTracker_isDoNothing: Boolean = incrementalCompilationComponents != null && incrementalCompilationComponents.getLookupTracker() == LookupTracker.DO_NOTHING
|
||||
private val lookupTracker_isDoNothing: Boolean = incrementalCompilationComponents?.getLookupTracker() === LookupTracker.DO_NOTHING
|
||||
|
||||
override fun lookupTracker_isDoNothing(): Boolean = lookupTracker_isDoNothing
|
||||
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
private fun syntheticPropertyInClassNotCached(ownerClass: ClassDescriptor, name: Name): SyntheticPropertyHolder {
|
||||
|
||||
fun result(descriptor: PropertyDescriptor?, getterNames: List<Name>, setterName: Name? = null): SyntheticPropertyHolder {
|
||||
if (lookupTracker == LookupTracker.DO_NOTHING) {
|
||||
if (lookupTracker === LookupTracker.DO_NOTHING) {
|
||||
return if (descriptor == null) SyntheticPropertyHolder.EMPTY else SyntheticPropertyHolder(descriptor, emptyList())
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -17,9 +17,11 @@
|
||||
package org.jetbrains.kotlin.resolve.lazy.descriptors
|
||||
|
||||
import com.google.common.collect.Sets
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.record
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
@@ -166,6 +168,8 @@ protected constructor(
|
||||
return result.toReadOnlyList()
|
||||
}
|
||||
|
||||
abstract fun recordLookup(name: Name, from: LookupLocation)
|
||||
|
||||
// Do not change this, override in concrete subclasses:
|
||||
// it is very easy to compromise laziness of this class, and fail all the debugging
|
||||
// a generic implementation can't do this properly
|
||||
@@ -180,8 +184,4 @@ protected constructor(
|
||||
p.popIndent()
|
||||
p.println("}")
|
||||
}
|
||||
|
||||
private fun recordLookup(name: Name, from: LookupLocation) {
|
||||
c.lookupTracker.record(from, thisDescriptor, name)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.incremental.record
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
@@ -38,7 +39,6 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.ClassMemberDeclarationProv
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.resolve.VarianceCheckerCore
|
||||
import org.jetbrains.kotlin.storage.NotNullLazyValue
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue
|
||||
import org.jetbrains.kotlin.types.DeferredType
|
||||
@@ -316,6 +316,10 @@ open class LazyClassMemberScope(
|
||||
descriptor.returnType = DeferredType.create(c.storageManager, trace, { thisDescriptor.getDefaultType() })
|
||||
}
|
||||
|
||||
override fun recordLookup(name: Name, from: LookupLocation) {
|
||||
c.lookupTracker.record(from, thisDescriptor, name)
|
||||
}
|
||||
|
||||
// Do not add details here, they may compromise the laziness during debugging
|
||||
override fun toString() = "lazy scope for class ${thisDescriptor.name}"
|
||||
|
||||
|
||||
+10
-1
@@ -16,8 +16,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.lazy.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.incremental.record
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
@@ -45,6 +50,10 @@ class LazyPackageMemberScope(
|
||||
// No extra properties
|
||||
}
|
||||
|
||||
override fun recordLookup(name: Name, from: LookupLocation) {
|
||||
c.lookupTracker.record(from, thisDescriptor, name)
|
||||
}
|
||||
|
||||
// Do not add details here, they may compromise the laziness during debugging
|
||||
override fun toString() = "lazy scope for package " + thisDescriptor.name
|
||||
}
|
||||
|
||||
+5
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.incremental.record
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
@@ -109,4 +110,8 @@ class LazyScriptClassMemberScope(
|
||||
propertyDescriptor.initialize(null, null)
|
||||
return propertyDescriptor
|
||||
}
|
||||
|
||||
override fun recordLookup(name: Name, from: LookupLocation) {
|
||||
c.lookupTracker.record(from, thisDescriptor, name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
/*
|
||||
* Copyright 2010-2016 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.util
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.incremental.KotlinLookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.incremental.getScopeKind
|
||||
import org.jetbrains.kotlin.incremental.record
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
@@ -17,8 +34,13 @@ fun LookupTracker.record(expression: KtExpression, type: KotlinType) {
|
||||
|
||||
// Scope descriptor is function descriptor only when type is local
|
||||
// Lookups for local types are not needed since all usages are compiled with the type
|
||||
if (getScopeKind(scopeDescriptor) != null && !DescriptorUtils.isLocal(typeDescriptor)) {
|
||||
record(KotlinLookupLocation(expression), scopeDescriptor, typeDescriptor.name)
|
||||
when {
|
||||
scopeDescriptor is PackageFragmentDescriptor && !DescriptorUtils.isLocal(typeDescriptor) -> {
|
||||
record(KotlinLookupLocation(expression), scopeDescriptor, typeDescriptor.name)
|
||||
}
|
||||
scopeDescriptor is ClassDescriptor && !DescriptorUtils.isLocal(typeDescriptor) -> {
|
||||
record(KotlinLookupLocation(expression), scopeDescriptor, typeDescriptor.name)
|
||||
}
|
||||
}
|
||||
|
||||
for (typeArgument in type.arguments) {
|
||||
@@ -27,4 +49,3 @@ fun LookupTracker.record(expression: KtExpression, type: KotlinType) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user