I would like to generate a class per package, when at least a class extending a certain base class is present in my package.
Currently I am doing this in a
FirDeclarationGenerationExtension
. When I see a class extending the base class of interest in
getNestedClassifiersNames
then I wrote that down and the next time that
getTopLevelClassIds
is invoked a return my new class id.
override fun getTopLevelClassIds(): Set<ClassId> {
val packages = mpNodeClassesEncountered.map { it.packageFqName() }.distinct()
val topLevelValues = packages.map { ClassId(it, Name.identifier("Language${it.asString().replace(".", "_").capitalize()}")) }.toMutableSet()
topLevelValues.removeAll(alreadyAddedClasses)
topLevelValues.map { sli ->
createTopLevelClass(sli, Key, classKind = ClassKind.OBJECT) {
superType(StarLasuLanguage::class.classId.toConeType())
}
}
alreadyAddedClasses.addAll(topLevelValues)
return alreadyAddedClasses
}
The problem is that reference to the object I generate are not resolved. The compiler behave as if the object does not exist.
Any idea about what I am doing wrong?