diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/picker/CodePicker.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/picker/CodePicker.kt index 05102ff9..9694685a 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/picker/CodePicker.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/picker/CodePicker.kt @@ -37,7 +37,7 @@ class CodePicker(private val config: PickerConfig) { launch { for (fileJob in walkdirChannel) { languageWorker.processFile(fileJob)?.let { - workerManager.addJob(PickJob.from(it)) + workerManager.addJob(InstructionJob.from(it)) } } diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/picker/PickJob.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/picker/InstructionJob.kt similarity index 79% rename from unit-picker/src/main/kotlin/cc/unitmesh/pick/picker/PickJob.kt rename to unit-picker/src/main/kotlin/cc/unitmesh/pick/picker/InstructionJob.kt index 32efdbb5..c8542865 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/picker/PickJob.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/picker/InstructionJob.kt @@ -5,14 +5,14 @@ import kotlinx.serialization.Serializable import org.archguard.scanner.analyser.count.FileJob @Serializable -class PickJob( +class InstructionJob( var fileSummary: FileJob, var code: String = "", var container: CodeContainer? = null, ) { companion object { - fun from(fileJob: FileJob): PickJob { - return PickJob( + fun from(fileJob: FileJob): InstructionJob { + return InstructionJob( code = fileJob.content.decodeToString(), fileSummary = fileJob ) diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/JavaLangWorker.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/JavaLangWorker.kt index 2520e9ff..c658bac7 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/JavaLangWorker.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/JavaLangWorker.kt @@ -1,7 +1,7 @@ package cc.unitmesh.pick.worker import cc.unitmesh.pick.prompt.InstructionBuilder -import cc.unitmesh.pick.picker.PickJob +import cc.unitmesh.pick.picker.InstructionJob import chapi.ast.javaast.JavaAnalyser import kotlinx.coroutines.coroutineScope import org.archguard.scanner.analyser.count.FileJob @@ -21,19 +21,19 @@ import org.archguard.scanner.analyser.count.FileJob * - by Vertical (with History Change): */ class JavaLangWorker : LangWorker() { - private val jobs: MutableList = mutableListOf() - private val packageTree: MutableMap = mutableMapOf() + private val jobs: MutableList = mutableListOf() + private val packageTree: MutableMap = mutableMapOf() private val packageRegex = Regex("package\\s+([a-zA-Z0-9_.]+);") private val extLength = ".java".length - override fun addJob(job: PickJob) { + override fun addJob(job: InstructionJob) { this.jobs.add(job) tryAddClassToTree(job.code, job) job.container = JavaAnalyser().analysis(job.code, job.fileSummary.location) } - private fun tryAddClassToTree(code: String, job: PickJob) { + private fun tryAddClassToTree(code: String, job: InstructionJob) { val packageMatch = packageRegex.find(code) if (packageMatch != null) { val packageName = packageMatch.groupValues[1] diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/LangWorker.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/LangWorker.kt index 5ca59a17..0607b6f2 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/LangWorker.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/LangWorker.kt @@ -1,9 +1,9 @@ package cc.unitmesh.pick.worker import cc.unitmesh.pick.prompt.InstructionBuilder -import cc.unitmesh.pick.picker.PickJob +import cc.unitmesh.pick.picker.InstructionJob abstract class LangWorker { - abstract fun addJob(job: PickJob) + abstract fun addJob(job: InstructionJob) abstract suspend fun start() : List } \ No newline at end of file diff --git a/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/WorkerManager.kt b/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/WorkerManager.kt index 32532618..5534b9e2 100644 --- a/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/WorkerManager.kt +++ b/unit-picker/src/main/kotlin/cc/unitmesh/pick/worker/WorkerManager.kt @@ -1,7 +1,7 @@ package cc.unitmesh.pick.worker import cc.unitmesh.pick.prompt.InstructionBuilder -import cc.unitmesh.pick.picker.PickJob +import cc.unitmesh.pick.picker.InstructionJob import org.archguard.rule.common.Language class WorkerManager { @@ -9,7 +9,7 @@ class WorkerManager { Language.JAVA to JavaLangWorker(), ) - fun addJob(job: PickJob) { + fun addJob(job: InstructionJob) { val language = job.fileSummary.language.toSupportLanguage() val worker = workers[language] worker?.addJob(job)