KotlinNames

Small, dependency-free Kotlin naming helpers.

The engine needs stable defaults when generating Kotlin stubs (import, scaffolding, etc.). In practice, the two most important operations are:

  1. Turning a human / file / folder name into a Kotlin type name (UpperCamelCase).

  2. Turning a Kotlin type name into a Kotlin property name (lowerCamelCase).

This file intentionally avoids heavyweight dependencies and keeps the rules predictable.

Functions

Link copied to clipboard
fun packageFromPath(root: Path, path: Path): String

Derives a dotted Kotlin package name from a directory path relative to root.

Link copied to clipboard

Derives a dotted Kotlin package name from a relative directory path.

Link copied to clipboard

Converts a dotted package name to a forward-slash-separated relative path.

Link copied to clipboard
fun toInstanceName(typeName: String): String

Convert a Kotlin type name into a lowerCamelCase property name.

Link copied to clipboard

Best-effort conversion of a file system path segment into a Kotlin package segment.

Link copied to clipboard

Strict conversion of a path segment into a Kotlin package segment.

Link copied to clipboard
fun toTypeName(raw: String, fallback: String = "Element"): String

Convert an arbitrary string into a valid Kotlin class name.

Generated with STIG