KT-6820 Find usages doesn't find delegated properties when searching get/set/propertyDelegated functions

#KT-6820 fixed
This commit is contained in:
Evgeny Gerashchenko
2015-03-04 19:34:36 +03:00
parent 0a824edace
commit 8ba15937f9
12 changed files with 65 additions and 32 deletions
@@ -390,6 +390,7 @@ usageType.implicit.get = Implicit 'get'
usageType.implicit.set = Implicit 'set'
usageType.implicit.invoke = Implicit 'invoke'
usageType.implicit.iteration = Implicit iteration
usageType.property.delegation = Property delegation
usageType.extension.receiver.type = Extension receiver type
usageType.super.type.qualifier = Super type qualifier
usageType.receiver = Receiver
@@ -17,40 +17,13 @@
package org.jetbrains.kotlin.idea.findUsages
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.psi.JetForExpression
import org.jetbrains.kotlin.psi.JetMultiDeclaration
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
import org.jetbrains.kotlin.psi.JetReferenceExpression
import org.jetbrains.kotlin.psi.JetImportDirective
import org.jetbrains.kotlin.psi.JetCallableReferenceExpression
import org.jetbrains.kotlin.psi.JetProperty
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
import org.jetbrains.kotlin.psi.JetFunction
import org.jetbrains.kotlin.psi.JetTypeParameter
import org.jetbrains.kotlin.psi.JetTypeConstraint
import org.jetbrains.kotlin.psi.JetDelegationSpecifier
import org.jetbrains.kotlin.psi.JetTypedef
import org.jetbrains.kotlin.psi.JetTypeProjection
import org.jetbrains.kotlin.psi.JetParameter
import org.jetbrains.kotlin.psi.JetIsExpression
import org.jetbrains.kotlin.psi.JetBinaryExpressionWithTypeRHS
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.JetDotQualifiedExpression
import org.jetbrains.kotlin.psi.JetSuperExpression
import org.jetbrains.kotlin.psi.JetDelegatorByExpressionSpecifier
import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypesAndPredicate
import org.jetbrains.kotlin.psi.JetBinaryExpression
import org.jetbrains.kotlin.psi.JetPsiUtil
import org.jetbrains.kotlin.psi.JetSimpleNameExpression
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.psi.JetAnnotationEntry
import org.jetbrains.kotlin.psi.JetCallExpression
import org.jetbrains.kotlin.psi.JetUnaryExpression
import org.jetbrains.kotlin.psi.JetWhenConditionInRange
import org.jetbrains.kotlin.psi.JetPackageDirective
import org.jetbrains.kotlin.psi.JetQualifiedExpression
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
@@ -62,6 +35,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch
import org.jetbrains.kotlin.idea.references.JetArrayAccessReference
import org.jetbrains.kotlin.idea.references.JetInvokeFunctionReference
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.DescriptorUtils
public object UsageTypeUtils {
@@ -69,6 +43,7 @@ public object UsageTypeUtils {
when (element) {
is JetForExpression -> return IMPLICIT_ITERATION
is JetMultiDeclaration -> return READ
is JetPropertyDelegate -> return PROPERTY_DELEGATION
}
val refExpr = element.getNonStrictParentOfType<JetReferenceExpression>()
@@ -262,6 +237,7 @@ enum class UsageTypeEnum {
IMPLICIT_SET
IMPLICIT_INVOKE
IMPLICIT_ITERATION
PROPERTY_DELEGATION
RECEIVER
DELEGATE
@@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableSet
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.lexer.JetSingleValueToken
import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike
import org.jetbrains.kotlin.resolve.*
public val ALL_SEARCHABLE_OPERATIONS: ImmutableSet<JetToken> = ImmutableSet
.builder<JetToken>()
@@ -59,7 +60,8 @@ public fun Name.getOperationSymbolsToSearch(): Set<JetToken> {
IDENTITY_EQUALS -> return IDENTITY_EQUALS_OPERATIONS
CONTAINS -> return IN_OPERATIONS_TO_SEARCH
ITERATOR_OPERATION_NAME -> return ImmutableSet.of<JetToken>(JetTokens.IN_KEYWORD)
in INDEXING_OPERATION_NAMES -> return ImmutableSet.of<JetToken>(JetTokens.LBRACKET)
in INDEXING_OPERATION_NAMES -> return ImmutableSet.of<JetToken>(JetTokens.LBRACKET, JetTokens.BY_KEYWORD)
DelegatedPropertyResolver.PROPERTY_DELEGATED_FUNCTION_NAME -> return ImmutableSet.of<JetToken>(JetTokens.BY_KEYWORD)
}
if (isComponentLike(this)) return ImmutableSet.of<JetToken>(JetTokens.LPAR)