Skip to content

Commit

Permalink
feat(kotlin): optimize imports and refactor isService/isController me…
Browse files Browse the repository at this point in the history
…thods for better readability.

This commit optimizes the import statements and refactors the `isService` and `isController` methods for improved readability and maintainability.
  • Loading branch information
phodal committed Apr 16, 2024
1 parent 34b4a3c commit 7b8e88a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
Expand Up @@ -10,7 +10,6 @@ import com.intellij.lang.java.JavaLanguage
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.NlsSafe
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiMethod
Expand Down Expand Up @@ -83,10 +82,10 @@ open class JavaTestContextProvider : ChatContextProvider {
open fun checkIsSpringRelated(creationContext: ChatCreationContext) =
runReadAction { creationContext.element?.let { isSpringRelated(it) } ?: false }

protected fun isService(fileName: @NlsSafe String?) =
protected fun isService(fileName: String?) =
fileName?.let { MvcUtil.isService(it, langFileSuffix()) } ?: false

protected fun isController(fileName: @NlsSafe String?) =
protected fun isController(fileName: String?) =
fileName?.let { MvcUtil.isController(it, langFileSuffix()) } ?: false


Expand All @@ -103,8 +102,6 @@ open class JavaTestContextProvider : ChatContextProvider {
* and checks if the project uses JUnit 5 or JUnit 4. Based on the result, it sets the rule string
* accordingly. Finally, it adds the rule to the projectJunitCache and returns the rule string.
*/
// todo: lookup module deps
// val module = ModuleUtilCore.findModuleForPsiElement(sourceFile!!)
protected fun junitRule(project: Project): String {
if (projectJunitCache.containsKey(project)) {
return projectJunitCache[project]!!
Expand Down
Expand Up @@ -7,15 +7,8 @@ import cc.unitmesh.devti.provider.context.ChatContextProvider
import cc.unitmesh.devti.provider.context.ChatCreationContext
import cc.unitmesh.idea.context.library.SpringLibrary
import com.intellij.openapi.externalSystem.model.project.LibraryData
import com.intellij.openapi.externalSystem.model.project.ModuleDependencyData
import com.intellij.openapi.externalSystem.service.project.ProjectDataManager
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.openapi.roots.OrderEnumerator
import com.intellij.openapi.roots.OrderRootType
import com.intellij.openapi.roots.libraries.Library
import com.intellij.psi.util.CachedValuesManager
import org.jetbrains.plugins.gradle.util.GradleConstants

open class SpringContextProvider : ChatContextProvider {
Expand Down

0 comments on commit 7b8e88a

Please sign in to comment.