diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/ExpressionsOfTypeProcessor.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/ExpressionsOfTypeProcessor.kt index d5d5d1a21df..8c38f53f18d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/ExpressionsOfTypeProcessor.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/ExpressionsOfTypeProcessor.kt @@ -289,12 +289,12 @@ class ExpressionsOfTypeProcessor( is KtReferenceExpression -> { val parent = element.parent when (parent) { - is KtUserType -> { + is KtUserType -> { // usage in type return processClassUsageInUserType(parent) } is KtCallExpression -> { - if (element == parent.calleeExpression) { + if (element == parent.calleeExpression) { // constructor invocation processSuspiciousExpression(parent) return true } @@ -307,7 +307,7 @@ class ExpressionsOfTypeProcessor( } is KtQualifiedExpression -> { - if (element == parent.receiverExpression) { + if (element == parent.receiverExpression) { // .memberName return true // companion object member or static member access - ignore it } } @@ -326,7 +326,7 @@ class ExpressionsOfTypeProcessor( } is KtClassLiteralExpression -> { - if (element == parent.receiverExpression) { // ClassName::class + if (element == parent.receiverExpression) { // ::class processSuspiciousExpression(element) return true } @@ -348,7 +348,7 @@ class ExpressionsOfTypeProcessor( when (typeRefParent) { is KtCallableDeclaration -> { when (typeRef) { - typeRefParent.typeReference -> { + typeRefParent.typeReference -> { // usage in type of callable declaration addCallableDeclarationToProcess(typeRefParent, CallableToProcessKind.HAS_OUR_CLASS_TYPE) if (typeRefParent is KtParameter) { //TODO: what if functional type is declared with "FunctionN<...>"? @@ -364,7 +364,7 @@ class ExpressionsOfTypeProcessor( return true } - typeRefParent.receiverTypeReference -> { + typeRefParent.receiverTypeReference -> { // usage in receiver type of callable declaration // we must use plain search inside extensions because implicit 'this' can happen anywhere usePlainSearch(typeRefParent) return true @@ -372,7 +372,7 @@ class ExpressionsOfTypeProcessor( } } - is KtTypeProjection -> { + is KtTypeProjection -> { // usage in type arguments of a call val callExpression = (typeRefParent.parent as? KtTypeArgumentList)?.parent as? KtCallExpression if (callExpression != null) { processSuspiciousExpression(callExpression) @@ -380,7 +380,7 @@ class ExpressionsOfTypeProcessor( } } - is KtConstructorCalleeExpression -> { + is KtConstructorCalleeExpression -> { // super-class name in the list of bases val parent = typeRefParent.parent if (parent is KtSuperTypeCallEntry) { val classOrObject = (parent.parent as KtSuperTypeList).parent as KtClassOrObject @@ -390,7 +390,7 @@ class ExpressionsOfTypeProcessor( } } - is KtSuperTypeListEntry -> { + is KtSuperTypeListEntry -> { // super-interface name in the list of bases if (typeRef == typeRefParent.typeReference) { val classOrObject = (typeRefParent.parent as KtSuperTypeList).parent as KtClassOrObject val psiClass = classOrObject.toLightClass() @@ -399,13 +399,13 @@ class ExpressionsOfTypeProcessor( } } - is KtIsExpression -> { + is KtIsExpression -> { // is val scopeOfPossibleSmartCast = typeRefParent.getParentOfType(true) scopeOfPossibleSmartCast?.let { usePlainSearch(it) } return true } - is KtWhenConditionIsPattern -> { + is KtWhenConditionIsPattern -> { // "is " or "!is " in when val whenEntry = typeRefParent.parent as KtWhenEntry if (typeRefParent.isNegated) { val whenExpression = whenEntry.parent as KtWhenExpression @@ -418,7 +418,7 @@ class ExpressionsOfTypeProcessor( return true } - is KtBinaryExpressionWithTypeRHS -> { + is KtBinaryExpressionWithTypeRHS -> { // as processSuspiciousExpression(typeRefParent) return true } @@ -439,20 +439,20 @@ class ExpressionsOfTypeProcessor( break@ParentsLoop // ignore local usages is PsiMethod -> { - if (prev == parent.returnTypeElement && !parent.isPrivateOrLocal()) { + if (prev == parent.returnTypeElement && !parent.isPrivateOrLocal()) { // usage in return type of a method addCallableDeclarationToProcess(parent, CallableToProcessKind.HAS_OUR_CLASS_TYPE) } break@ParentsLoop } is PsiField -> { - if (prev == parent.typeElement && !parent.isPrivateOrLocal()) { + if (prev == parent.typeElement && !parent.isPrivateOrLocal()) { // usage in type of a field addCallableDeclarationToProcess(parent, CallableToProcessKind.HAS_OUR_CLASS_TYPE) } break@ParentsLoop } - is PsiReferenceList -> { + is PsiReferenceList -> { // usage in extends/implements list if (parent.role == PsiReferenceList.Role.EXTENDS_LIST || parent.role == PsiReferenceList.Role.IMPLEMENTS_LIST) { val psiClass = parent.parent as PsiClass if (!psiClass.isPrivateOrLocal()) { @@ -464,7 +464,7 @@ class ExpressionsOfTypeProcessor( //TODO: if Java parameter has Kotlin functional type then we should process method usages is PsiParameter -> { - if (prev == parent.typeElement) { + if (prev == parent.typeElement) { // usage in parameter type - check if the method is in SAM interface val method = parent.declarationScope as? PsiMethod if (method != null && method.hasModifierProperty(PsiModifier.ABSTRACT)) { val psiClass = method.containingClass @@ -509,12 +509,12 @@ class ExpressionsOfTypeProcessor( val parent = element.parent when (parent) { - is KtDestructuringDeclaration -> { + is KtDestructuringDeclaration -> { // "val (x, y) = " processSuspiciousDeclaration(parent) break@ParentsLoop } - is KtWithExpressionInitializer -> { + is KtWithExpressionInitializer -> { // "val x = " or "fun f() = " if (element == parent.initializer) { processSuspiciousDeclaration(parent) } @@ -522,7 +522,7 @@ class ExpressionsOfTypeProcessor( } is KtContainerNode -> { - if (parent.node.elementType == KtNodeTypes.LOOP_RANGE) { + if (parent.node.elementType == KtNodeTypes.LOOP_RANGE) { // "for (x in ) ..." val forExpression = parent.parent as KtForExpression (forExpression.destructuringParameter ?: forExpression.loopParameter as KtDeclaration?)?.let { processSuspiciousDeclaration(it)