Given a file com/example/Foo.kt
package com.example
fun bar() = null
If I try to link to it from KDoc:
/**
* Used by [com.example.Foo.bar]
*/
Idea tells me "Cannot resolve symbol 'bar'"
/**
* Used by [com.example.FooKt.bar]
*/
Idea now can't find "FooKt"
Given a file com/example/Foo.kt
package com.example
fun bar() = null
If I try to link to it from KDoc:
/**
* Used by [com.example.Foo.bar]
*/
Idea tells me "Cannot resolve symbol 'bar'"
/**
* Used by [com.example.FooKt.bar]
*/
Idea now can't find "FooKt"
Share Improve this question edited Jan 29 at 12:03 Jakub Bochenski asked Jan 27 at 15:39 Jakub BochenskiJakub Bochenski 3,2714 gold badges37 silver badges67 bronze badges 6- 3 Documentation is supposed to be public, and private members are hidden implementation detail. – k314159 Commented Jan 27 at 15:43
- @k314159 this is just your opinion. In Javadoc you can link to private members – Jakub Bochenski Commented Jan 27 at 15:47
- 3 @k314159 I disagree. While you shouldn't include references to private members in the documentation for public members, it makes sense to include such references in the documentation for private members. – Sweeper Commented Jan 27 at 18:45
- @Sweeper I agree in general, but I usually don't bother making private documentation conform to Javadoc format unless the class is a very large and complicated one. – k314159 Commented Jan 28 at 10:19
- 3 I cannot reproduce this error / warning in IntelliJ IDEA Ultimate 2024.1. Maybe provide a complete minimal reproducible example. Also: Where is this comment located? On a class, method, field, somewhere else? Also is the comment in the same kotlin file, or somewhere else? Is this class available in your class path. Is the FQDN correct? – Lino Commented Jan 28 at 18:22
1 Answer
Reset to default 2To link to a top-level function you need to use a proper FQDN, which is the package name and the element name (no matter what file it's defined in).
E.g.
/**
* Used by [com.example.bar]
*/
What has confused me initially is that if you use "Copy Reference" in Idea it will generate an incorrect value like com.example.FooKt.bar