Open stephan-gh opened 7 years ago
Thanks for the report @Minecrell!
I confirmed this locally.
Navigating to Gradle Kotlin DSL source works.
Navigating to Gradle API (gradleApi()
) source doesn't.
We'll look into this.
@eskatos Weird, it's the exact opposite for me(?). I was able to navigate to Gradle API source (e.g. the Project
or Task
interface) but not to the source of Gradle Kotlin DSL (e.g. additional extension it adds).
@Minecrell 🤔 which version of IntelliJ and the Kotlin Plugin for it are you using?
@eskatos IntelliJ IDEA 2017.2.5 with Gradle 4.2 (and the version of kotlin-dsl
it bundles). I used "Use local Gradle distribution" if that makes any difference.
I just tried with "Use default Gradle wrapper" and the latest snapshot distribution used on the develop
branch and the same happens.
For reference, the project I'm testing with is available at https://github.com/Minecrell/plugin-yml. In PlatformPlugin.kt
I'm able to navigate to the source of Project
or Project.getExtensions()
, but not to the task<T>
or plugins.withType<T>
extension method from kotlin-dsl.
I can't reproduce using Gradle 4.9 on IntelliJ IDEA 2018.1.6 nor on 2018.2.RC.
Here's a cast using the former:
Also validated in some buildSrc
.
Note I'm using a -bin
distribution when testing.
After invalidating all IntelliJ caches, restarting, I can reproduce the issues:
.kt
files fails.kt
files failsFor the Gradle Kotlin DSL API, sources are embedded in the jars. It seems IntelliJ is not picking up the sources from them.
For the Gradle API, it's another story and is currently enabled by using a -all
distribution.
Interestingly as soon as you open a .gradle.kts
file, then IntelliJ resolves the sources for the script editor and then they are available when navigating from .kt
files. Somehow, IntelliJ shares the sources it recognizes from the script source-path with the Kotlin files from source sets.
The gif in the previous comment was done after doing just that, that's why the navigation to sources was working. Confusing, but it provides a work around.
IntelliJ issue for recognizing sources embedded in jars: https://youtrack.jetbrains.com/issue/IDEA-15406
And the gradle/gradle
issue for IDE plugins to provide Gradle sources:
https://github.com/gradle/gradle/issues/1003
We can't work around https://youtrack.jetbrains.com/issue/IDEA-15406 by publishing -sources
jar as it would require adding a remote repository.
To sum up:
Navigating to Gradle API sources from .kt
files when the kotlin-dsl
plugin is applied
-all
wrapper-bin
wrapper once you opened a .gradle.kts
file once-bin
wrapper if gradle/gradle#1003 was implementedNavigating to Kotlin DSL sources from .kt
files when the kotlin-dsl
plugin is applied
.gradle.kts
file onceTurning this issue into a vendor issue for IDEA-15406.
I'm using the
kotlin-dsl
Gradle plugin to create a new Gradle plugin written in Kotlin together with IntelliJ IDEA. When using the kotlin-dsl extension methods inbuild.gradle.kts
, navigation to the source works correctly. However, it does not work when using thekotlin-dsl
Gradle plugin. Instead, IntelliJ IDEA navigates to the decompiled stub source file.Using the test class below, the two methods marked with a comment do not have sources attached:
I can provide a full test project if necessary. However, it's simple to reproduce by applying the
kotlin-dsl
Gradle plugin in a project and then using the test class above.Expected Behavior
Navigation to sources should work in IntelliJ IDEA for kotlin-dsl extension methods when using the
kotlin-dsl
Gradle plugin to create a Gradle plugin.Current Behavior
IntelliJ IDEA navigates to a decompiled stub source file.