User: kyle wood Date: 16 Nov 25 19:56 Revision: 3bdbaafc60fc9cdb66ef214fdd358634edae9c39 Summary: Try to fix write-unsafe context with old API instead of coroutine Fixes: MCDEV-3Q TeamCity URL: http://ci.mcdev.io:80/viewModification.html?tab=vcsModificationFiles&modId=10309&personal=false Index: src/main/kotlin/creator/custom/CustomPlatformStep.kt =================================================================== --- src/main/kotlin/creator/custom/CustomPlatformStep.kt (revision db39fda52f5198de46b0bbcf9cba8f46749f7bb2) +++ src/main/kotlin/creator/custom/CustomPlatformStep.kt (revision 3bdbaafc60fc9cdb66ef214fdd358634edae9c39) @@ -67,7 +67,7 @@ val creatorUiScope = TemplateService.instance.scope("MinecraftDev Creator UI") val templateRepos = MinecraftSettings.instance.creatorTemplateRepos - val templateRepoProperty = propertyGraph.property( + val templateRepoProperty = propertyGraph.property( templateRepos.firstOrNull() ?: MinecraftSettings.TemplateRepo.makeBuiltinRepo() ) var templateRepo by templateRepoProperty @@ -79,19 +79,19 @@ lateinit var availableGroupsSegmentedButton: SegmentedButton lateinit var availableTemplatesSegmentedButton: SegmentedButton - val selectedGroupProperty = propertyGraph.property("") + val selectedGroupProperty = propertyGraph.property("") var selectedGroup by selectedGroupProperty val selectedTemplateProperty = propertyGraph.property(EmptyLoadedTemplate) var selectedTemplate by selectedTemplateProperty - val templateProvidersLoadingProperty = propertyGraph.property(true) + val templateProvidersLoadingProperty = propertyGraph.property(true) val templateProvidersTextProperty = propertyGraph.property("") val templateProvidersText2Property = propertyGraph.property("") lateinit var templateProvidersProcessIcon: Cell - val templateLoadingProperty = propertyGraph.property(false) - val templateLoadingTextProperty = propertyGraph.property("") - val templateLoadingText2Property = propertyGraph.property("") + val templateLoadingProperty = propertyGraph.property(false) + val templateLoadingTextProperty = propertyGraph.property("") + val templateLoadingText2Property = propertyGraph.property("") lateinit var templatePropertiesProcessIcon: Cell lateinit var noTemplatesAvailable: Cell var templateLoadingJob: Job? = null Index: src/main/kotlin/creator/custom/providers/RemoteTemplateProvider.kt =================================================================== --- src/main/kotlin/creator/custom/providers/RemoteTemplateProvider.kt (revision db39fda52f5198de46b0bbcf9cba8f46749f7bb2) +++ src/main/kotlin/creator/custom/providers/RemoteTemplateProvider.kt (revision 3bdbaafc60fc9cdb66ef214fdd358634edae9c39) @@ -144,7 +144,7 @@ return doLoadTemplates(context, repo, remoteRepo.innerPath) } - protected suspend fun doLoadTemplates( + protected fun doLoadTemplates( context: WizardContext, repo: MinecraftSettings.TemplateRepo, rawInnerPath: String @@ -267,7 +267,7 @@ index: Int, isSelected: Boolean, cellHasFocus: Boolean - ): Component? { + ): Component { text = value?.displayname?.let(MCDevBundle::invoke) ?: value?.name?.capitalize().toString() return this } Index: src/main/kotlin/creator/custom/providers/TemplateProvider.kt =================================================================== --- src/main/kotlin/creator/custom/providers/TemplateProvider.kt (revision db39fda52f5198de46b0bbcf9cba8f46749f7bb2) +++ src/main/kotlin/creator/custom/providers/TemplateProvider.kt (revision 3bdbaafc60fc9cdb66ef214fdd358634edae9c39) @@ -46,8 +46,6 @@ import com.intellij.util.xmlb.annotations.Attribute import java.util.ResourceBundle import javax.swing.JComponent -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.runBlocking /** * Extensions responsible for creating a [TemplateDescriptor] based on whatever data it is provided in its configuration @@ -75,13 +73,12 @@ fun getAllKeys() = EP_NAME.extensionList.mapNotNull { it.key } - suspend fun findTemplates( + fun findTemplates( modalityState: ModalityState, repoRoot: VirtualFile, templates: MutableList = mutableListOf(), - bundle: ResourceBundle? = null + bundle: ResourceBundle? = loadMessagesBundle(modalityState, repoRoot) ): List { - val bundle = bundle ?: loadMessagesBundle(modalityState, repoRoot) val templatesToLoad = mutableListOf() val visitor = object : VirtualFileVisitor() { override fun visitFile(file: VirtualFile): Boolean { @@ -117,7 +114,7 @@ return templates } - suspend fun loadMessagesBundle(modalityState: ModalityState, repoRoot: VirtualFile): ResourceBundle? = try { + fun loadMessagesBundle(modalityState: ModalityState, repoRoot: VirtualFile): ResourceBundle? = try { val locale = DynamicBundle.getLocale() // Simplified bundle resolution, but covers all the most common cases val baseBundle = doLoadMessageBundle( @@ -144,7 +141,7 @@ null } - private suspend fun doLoadMessageBundle( + private fun doLoadMessageBundle( file: VirtualFile?, modalityState: ModalityState, parent: ResourceBundle? @@ -167,7 +164,7 @@ return parent } - suspend fun createVfsLoadedTemplate( + fun createVfsLoadedTemplate( modalityState: ModalityState, templateRoot: VirtualFile, descriptorFile: VirtualFile, @@ -194,7 +191,7 @@ descriptor.translateOrNull("platform.${labelKey.lowercase()}.label") ?: descriptor.translate(labelKey) if (descriptor.inherit != null) { - val parent = templateRoot.findFileByRelativePath(descriptor.inherit!!) + val parent = templateRoot.findFileByRelativePath(descriptor.inherit) if (parent != null) { parent.refresh(false, false) val parentDescriptor = Gson().fromJson(parent.readText()) @@ -231,5 +228,5 @@ override fun getKey(): String = name - override fun getImplementationClassName(): String? = implementation + override fun getImplementationClassName(): String = implementation } Index: src/main/kotlin/util/files.kt =================================================================== --- src/main/kotlin/util/files.kt (revision db39fda52f5198de46b0bbcf9cba8f46749f7bb2) +++ src/main/kotlin/util/files.kt (revision 3bdbaafc60fc9cdb66ef214fdd358634edae9c39) @@ -22,7 +22,6 @@ import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ModalityState -import com.intellij.openapi.application.writeAction import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VfsUtilCore import com.intellij.openapi.vfs.VirtualFile @@ -79,7 +78,7 @@ operator fun Manifest.get(attribute: String): String? = mainAttributes.getValue(attribute) operator fun Manifest.get(attribute: Attributes.Name): String? = mainAttributes.getValue(attribute) -suspend fun VirtualFile.refreshSync(modalityState: ModalityState): VirtualFile? { +fun VirtualFile.refreshSync(modalityState: ModalityState): VirtualFile? { fun refresh() { RefreshQueue.getInstance().refresh(false, this.isDirectory, null, modalityState, this) } @@ -87,7 +86,7 @@ if (ApplicationManager.getApplication().isWriteAccessAllowed) { refresh() } else { - writeAction { + runWriteTask { refresh() } }