I’m trying to look at the implementation details of some of the Kotlin standard library functions to ensure that they meet my needs but I’m struggling with functions that are intended for multi-platform which utilize the expect
keyword.
As an example, looking at TextH.kt
, we see
expect fun CharSequence.isBlank(): Boolean
but I don’t know how to navigate to the actual
implementation of that within IntelliJ. I understand that there are multiple sources (one for each platform) but I would expect to see something similar to interfaces where I can see the various actual
implementations of that function.
I’m working in a regular back-end JVM project so I’m actually just interested in a quick way of navigating to the JVM implementation of that function. Is there any way to navigate to the actual
implementations within IntelliJ?
Usually you just have to click yellow something on the left of the code line.
Looks like that navigation is not working for library sources yet.
https://youtrack.jetbrains.com/issue/KT-22955
@Beholder Thanks, I upvoted the defect and added a comment asking to raise the priority since this defect is affecting all types of projects (not just multi-platform projects).
Actually if you’re navigating from a JVM project, you should get straight to the actual
declaration for JVM platform. There was some fix about it recently (KT-28398) that was targeted to 1.3.20.
Could you try 1.3.20-eap-25 version of Kotlin plugin and tell whether it fixes your issue?
I updated the plugin to 1.3.20-eap-52-IJ2018.3-1 and that made a huge improvement. I can now navigate from my code directly to the actual
implementation nicely.
However, if I’m looking at a file with expect
declarations, I can’t navigate to the actual
implementation from there. As a workaround, I can temporarily use the function that I’m looking at and then navigate into that. This should be less of an issue in JVM projects since I’ll probably never end up looking at files with expect
declarations since navigating should always take me straight into the file with the actual
implementations.
Thanks for your help