Skip to content

Commit

Permalink
refactor(openrewrite): remove unused code and streamline logic and cl…
Browse files Browse the repository at this point in the history
…osed #119
  • Loading branch information
phodal committed Oct 12, 2024
1 parent c3b5568 commit c667354
Showing 1 changed file with 1 addition and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class OpenRewriteFileRunService : FileRunService {

isRecipeMethod.isAccessible = true

// 调用 isRecipe 方法
val result = isRecipeMethod.invoke(fileService, psiFile) as Boolean
return result
} catch (e: Exception) {
Expand All @@ -57,41 +56,14 @@ class OpenRewriteFileRunService : FileRunService {
val configClass = config::class.java

if (configClass.name == "com.intellij.openRewrite.run.OpenRewriteRunConfiguration") {
// val expandedWorkingDirectoryField = configClass.getDeclaredField("getExpandedWorkingDirectory()")
// // method
// val expandedWorkingDirectoryMethod = configClass.getDeclaredMethod("setExpandedWorkingDirectory")
// expandedWorkingDirectoryMethod.isAccessible = true
//
//
// expandedWorkingDirectory?.let {
// if (it == virtualFile.parent.path) {
// return@firstOrNull true
// }
// }

return@firstOrNull true
} else {
return@firstOrNull false
}
} ?: return ""
// ?: run {
// val newSettings = runManager.createConfiguration(
// "", OpenRewriteRunConfigurationType.openRewriteRunConfigurationType().configurationFactories[0]
// )
// val config = newSettings.configuration as OpenRewriteRunConfiguration
// config.apply {
// activeRecipes = descriptor.name
// generatedName = ""
// workingDirectory = virtualFile.parent.path
// }
// runManager.setUniqueNameIfNeeded(newSettings)
// runManager.setTemporaryConfiguration(newSettings)
// newSettings
// }
}

if (settings == null) {
throw RuntimeException("No OpenRewrite configuration found")
return ""
}

val builder = ExecutionEnvironmentBuilder.createOrNull(DefaultRunExecutor.getRunExecutorInstance(), settings)
Expand Down

0 comments on commit c667354

Please sign in to comment.