Skip to content

Commit

Permalink
fix: fix class empty issues
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Apr 17, 2023
1 parent 7e64357 commit a9cf9be
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/main/kotlin/cc/unitmesh/devti/DevtiFlow.kt
Expand Up @@ -39,12 +39,11 @@ class DevtiFlow(
*/
fun updateEndpointMethod(target: TargetEndpoint, storyDetail: String) {
// 3. update endpoint method
val code = fetchCode(target.endpoint, target.controller, storyDetail)
try {
val code = fetchCode(target.endpoint, target.controller, storyDetail)
processor?.createControllerOrUpdateMethod(target.controller.name, code, target.hasMatchedController)
} catch (e: Exception) {
logger.warn("update method failed: $e")
logger.warn("try to fill update method 2nd")
logger.warn("update method failed: $e, try to fill update method 2nd")

val code = fetchCode(target.endpoint, target.controller, storyDetail)
processor?.createControllerOrUpdateMethod(target.controller.name, code, target.hasMatchedController)
Expand Down
12 changes: 7 additions & 5 deletions src/main/kotlin/cc/unitmesh/devti/analysis/DtAnalysisModel.kt
Expand Up @@ -26,11 +26,13 @@ class DtClass(
output.append(")\n")
}

output.append("- methods: ")
// filter out constructor
output.append(methods.filter { it.name != this.name }.joinToString(", ") { method ->
"${method.name}(${method.parameters.joinToString(", ") { parameter -> "${parameter.name}: ${parameter.type}" }}): ${method.returnType}"
})
if (methods.isNotEmpty()) {
output.append("- methods: ")
// filter out constructor
output.append(methods.filter { it.name != this.name }.joinToString(", ") { method ->
"${method.name}(${method.parameters.joinToString(", ") { parameter -> "${parameter.name}: ${parameter.type}" }}): ${method.returnType}"
})
}

return output.toString()
}
Expand Down
Expand Up @@ -98,7 +98,7 @@ class JavaCrudProcessor(val project: Project) : CrudProcessor {
}

override fun createControllerOrUpdateMethod(targetController: String, code: String, isControllerExist: Boolean) {
if (controllers.isEmpty()) {
if (!isControllerExist) {
this.createController(targetController, code)
return
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/cc/unitmesh/devti/runconfig/DtRunState.kt
Expand Up @@ -2,6 +2,7 @@ package cc.unitmesh.devti.runconfig

import cc.unitmesh.devti.DevtiBundle
import cc.unitmesh.devti.DevtiFlow
import cc.unitmesh.devti.analysis.DtClass
import cc.unitmesh.devti.analysis.JavaCrudProcessor
import cc.unitmesh.devti.kanban.impl.GitHubIssue
import cc.unitmesh.devti.prompt.openai.OpenAIAction
Expand Down Expand Up @@ -50,6 +51,9 @@ class DtRunState(

indicator.text = DevtiBundle.message("devti.runconfig.progress.fetchingSuggestEndpoint")
val target = devtiFlow.fetchSuggestEndpoint(storyDetail)
if (!target.hasMatchedController) {
target.controller = DtClass(target.controller.name, emptyList())
}

indicator.fraction = 0.6

Expand Down

0 comments on commit a9cf9be

Please sign in to comment.