Before searching for descriptor of method, check if it can be property
This commit is contained in:
+5
-1
@@ -40,6 +40,10 @@ import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.*
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
fun canBePropertyAccessor(identifier: String): Boolean {
|
||||
return identifier.startsWith("get") || identifier.startsWith("is") || identifier.startsWith("set")
|
||||
}
|
||||
|
||||
interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
|
||||
val getMethod: FunctionDescriptor
|
||||
val setMethod: FunctionDescriptor?
|
||||
@@ -49,7 +53,7 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
|
||||
val name = getterOrSetter.name
|
||||
if (name.isSpecial) return null
|
||||
val identifier = name.identifier
|
||||
if (!identifier.startsWith("get") && !identifier.startsWith("is") && !identifier.startsWith("set")) return null // optimization
|
||||
if (!canBePropertyAccessor(identifier)) return null // optimization
|
||||
|
||||
val classDescriptorOwner = getterOrSetter.containingDeclaration as? ClassDescriptor ?: return null
|
||||
|
||||
|
||||
+2
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.synthetic.JavaSyntheticPropertiesScope
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.synthetic.canBePropertyAccessor
|
||||
|
||||
class KotlinPropertyAccessorsReferenceSearcher : QueryExecutorBase<PsiReference, MethodReferencesSearch.SearchParameters>(true) {
|
||||
override fun processQuery(queryParameters: MethodReferencesSearch.SearchParameters, consumer: Processor<PsiReference>) {
|
||||
@@ -54,6 +55,7 @@ class KotlinPropertyAccessorsReferenceSearcher : QueryExecutorBase<PsiReference,
|
||||
return unwrapped.getName()
|
||||
}
|
||||
|
||||
if (!canBePropertyAccessor(method.name)) return null
|
||||
val functionDescriptor = method.getJavaMethodDescriptor() ?: return null
|
||||
val syntheticExtensionsScope = JavaSyntheticPropertiesScope(LockBasedStorageManager(), LookupTracker.DO_NOTHING)
|
||||
val property = SyntheticJavaPropertyDescriptor.findByGetterOrSetter(functionDescriptor, syntheticExtensionsScope) ?: return null
|
||||
|
||||
Reference in New Issue
Block a user