Skip to content

Commit cdacf15

Browse files
committed
refactor(custom-action): simplify regex check and prompt methods
Remove redundant variable declarations and inline regex creation. Simplify prompt method implementations for better readability.
1 parent 22ec6fa commit cdacf15

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

core/src/main/kotlin/cc/unitmesh/devti/custom/CustomActionBaseIntention.kt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ class CustomActionBaseIntention(private val intentionConfig: CustomIntentionConf
2929
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?): Boolean {
3030
if (editor == null || file == null) return false
3131

32-
val regexString = intentionConfig.matchRegex
3332
return try {
34-
val regex = Regex(regexString)
35-
regex.matches(file.name)
33+
Regex(intentionConfig.matchRegex).matches(file.name)
3634
} catch (e: Exception) {
3735
false
3836
}
@@ -53,13 +51,8 @@ class CustomActionBaseIntention(private val intentionConfig: CustomIntentionConf
5351

5452
if (intentionConfig.autoInvoke) {
5553
sendToChatPanel(project, getActionType(), object : ContextPrompter() {
56-
override fun displayPrompt(): String {
57-
return prompt.displayPrompt
58-
}
59-
60-
override fun requestPrompt(): String {
61-
return prompt.requestPrompt
62-
}
54+
override fun displayPrompt(): String = prompt.displayPrompt
55+
override fun requestPrompt(): String = prompt.requestPrompt
6356
})
6457
} else {
6558
sendToChatPanel(project) { panel, _ ->

0 commit comments

Comments
 (0)