Skip to content

KtNamedDeclarationUtil

Static helpers for computing fully qualified names of KtNamedDeclarations from their PSI structure.

Prefer getFqName in client code; these helpers back that computation by walking the enclosing declarations and package directive.

Companion functions

getParentFqName

@Nullable
open fun getParentFqName(@NotNull namedDeclaration: KtNamedDeclaration): FqName

Returns the fully qualified name of the element that lexically encloses the given namedDeclaration — its package for a top-level declaration, or the containing class, object, or script otherwise — or null if it cannot be determined.