Find Usages on "override val" in constructor asks about base usages
Also fix long-standing bug with "title" parameter being ignored when displaying messages #KT-17845 Fixed
This commit is contained in:
@@ -25,7 +25,7 @@ import javax.swing.Icon
|
|||||||
|
|
||||||
fun showYesNoCancelDialog(key: String, project: Project, message: String, title: String, icon: Icon, default: Int?): Int {
|
fun showYesNoCancelDialog(key: String, project: Project, message: String, title: String, icon: Icon, default: Int?): Int {
|
||||||
return if (!ApplicationManager.getApplication().isUnitTestMode) {
|
return if (!ApplicationManager.getApplication().isUnitTestMode) {
|
||||||
Messages.showYesNoCancelDialog(project, message, message, icon)
|
Messages.showYesNoCancelDialog(project, message, title, icon)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
callInTestMode(key, default)
|
callInTestMode(key, default)
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import com.intellij.psi.PsiElement
|
|||||||
import com.intellij.psi.search.searches.OverridingMethodsSearch
|
import com.intellij.psi.search.searches.OverridingMethodsSearch
|
||||||
import org.jetbrains.kotlin.asJava.toLightMethods
|
import org.jetbrains.kotlin.asJava.toLightMethods
|
||||||
import org.jetbrains.kotlin.asJava.unwrapped
|
import org.jetbrains.kotlin.asJava.unwrapped
|
||||||
import org.jetbrains.kotlin.idea.KotlinBundle
|
|
||||||
import org.jetbrains.kotlin.idea.findUsages.handlers.DelegatingFindMemberUsagesHandler
|
import org.jetbrains.kotlin.idea.findUsages.handlers.DelegatingFindMemberUsagesHandler
|
||||||
import org.jetbrains.kotlin.idea.findUsages.handlers.KotlinFindClassUsagesHandler
|
import org.jetbrains.kotlin.idea.findUsages.handlers.KotlinFindClassUsagesHandler
|
||||||
import org.jetbrains.kotlin.idea.findUsages.handlers.KotlinFindMemberUsagesHandler
|
import org.jetbrains.kotlin.idea.findUsages.handlers.KotlinFindMemberUsagesHandler
|
||||||
@@ -80,6 +79,10 @@ class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandlerFactor
|
|||||||
|
|
||||||
is KtParameter -> {
|
is KtParameter -> {
|
||||||
if (canAsk) {
|
if (canAsk) {
|
||||||
|
if (element.hasValOrVar()) {
|
||||||
|
val declarationsToSearch = checkSuperMethods(element, null, "find usages of")
|
||||||
|
return handlerForMultiple(element, declarationsToSearch)
|
||||||
|
}
|
||||||
val function = element.ownerFunction
|
val function = element.ownerFunction
|
||||||
if (function != null && function.isOverridable()) {
|
if (function != null && function.isOverridable()) {
|
||||||
val psiMethod = function.toLightMethods().singleOrNull()
|
val psiMethod = function.toLightMethods().singleOrNull()
|
||||||
|
|||||||
@@ -848,7 +848,7 @@ fun checkSuperMethods(
|
|||||||
return overriddenElementsToDescriptor.entries.map { entry ->
|
return overriddenElementsToDescriptor.entries.map { entry ->
|
||||||
val (element, descriptor) = entry
|
val (element, descriptor) = entry
|
||||||
val description = when (element) {
|
val description = when (element) {
|
||||||
is KtNamedFunction, is KtProperty -> formatClassDescriptor(descriptor.containingDeclaration)
|
is KtNamedFunction, is KtProperty, is KtParameter -> formatClassDescriptor(descriptor.containingDeclaration)
|
||||||
is PsiMethod -> {
|
is PsiMethod -> {
|
||||||
val psiClass = element.containingClass ?: error("Invalid element: ${element.getText()}")
|
val psiClass = element.containingClass ?: error("Invalid element: ${element.getText()}")
|
||||||
formatPsiClass(psiClass, true, false)
|
formatPsiClass(psiClass, true, false)
|
||||||
@@ -891,7 +891,7 @@ fun checkSuperMethods(
|
|||||||
val overriddenElementsToDescriptor = HashMap<PsiElement, CallableDescriptor>()
|
val overriddenElementsToDescriptor = HashMap<PsiElement, CallableDescriptor>()
|
||||||
for (overriddenDescriptor in DescriptorUtils.getAllOverriddenDescriptors(declarationDescriptor)) {
|
for (overriddenDescriptor in DescriptorUtils.getAllOverriddenDescriptors(declarationDescriptor)) {
|
||||||
val overriddenDeclaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, overriddenDescriptor) ?: continue
|
val overriddenDeclaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, overriddenDescriptor) ?: continue
|
||||||
if (overriddenDeclaration is KtNamedFunction || overriddenDeclaration is KtProperty || overriddenDeclaration is PsiMethod) {
|
if (overriddenDeclaration is KtNamedFunction || overriddenDeclaration is KtProperty || overriddenDeclaration is PsiMethod || overriddenDeclaration is KtParameter) {
|
||||||
overriddenElementsToDescriptor[overriddenDeclaration] = overriddenDescriptor
|
overriddenElementsToDescriptor[overriddenDeclaration] = overriddenDescriptor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user