Skip to content

asPsiMethods

context(session: KaSession)
fun KaFunctionSymbol.asPsiMethods(): List<PsiMethod>

Converts the given KaFunctionSymbol to Java PsiMethods in the context of the useSiteModule.

The resulting list is the view on the given Kotlin declaration from Java and contains all PsiMethods produced by this.

useSiteModule for the current KaSession is used to provide proper actualizations for expect declarations. Since the produced list is a JVM-specific representation, useSiteModule is expected to be a JVM one.

If useSiteModule is not a JVM module or the provided KaFunctionSymbol is not visible from Java, returns an empty list.

Example:

The following Kotlin function:

// MyFile.kt
@JvmOverloads
@JvmName("jvmFoo")
fun foo(a: Int, b: Int = 1) {}

Is seen as the following PsiMethods from Java:

public final class MyFileKt {
    @kotlin.jvm.JvmName(name = "jvmFoo")
    @kotlin.jvm.JvmOverloads()
    public static void jvmFoo(int);

    @kotlin.jvm.JvmName(name = "jvmFoo")
    @kotlin.jvm.JvmOverloads()
    public static void jvmFoo(int, int);
}