Package-level declarations

Types

Link copied to clipboard
data class CollectionWrapperDescriptor(val wrapperObjectFqn: String, val forTypeFqn: String, val providesWrap: Boolean, val providesUnwrap: Boolean)

A validated @CollectionWrapper registration: which container type it serves and which directions it provides. TypeMatcher consults the direction flags so a mapping that needs a missing direction gets a guided compile error (the wrapper counterpart of UnsupportedConversion).

Link copied to clipboard
class CollectionWrapperValidator(logger: KSPLogger)

Validates a @CollectionWrapper object's duck-typed contract against its forType. Kotlin has no higher-kinded types, so the shapes are conventions — compile-checked here:

Link copied to clipboard
class ConverterIntrospector(resolver: Resolver, logger: KSPLogger? = null)

Reads a converter declaration's ConverterShape from the KSP Resolver: its (S, T) type pair from the MapTypeConverter supertype — found by walking UP the superclass chain, so parameterized-converter bases (the ledger's official recipe: object PriceFormatConverter : FormattedDoubleStringConverter(digits = 2) where the abstract base extends MapTypeConverter<Double, String>) resolve too — and which directions it provides, via function-level detection of the declared overrides (most derived wins) and their @UnsupportedDirection annotations.

Link copied to clipboard
data class ConverterShape(val sourceFqn: String, val targetFqn: String, val declaredToTotal: Boolean, val declaredToOrNull: Boolean, val declaredFromTotal: Boolean, val declaredFromOrNull: Boolean, val unsupportedToReason: String?, val unsupportedFromReason: String?, val orNullAnnotatedFunction: String?)

Which directions a converter provides, and any declared @UnsupportedDirection reasons.

Link copied to clipboard
class CycleDetector(logger: KSPLogger)

Detects guaranteed-infinite mapping cycles at compile time.

Link copied to clipboard
class FieldAnalyzer(logger: KSPLogger)

Analyzes fields (constructor parameters) and extracts mapping annotations.

Link copied to clipboard
data class ReturnWrapper(val wrapperClassName: ClassName, val suffix: String, val wrapFunctions: List<WrapFunction>)

A resolved return wrapper: the object to call, its suffix and its wrap overloads.

Link copied to clipboard
class ReturnWrapperResolver(resolver: Resolver, logger: KSPLogger, moduleWideOption: String?)

Resolves the wrapper = … argument of @MapTo / @MapFrom into a ReturnWrapper (null = no wrapper, only the plain toX() core).

Link copied to clipboard
class TypeMatcher(logger: KSPLogger, customConverters: Map<Pair<String, String>, String> = emptyMap(), collectionWrappers: Map<String, CollectionWrapperDescriptor> = emptyMap(), introspector: ConverterIntrospector? = null)

Determines the appropriate mapping strategy for field transformations.

Link copied to clipboard
data class WrapFunction(val receiverShape: KSType, val returnShape: KSType, val sourceTypeParameter: String, val targetTypeParameter: String, val typeParameterOrder: List<String>)

One wrap overload of a return wrapper, parsed from its signature fun <S, T> wrap(source: R<S>, map: (S) -> T): W<T>.

Functions

Link copied to clipboard
fun discoverWrappersFromConfig(resolver: Resolver, logger: KSPLogger): Map<String, CollectionWrapperDescriptor>

Reads all @KMapperConfig.wrappers listings (in-module, works on KMP/iOS), resolves each wrapper object's @CollectionWrapper.forType, and validates the duck-typed wrap/unwrap contract via CollectionWrapperValidator to build Map.

Link copied to clipboard
fun KSType.substituteTypeParameters(bindings: Map<String, TypeName>): TypeName

Converts this wrap-signature type into a KotlinPoet TypeName, replacing type parameters by bindings (S → the mapper's source, T → its target). Nullability and use-site variance are preserved.