IDEA-CR-57967 UAST: store empty list for uastByUsageReferenceProvider if there are no usages

GitOrigin-RevId: d4d997a520aeed00f2c4a8332f4abbf2b4ca0b51
This commit is contained in:
Yuriy Artamonov
2020-02-03 16:13:16 +03:00
committed by intellij-monorepo-bot
parent 9afc0f753f
commit 9a7be4f1d0

View File

@@ -132,7 +132,8 @@ fun PsiReferenceRegistrar.registerByUsageReferenceProvider(expressionPattern: UE
val parentVariable = element.uastParent as? UVariable ?: return emptyArray()
val usage = getDirectVariableUsages(parentVariable).find { usage ->
usagePattern.accepts(usage, context)
val refExpression = usage.toUElementOfType<UReferenceExpression>()
refExpression != null && usagePattern.accepts(refExpression, context)
}
if (usage == null) return emptyArray()
@@ -192,5 +193,5 @@ private fun findDirectVariableUsages(variablePsi: PsiElement): List<PsiElement>
true
}
return usages
return if (usages.isEmpty()) emptyList() else usages
}