Skip to content

Commit

Permalink
@KoraSubmodule generated modules should not implement root interface (
Browse files Browse the repository at this point in the history
  • Loading branch information
Squiry authored Jul 24, 2023
1 parent 000dbc4 commit c689304
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ private void generateAppParts() throws IOException {
var packageElement = this.elements.getPackageOf(appPart);
var b = TypeSpec.interfaceBuilder(appPart.getSimpleName() + "SubmoduleImpl")
.addModifiers(Modifier.PUBLIC)
.addSuperinterface(appPart.asType());
;
var componentNumber = 0;
for (var component : this.components) {
b.addOriginatingElement(component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ void appPart() throws Exception {
Assertions.assertThat(clazz).isNotNull()
.isInterface()
.hasDeclaredMethods("_component0", "_component1")
.matches(AppWithAppPart.class::isAssignableFrom)
.matches(Predicate.not(AppWithAppPart.Module.class::isAssignableFrom));
var targetFile1 = "src/test/java/" + AppWithAppPartApp.class.getName().replace('.', '/') + ".java";
var targetFile2 = "in-test-generated/classes/" + clazz.getCanonicalName().replace('.', '/') + ".class";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ class KoraAppProcessor(
.filter(filterObjectMethods)
.toMutableList()

val submodules = declaration.superTypes.map { it.resolve() }
val submodules = declaration.getAllSuperTypes()
.map { it.declaration as KSClassDeclaration }
.filter { it.findAnnotation(CommonClassNames.koraSubmodule) != null }
.map { resolver.getKSNameFromString(it.qualifiedName!!.asString() + "SubmoduleImpl") }
.map { resolver.getClassDeclarationByName(it)!! }
.map { resolver.getClassDeclarationByName(it) ?: throw java.lang.IllegalStateException("Declaration of ${it.asString()} was not found") }
.toList()
val allModules = (submodules + annotatedModules)
.flatMap { it.getAllSuperTypes().map { it.declaration as KSClassDeclaration } + it }
Expand Down Expand Up @@ -359,7 +359,6 @@ class KoraAppProcessor(
for (appPart in this.appParts) {
val packageName = appPart.packageName.asString()
val b = TypeSpec.interfaceBuilder(appPart.simpleName.asString() + "SubmoduleImpl")
.addSuperinterface(appPart.toClassName())
.generated(KoraAppProcessor::class)
var componentCounter = 0
for (component in components) {
Expand All @@ -379,7 +378,7 @@ class KoraAppProcessor(
if (i > 0) {
mb.addCode(", ")
}
mb.addCode("%N", parameter)
mb.addCode("%N", parameter.name?.asString())
}
val tag = component.parseTags()
if (tag.isNotEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ class KoraAppKspTest {
Assertions.assertThat(clazz).isNotNull
.isInterface
.hasMethods("_component0", "_component1")
.matches { cls -> AppWithAppPart::class.java.isAssignableFrom(cls) }
.matches { cls -> !AppWithAppPart.Module::class.java.isAssignableFrom(cls) }
val targetFile1 = "src/test/kotlin/" + AppWithAppPartApp::class.java.name.replace('.', '/') + ".kt"
val modulePath = AppWithAppPart::class.java.protectionDomain.codeSource.location.path.substringBefore("/build")
Expand Down

0 comments on commit c689304

Please sign in to comment.