Jakub Bochenski
Jakub Bochenski

Reputation: 3277

How do I link to a top-level function in a KDoc comment?

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"

Upvotes: -8

Views: 183

Answers (1)

Jakub Bochenski
Jakub Bochenski

Reputation: 3277

To 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

Upvotes: 2

Related Questions