Skip to content

KaAdditionalKDocResolutionProvider

An extension point to provide additional symbols for a KDoc reference. KDoc link resolution will use symbols returned by this extension point only if the real resolution was unsuccessful.

Example

Let's assume that you want to return symbol fun foo() = 3 for the following KDoc resolution:

package com.example

fun foo() = 3

/**
 * [this.is.not.com.example.fo<caret>o] is not the above `com.example.foo`, but you want to resolve it to the above `com.example.foo`.
*/
fun bar() = 7

You can create the following provider:

class KaAdditionalKDocResolutionProviderBasedOnNameMatch : KaAdditionalKDocResolutionProvider {
  override fun resolveKdocFqName(analysisSession: KaSession, fqName: FqName, contextElement: KtElement): Collection<KaSymbol> =
    contextElement.containingKtFile.declarations.filter { it.name == fqName.shortName().asString() }.map { it.getSymbol() }
}

The extension point name is org.jetbrains.kotlin.kaAdditionalKDocResolutionProvider.

Types

Companion

object Companion

Functions

resolveKdocFqName

abstract fun resolveKdocFqName(
    analysisSession: KaSession, 
    fqName: FqName, 
    contextElement: KtElement
): Collection<KaSymbol>

Returns additional symbols for the given contextElement in KDoc.