Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see source code of a fun in Kotlin in Android Studio 3.1.3?

I hope to see the source code of the fun let, but I get the following content after I ctrl + click data?.let.

How to see the source code of a fun in Kotlin in Android Studio 3.1.3?

@kotlin.internal.InlineOnly public inline fun <T, R> T.let(block: (T) -> R): R { /* compiled code */ }

Added Content

Added Content

Android studio start

And More

The image when I click on choose sources

kotlin jar image

Solved:

Now it's OK when system updates the Kotlin plugin today.

I think that the system update the plugin failed caused the problem.

How can I update the plugin manually? You know the Update Plugin UI doesn't always be displayed by the system!

enter image description here

like image 899
HelloCW Avatar asked Jul 26 '18 03:07

HelloCW


People also ask

Where is the source code in Android Studio?

From within Android Studio, navigate to Tools -> Android -> SDK Manager. Once open, you'll need to download the Sources for Android SDK as shown below. Once you have the sources downloaded, you can find the source code inside of the "sources" folder of your SDK (wherever that may be on your computer).

Where do I put the Kotlin code in Android Studio?

To convert Java code to Kotlin, open the Java file in Android Studio, and select Code > Convert Java File to Kotlin File. Alternatively, create a new Kotlin file (File > New > Kotlin File/Class), and then paste your Java code into that file.

Can I code in Kotlin on my phone?

Kotlin is an officially supported language for developing Android apps, along with Java.


1 Answers

I can see the source code of let in kotlin-stdlib-common-1.2.51.jar where path is kotlin -> Standard.kt (or file name showing as StandardKt.kotlin_metadata). I am doing same command.

Below is code of that fun

/**
 * Calls the specified function [block] with `this` value as its argument and returns its result.
 */
@kotlin.internal.InlineOnly
public inline fun <T, R> T.let(block: (T) -> R): R {
    contract {
        callsInPlace(block, InvocationKind.EXACTLY_ONCE)
    }
    return block(this)
}

Versions I am using are

Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6

And kotlin version is Version: 1.2.51-release-Studio3.1-1
like image 75
Pankaj Kumar Avatar answered Oct 20 '22 15:10

Pankaj Kumar