Home > database >  How to find where a Kotlin interface method is overridden in intellij?
How to find where a Kotlin interface method is overridden in intellij?

Time:11-30

Given this Foo interface

interface Foo {
    fun whereIsThisImplemented(a: String): String
}

// How do I use the above interface to find the below implementation
class Bar: Foo {
    override fun whereIsThisImplemented(a: String): String {
        return a
    }

}

is there a simple way of finding where the whereIsThisImplemented method is overridden through intellij?

While whereIsThisImplemented is highlighted, Using edit -> Find Usages -> Find Usage Settings, none of the options will find the Override fun whereIsThisImplemented.

I could find all places the interface is implemented, then look for the method, but this is extremely cumbersome and I was hoping there was a simpler way that I was missing.

CodePudding user response:

Menu: Navigate -> Implementations . Note down the shortcut besides the menu.

Alternatively, you can click on the down arrow on the left of the method declaration

enter image description here

Tip: Install key promoter plugin so that you get a notification of keyboard shortcut everytime you use the mouse.

CodePudding user response:

Hover over the green icon next to the interface function to see a list of places where it is implemented. If you click the icon, it jumps you to that spot in the code.

enter image description here

  • Related