diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/run/ShireRunConfigurationProfileState.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/run/ShireRunConfigurationProfileState.kt index f7c56c86e..935e3c185 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/run/ShireRunConfigurationProfileState.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/run/ShireRunConfigurationProfileState.kt @@ -65,11 +65,7 @@ open class ShireRunConfigurationProfileState( console!!.attachToProcess(processHandler) - var shireFile: ShireFile? = ShireFile.lookup(myProject, configuration.getScriptPath()) - if (shireFile == null) { - shireFile = tryLoadFromDataContext() - } - + val shireFile: ShireFile? = ShireFile.lookup(myProject, configuration.getScriptPath()) if (shireFile == null) { console!!.print("File not found: ${configuration.getScriptPath()}", ConsoleViewContentType.ERROR_OUTPUT) processHandler.exitWithError() @@ -118,15 +114,6 @@ open class ShireRunConfigurationProfileState( return DefaultExecutionResult(console, processHandler) } - private fun tryLoadFromDataContext(): ShireFile? { - val dataContext = DataManager.getInstance().dataContextFromFocusAsync.blockingGet(10000) - ?: throw IllegalStateException("No data context found") - - val data = SimpleDataContext.getProjectContext(myProject).getData(SHIRE_VIRTUAL_KEY) - - return dataContext.getData(SHIRE_VIRTUAL_KEY) ?: data - } - override fun dispose() { console?.dispose() executionConsole?.dispose() diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/runner/ShireFileRunService.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/runner/ShireFileRunService.kt index 350987321..37b1c1a5c 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/runner/ShireFileRunService.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/runner/ShireFileRunService.kt @@ -56,13 +56,6 @@ class ShireFileRunService : FileRunService { val shireConfiguration = setting.configuration as ShireConfiguration shireConfiguration.name = virtualFile.nameWithoutExtension - - if (virtualFile is LightVirtualFile) { - val dataContext = SimpleDataContext.builder() - .add(ShireRunConfigurationProfileState.SHIRE_VIRTUAL_KEY, psiFile).build() - - } - shireConfiguration.setScriptPath(virtualFile.path) runManager.setTemporaryConfiguration(setting) diff --git a/src/main/kotlin/com/phodal/shire/marketplace/ui/MarketplaceView.kt b/src/main/kotlin/com/phodal/shire/marketplace/ui/MarketplaceView.kt index 20ea187c0..d04f62c77 100644 --- a/src/main/kotlin/com/phodal/shire/marketplace/ui/MarketplaceView.kt +++ b/src/main/kotlin/com/phodal/shire/marketplace/ui/MarketplaceView.kt @@ -1,5 +1,7 @@ package com.phodal.shire.marketplace.ui +import com.intellij.ide.scratch.ScratchRootType +import com.intellij.lang.Language import com.intellij.openapi.Disposable import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage @@ -42,8 +44,17 @@ class MarketplaceView(val project: Project) : Disposable { return } - val file = LightVirtualFile("temp.shire", prompt) - FileRunService.provider(project, file)?.runFile(project, file, null) + val createScratchFile = ScratchRootType.getInstance().createScratchFile( + project, + "shire-temp.shire", + Language.findLanguageByID("Shire"), + prompt + ) + + val file = createScratchFile!! + val result = FileRunService.provider(project, file)?.runFile(project, file, null) + // delete scracth file? + println(result) } }) val borderPanel = JPanel(BorderLayout())