threading a question asking about Find Usages (or ...
# intellij
t
threading a question asking about Find Usages (or alternatives) for a function
typealias
or function signature
Our code uses
typealias
for a function signature fairly heavily. Here is small made-up example:
Copy code
data class Widget(val name: String)
typealias PersistWidget = (Widget) -> Boolean

class RealBackend {
    // other functions, not something that can be just a SAM
    fun persist(widget: Widget): Boolean = TODO()
}

class FakeBackend {
    fun persistSuccess(widget: Widget): Boolean = true
    fun persistFailure(widget: Widget): Boolean = false
}

class Facade(val persist: PersistWidget) {
    fun createWidget(): Widget {
        val widget = Widget("default")
        return if (persist(widget)) {
            widget
        } else {
            throw Exception("failed to persist")
        }
    }
}

fun main() {
    val backend = FakeBackend()
    val facade = Facade(backend::persistSuccess)
    facade.createWidget()
}
If
PersistWidget
were an interface, it'd be easy to find all of the classes that implement that interface
but with a
typealias
I'm not aware of an equivalent ability to find all things that have the same type signature as my
typealias
is there some way of using Find Usages, or similar, to find all of the things in my code that have the same type signature as the
PersistWidget
typealias?
right now, I can cmd-B on the
PersistWidget
and it'll show me that there is a single use of it in this line:
Copy code
class Facade(val persist: PersistWidget) {
which is correct for explicit usages of that
but I'd also like it to be able to expand that search so that it also shows me functions that are effectively that
typealias
as well, so that it'd show me these too:
I found a sort of similar question in history that seems to imply that it's possible but I haven't figured out how: https://kotlinlang.slack.com/archives/C0B8H786P/p1585584873009600
a
I think it's not possible. Can you please create a feature request at http://kotl.in/issue and describe your use case with sample code attached? Thanks!
t
Will do, thanks!