Skip to content

Commit

Permalink
fix(generator-accessor): ensure explicit accessor isn't ignored when …
Browse files Browse the repository at this point in the history
…it's glob matched as well
  • Loading branch information
zlataovce committed Sep 24, 2023
1 parent ed3da3f commit 56daf3b
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

package me.kcra.takenaka.generator.accessor

import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.*
import me.kcra.takenaka.core.Workspace
import me.kcra.takenaka.generator.accessor.context.generationContext
import me.kcra.takenaka.generator.accessor.model.ClassAccessor
import me.kcra.takenaka.generator.accessor.util.isGlob
import me.kcra.takenaka.generator.common.Generator
import me.kcra.takenaka.generator.common.provider.AncestryProvider
import me.kcra.takenaka.generator.common.provider.MappingProvider
Expand Down Expand Up @@ -51,14 +50,21 @@ class AccessorGenerator(override val workspace: Workspace, val config: AccessorC
val tree = ancestryProvider.klass<_, MappingTreeView.ClassMappingView>(mappings)

generationContext(ancestryProvider, config.codeLanguage) {
coroutineScope {
config.accessors.forEach { classAccessor ->
launch(Dispatchers.Default + CoroutineName("generate-coro")) {
generateClass(classAccessor, tree)
}
fun CoroutineScope.generateAccessor(classAccessor: ClassAccessor) {
launch(Dispatchers.Default + CoroutineName("generate-coro")) {
generateClass(classAccessor, tree)
}
}

// generate non-glob accessors before glob ones to ensure that an explicit accessor doesn't get ignored
val (glob, nonGlob) = config.accessors.partition { it.internalName.isGlob }
coroutineScope {
nonGlob.forEach(::generateAccessor)
}
coroutineScope {
glob.forEach(::generateAccessor)
}

generateLookupClass()
generateExtras()
}
Expand Down

0 comments on commit 56daf3b

Please sign in to comment.