Skip to content

Commit

Permalink
docs: thinking in language worker
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 6, 2023
1 parent 614ef7c commit cf829d8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package cc.unitmesh.pick.picker

import cc.unitmesh.pick.worker.WorkerDispatch
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.archguard.action.checkout.GitSourceSettings
import org.archguard.action.checkout.executeGitCheckout
import java.nio.file.Files
import java.nio.file.Path
import kotlin.coroutines.coroutineContext

class CodePicker(val config: PickerConfig) {
private val logger = org.slf4j.LoggerFactory.getLogger(javaClass)
Expand All @@ -31,13 +30,13 @@ class CodePicker(val config: PickerConfig) {
}
launch {
for (fileJob in walkdirChannel) {
// todo call by language worker
println(fileJob)
WorkerDispatch.worker(fileJob)
}
}
}

logger.info("stop picker")

// 3. generate tree to jsonl
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package cc.unitmesh.pick.worker

abstract class AbstractWorker {
abstract suspend fun start(filePath: String)
abstract suspend fun start()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cc.unitmesh.pick.worker

import cc.unitmesh.pick.picker.PickJob
import kotlinx.coroutines.coroutineScope
import org.archguard.scanner.analyser.count.FileJob

Expand All @@ -17,11 +18,11 @@ import org.archguard.scanner.analyser.count.FileJob
* - by Horizontal (with Import File):
* - by Vertical (with History Change):
*/
class JavaFileWorker : AbstractWorker() {
class JavaFileWorker(val job: PickJob) : AbstractWorker() {
val packageTree: Map<String, FileJob> = mapOf()
/// [Coco](https://github.com/inherd/coco) high change and long line, means is important file, and need to be checked.

override suspend fun start(filePath: String) = coroutineScope {
override suspend fun start() = coroutineScope {
// 1. read directory to a collection of files for FileJob

// 2. check package information from line 1?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package cc.unitmesh.pick.worker

import cc.unitmesh.pick.picker.PickJob

object WorkerDispatch {
/**
* Dispatch language worker by language
*/
fun worker(language: String): AbstractWorker? {
return when (language) {
"Java" -> JavaFileWorker()
fun worker(job: PickJob): AbstractWorker? {
return when (job.language.lowercase()) {
"java" -> JavaFileWorker(job)
else -> null
}
}
Expand Down

0 comments on commit cf829d8

Please sign in to comment.