From 25cb1c1c155c032e3c708dfb9c92633bd66f3f30 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Mon, 11 Nov 2024 13:45:15 +0800 Subject: [PATCH] refactor(kotlin): update living documentation provider comment style --- .../devti/intentions/action/task/LivingDocPromptBuilder.kt | 6 ++++-- .../cc/unitmesh/devti/provider/LivingDocumentation.kt | 2 +- .../unitmesh/go/provider/GoLivingDocumentationProvider.kt | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/kotlin/cc/unitmesh/devti/intentions/action/task/LivingDocPromptBuilder.kt b/core/src/main/kotlin/cc/unitmesh/devti/intentions/action/task/LivingDocPromptBuilder.kt index 4f0deb15c2..e7922ade8f 100644 --- a/core/src/main/kotlin/cc/unitmesh/devti/intentions/action/task/LivingDocPromptBuilder.kt +++ b/core/src/main/kotlin/cc/unitmesh/devti/intentions/action/task/LivingDocPromptBuilder.kt @@ -135,9 +135,11 @@ open class LivingDocPromptBuilder( instruction.append("```${target.language.displayName}\n${target.text}\n```") val startEndString = documentation.startEndString(type) - instruction.append(documentation.forbiddenRules.joinToString { "\n- $it" }) + if (startEndString != null) { + instruction.append("\n\nStart your documentation with ${startEndString.first} here, and ends with `${startEndString.second}`.\n") + } - instruction.append("\n\nStart your documentation with ${startEndString.first} here, and ends with `${startEndString.second}`.\n") + instruction.append(documentation.forbiddenRules.joinToString { "\n- $it" }) instruction.toString() } } diff --git a/core/src/main/kotlin/cc/unitmesh/devti/provider/LivingDocumentation.kt b/core/src/main/kotlin/cc/unitmesh/devti/provider/LivingDocumentation.kt index e47f3c687a..d7625c562f 100644 --- a/core/src/main/kotlin/cc/unitmesh/devti/provider/LivingDocumentation.kt +++ b/core/src/main/kotlin/cc/unitmesh/devti/provider/LivingDocumentation.kt @@ -20,7 +20,7 @@ interface LivingDocumentation { val parameterTagInstruction: String? get() = null val returnTagInstruction: String? get() = null - fun startEndString(type: LivingDocumentationType): Pair + fun startEndString(type: LivingDocumentationType): Pair? fun updateDoc(target: PsiElement, newDoc: String, type: LivingDocumentationType, editor: Editor) diff --git a/goland/src/main/kotlin/cc/unitmesh/go/provider/GoLivingDocumentationProvider.kt b/goland/src/main/kotlin/cc/unitmesh/go/provider/GoLivingDocumentationProvider.kt index 21b5a5cf4a..5f37c58499 100644 --- a/goland/src/main/kotlin/cc/unitmesh/go/provider/GoLivingDocumentationProvider.kt +++ b/goland/src/main/kotlin/cc/unitmesh/go/provider/GoLivingDocumentationProvider.kt @@ -19,7 +19,7 @@ class GoLivingDocumentationProvider : LivingDocumentation { "Do not mention the containing package", ) - override fun startEndString(type: LivingDocumentationType): Pair = "/*" to "*/" + override fun startEndString(type: LivingDocumentationType): Pair? = null override fun updateDoc(target: PsiElement, newDoc: String, type: LivingDocumentationType, editor: Editor) { val project = runReadAction { target.project }