Skip to content

Commit

Permalink
refactor(test): improve prompter message
Browse files Browse the repository at this point in the history
- Refactored the prompter message in the `TestCodeGenTask.kt` file to provide more detailed information about the current class and the code being generated.
- Added a section to display the current class information and the code being generated.
- Improved the formatting and readability of the prompter message.
  • Loading branch information
phodal committed Jan 12, 2024
1 parent 1c5bad0 commit 4dbe802
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,25 @@ class TestCodeGenTask(val request: TestCodeGenRequest) :
}

if (testContext.currentClass != null) {
prompter += "\n"
prompter += "// here is current class information:\n"
prompter += runReadAction { testContext.currentClass.format() }
val currentClassInfo = runReadAction { testContext.currentClass.format() }
prompter += """
// here is current class information:
$currentClassInfo
""".trimIndent()
}


prompter += "\nCode:\n"
prompter += testContext.imports.joinToString("\n") {
val importString = testContext.imports.joinToString("\n") {
"// $it"
}

prompter += "\n```${lang.lowercase()}\n${request.selectText}\n```"
prompter += """
Code:
$importString
```${lang.lowercase()}
${request.selectText}
```
""".trimIndent()

prompter += if (!testContext.isNewFile) {
"Start test code with `@Test` syntax here: \n"
} else {
Expand Down

0 comments on commit 4dbe802

Please sign in to comment.