Skip to content

Commit 7b8e88a

Browse files
committed
feat(kotlin): optimize imports and refactor isService/isController methods for better readability.
This commit optimizes the import statements and refactors the `isService` and `isController` methods for improved readability and maintainability.
1 parent 34b4a3c commit 7b8e88a

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

java/src/main/kotlin/cc/unitmesh/idea/provider/JavaTestContextProvider.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import com.intellij.lang.java.JavaLanguage
1010
import com.intellij.openapi.application.runReadAction
1111
import com.intellij.openapi.components.service
1212
import com.intellij.openapi.project.Project
13-
import com.intellij.openapi.util.NlsSafe
1413
import com.intellij.psi.PsiClass
1514
import com.intellij.psi.PsiElement
1615
import com.intellij.psi.PsiMethod
@@ -83,10 +82,10 @@ open class JavaTestContextProvider : ChatContextProvider {
8382
open fun checkIsSpringRelated(creationContext: ChatCreationContext) =
8483
runReadAction { creationContext.element?.let { isSpringRelated(it) } ?: false }
8584

86-
protected fun isService(fileName: @NlsSafe String?) =
85+
protected fun isService(fileName: String?) =
8786
fileName?.let { MvcUtil.isService(it, langFileSuffix()) } ?: false
8887

89-
protected fun isController(fileName: @NlsSafe String?) =
88+
protected fun isController(fileName: String?) =
9089
fileName?.let { MvcUtil.isController(it, langFileSuffix()) } ?: false
9190

9291

@@ -103,8 +102,6 @@ open class JavaTestContextProvider : ChatContextProvider {
103102
* and checks if the project uses JUnit 5 or JUnit 4. Based on the result, it sets the rule string
104103
* accordingly. Finally, it adds the rule to the projectJunitCache and returns the rule string.
105104
*/
106-
// todo: lookup module deps
107-
// val module = ModuleUtilCore.findModuleForPsiElement(sourceFile!!)
108105
protected fun junitRule(project: Project): String {
109106
if (projectJunitCache.containsKey(project)) {
110107
return projectJunitCache[project]!!

java/src/main/kotlin/cc/unitmesh/idea/provider/SpringContextProvider.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,8 @@ import cc.unitmesh.devti.provider.context.ChatContextProvider
77
import cc.unitmesh.devti.provider.context.ChatCreationContext
88
import cc.unitmesh.idea.context.library.SpringLibrary
99
import com.intellij.openapi.externalSystem.model.project.LibraryData
10-
import com.intellij.openapi.externalSystem.model.project.ModuleDependencyData
1110
import com.intellij.openapi.externalSystem.service.project.ProjectDataManager
12-
import com.intellij.openapi.module.Module
1311
import com.intellij.openapi.project.Project
14-
import com.intellij.openapi.roots.ModuleRootManager
15-
import com.intellij.openapi.roots.OrderEnumerator
16-
import com.intellij.openapi.roots.OrderRootType
17-
import com.intellij.openapi.roots.libraries.Library
18-
import com.intellij.psi.util.CachedValuesManager
1912
import org.jetbrains.plugins.gradle.util.GradleConstants
2013

2114
open class SpringContextProvider : ChatContextProvider {

0 commit comments

Comments
 (0)