Skip to content

Commit

Permalink
fix: fix for JavaWorker in error issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 23, 2023
1 parent 123f904 commit 897b288
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ enum class CompletionBuilderType {
/**
* generate full file code, like test code, class code, api code
*/
FULL_FILE_COMPLETION,
TEST_CODE_GEN,
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import cc.unitmesh.core.completion.CompletionBuilderType
import cc.unitmesh.core.completion.TypedIns

abstract class TypedTestIns : TypedIns {
override val type: CompletionBuilderType = CompletionBuilderType.FULL_FILE_COMPLETION
override val type: CompletionBuilderType = CompletionBuilderType.TEST_CODE_GEN
abstract val testType: TestCodeBuilderType
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fun completionBuilder(completionBuilderType: CompletionBuilderType, context: Job
CompletionBuilderType.INLINE_COMPLETION to InlineCodeCompletionBuilder(context),
CompletionBuilderType.IN_BLOCK_COMPLETION to InBlockCodeCompletionBuilder(context),
CompletionBuilderType.AFTER_BLOCK_COMPLETION to AfterBlockCodeCompletionBuilder(context),
CompletionBuilderType.FULL_FILE_COMPLETION to FullFileCodeCompletionBuilder(context),
CompletionBuilderType.TEST_CODE_GEN to TestCodeCompletionBuilder(context),
)[completionBuilderType] ?: throw SerializationException("Unknown message type: $completionBuilderType")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import cc.unitmesh.pick.worker.job.JobContext
import chapi.domain.core.CodeDataStruct
import chapi.domain.core.CodeFunction

class FullFileCodeCompletionBuilder(val context: JobContext) : CompletionBuilder {
class TestCodeCompletionBuilder(val context: JobContext) : CompletionBuilder {
override fun build(dataStruct: CodeDataStruct): List<TypedIns> {
val testIns = UnitTestService.lookup(dataStruct, context).map {
it.build(dataStruct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ data class InsPickerOption(
CompletionBuilderType.AFTER_BLOCK_COMPLETION,
CompletionBuilderType.IN_BLOCK_COMPLETION,
CompletionBuilderType.INLINE_COMPLETION,
CompletionBuilderType.FULL_FILE_COMPLETION,
CompletionBuilderType.TEST_CODE_GEN,
),
/**
* The [CodeQualityType], will be like a tree to hold the item.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ class JavaWorker(private val context: WorkerContext) : LangWorker {
finalList[it.type] = finalList[it.type]?.plus(it) ?: listOf(it)
}

val result = finalList.values.map { it.take(context.completionTypeSize) }.flatten()
val result = finalList.keys.map {
finalList[it]?.take(context.completionTypeSize) ?: emptyList()
}.flatten()
result.map {
instructions.add(it.unique())
outputFile.appendText(it.toString() + "\n")
Expand Down

0 comments on commit 897b288

Please sign in to comment.