FeatureFlagCodegenProcessor

class FeatureFlagCodegenProcessor(codeGenerator: CodeGenerator, logger: KSPLogger, platforms: List<PlatformInfo>) : SymbolProcessor(source)

KSP processor that turns @FeatureFlag-decorated anchors into a Metro @Qualifier annotation and a binding interface. Loaded once per build by KSP through FeatureFlagCodegenProcessorProvider.

For each annotated symbol the processor validates the shape (class/object/interface — not an annotation class — with non-blank key and title and an ISO-formatted dateAdded), parses the annotation arguments, takes the base name from the anchor's simple name verbatim, and hands the result to FeatureFlagQualifierGenerator and FeatureFlagBindingGenerator, which emit one <BaseName>Qualifier.kt and one <BaseName>Binding.kt file into the anchor's package. Validation failures are reported through KSPLogger.error pinned to the offending symbol so KSP turns them into compile errors at the source position, rather than thrown; the annotation-argument readers assume KSP has already guaranteed the required members are present.

The DSL attaches the processor to the commonMain metadata run and every per-target run, so a PlatformSourceSetGuard keeps a single run as the one that emits each anchor. The anchor's platform field drives this: a FlagPlatform.ALL flag is generated by the metadata run alone, while a platform = IOS/JVM flag is generated only by the matching per-target run. The guard runs before validation so a malformed anchor reports its error once, from the run that owns it, rather than once per compilation.

Constructors

Link copied to clipboard
constructor(codeGenerator: CodeGenerator, logger: KSPLogger, platforms: List<PlatformInfo>)

Functions

Link copied to clipboard
open fun finish()
Link copied to clipboard
open fun onError()
Link copied to clipboard
open override fun process(resolver: Resolver): List<KSAnnotated>

Runs one KSP round. Iterates every symbol annotated with @FeatureFlag, skips anchors the current run does not own, validates and parses the rest into a FeatureFlagData, and writes one qualifier and one binding file per owned anchor.