Skip to content

Commit b9fa651

Browse files
committed
refactor(shirelang): simplify variable handling and remove unused imports
- Replace `var` with `val` in `UserCustomVariableResolver` for immutability. - Remove unused imports and redundant code in `ShireFileRunService`.
1 parent 510965e commit b9fa651

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

shirelang/src/main/kotlin/com/phodal/shirelang/compiler/variable/resolver/UserCustomVariableResolver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class UserCustomVariableResolver(
88
private val context: VariableResolverContext
99
) : VariableResolver {
1010
override suspend fun resolve(initVariables: Map<String, Any>): Map<String, String> {
11-
var vars: MutableMap<String, Any?> = initVariables.toMutableMap()
11+
val vars: MutableMap<String, Any?> = initVariables.toMutableMap()
1212
return context.hole?.variables?.mapValues {
1313
PatternActionProcessor(context.myProject, context.hole, vars).execute(it.value)
1414
} ?: emptyMap()

shirelang/src/main/kotlin/com/phodal/shirelang/runner/ShireFileRunService.kt

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ import com.intellij.openapi.application.runReadAction
88
import com.intellij.openapi.project.Project
99
import com.intellij.openapi.vfs.VirtualFile
1010
import com.intellij.psi.PsiElement
11-
import com.phodal.shirecore.config.InteractionType
12-
import com.phodal.shirecore.config.ShireActionLocation
1311
import com.phodal.shirecore.provider.shire.FileRunService
14-
import com.phodal.shirelang.ShireBundle
1512
import com.phodal.shirelang.actions.ShireRunFileAction.Companion.executeFile
1613
import com.phodal.shirelang.actions.base.DynamicShireActionConfig
17-
import com.phodal.shirelang.compiler.ast.hobbit.HobbitHole
1814
import com.phodal.shirelang.psi.ShireFile
1915
import com.phodal.shirelang.run.ShireConfiguration
2016
import com.phodal.shirelang.run.ShireConfigurationType
@@ -50,25 +46,11 @@ class ShireFileRunService : FileRunService, Disposable {
5046

5147
return setting
5248
}
53-
54-
/**
55-
* Create ChatBox Run
56-
*/
5749
override fun runFile(project: Project, virtualFile: VirtualFile, psiElement: PsiElement?): String? {
5850
val settings = createRunSettings(project, virtualFile, psiElement) ?: return null
5951
val psiFile = ShireFile.lookup(project, virtualFile) ?: return null
6052

61-
var config = DynamicShireActionConfig.from(psiFile)
62-
if (config.hole == null) {
63-
config = config.copy(
64-
hole = HobbitHole.create(
65-
ShireBundle.message("shire.actions.chat-box"),
66-
ShireBundle.message("shire.actions.run-from-chat-box"),
67-
InteractionType.RightPanel,
68-
ShireActionLocation.CHAT_BOX
69-
)
70-
)
71-
}
53+
val config = DynamicShireActionConfig.from(psiFile)
7254

7355
executeFile(project, config, settings)
7456
return "Running Shire file: ${virtualFile.name}"

0 commit comments

Comments
 (0)