mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-CR-3497 it's better to use verb in method name to make it clearer what it does, i.e. it would be better to rename this method to 'runWriteAction'.
add javadoc to avoid "exposes Function0 class from Kotlin stdlib to public API, it's forbidden for now"
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package org.jetbrains.ide
|
||||
|
||||
import com.intellij.openapi.application.invokeAndWaitIfNeed
|
||||
import com.intellij.openapi.application.writeAction
|
||||
import com.intellij.openapi.application.runWriteAction
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
||||
import com.intellij.openapi.util.io.FileUtilRt
|
||||
@@ -68,7 +68,7 @@ class TestManager(val projectFixture: IdeaProjectTestFixture) : TestWatcher() {
|
||||
val normalizedFilePath = FileUtilRt.toSystemIndependentName(filePath!!)
|
||||
if (annotation!!.relativeToProject) {
|
||||
val root = projectFixture.getProject().getBaseDir()
|
||||
writeAction {
|
||||
runWriteAction {
|
||||
fileToDelete = root.findOrCreateChildData(this@TestManager, normalizedFilePath)
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class TestManager(val projectFixture: IdeaProjectTestFixture) : TestWatcher() {
|
||||
ModuleRootModificationUtil.updateModel(projectFixture.getModule()) { model ->
|
||||
val contentEntry = model.getContentEntries()[0]
|
||||
val contentRoot = contentEntry.getFile()!!
|
||||
writeAction {
|
||||
runWriteAction {
|
||||
contentRoot.findChild(EXCLUDED_DIR_NAME)?.delete(this@TestManager)
|
||||
fileToDelete = contentRoot.createChildDirectory(this@TestManager, EXCLUDED_DIR_NAME)
|
||||
fileToDelete!!.createChildData(this@TestManager, normalizedFilePath)
|
||||
@@ -89,7 +89,7 @@ class TestManager(val projectFixture: IdeaProjectTestFixture) : TestWatcher() {
|
||||
}
|
||||
else {
|
||||
val root = ModuleRootManager.getInstance(projectFixture.getModule()).getSourceRoots()[0]
|
||||
writeAction {
|
||||
runWriteAction {
|
||||
fileToDelete = root.findOrCreateChildData(this@TestManager, normalizedFilePath)
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ class TestManager(val projectFixture: IdeaProjectTestFixture) : TestWatcher() {
|
||||
}
|
||||
|
||||
if (fileToDelete != null) {
|
||||
invokeAndWaitIfNeed { writeAction { fileToDelete?.delete(this@TestManager) } }
|
||||
invokeAndWaitIfNeed { runWriteAction { fileToDelete?.delete(this@TestManager) } }
|
||||
fileToDelete = null
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@ package com.intellij.openapi.application
|
||||
|
||||
import javax.swing.SwingUtilities
|
||||
|
||||
public inline fun writeAction(runnable: () -> Unit) {
|
||||
/**
|
||||
* @exclude Internal use only
|
||||
*/
|
||||
public inline fun runWriteAction(runnable: () -> Unit) {
|
||||
val token = WriteAction.start()
|
||||
try {
|
||||
runnable()
|
||||
@@ -27,6 +30,9 @@ public inline fun writeAction(runnable: () -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @exclude Internal use only
|
||||
*/
|
||||
public fun invokeAndWaitIfNeed(runnable: () -> Unit) {
|
||||
val app = ApplicationManager.getApplication()
|
||||
if (app == null) {
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.intellij.openapi.application.AccessToken
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.WriteAction
|
||||
import com.intellij.openapi.application.ex.DecodeDefaultsUtil
|
||||
import com.intellij.openapi.application.writeAction
|
||||
import com.intellij.openapi.application.runWriteAction
|
||||
import com.intellij.openapi.components.RoamingType
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.components.impl.stores.DirectoryBasedStorage
|
||||
@@ -527,7 +527,8 @@ public class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(private val
|
||||
if (renamed) {
|
||||
file = dir.findChild(externalInfo!!.fileName)
|
||||
if (file != null) {
|
||||
writeAction {
|
||||
runWriteAction { }
|
||||
runWriteAction {
|
||||
file!!.rename(this, fileName)
|
||||
}
|
||||
}
|
||||
@@ -537,7 +538,7 @@ public class SchemeManagerImpl<T : Scheme, E : ExternalizableScheme>(private val
|
||||
file = DirectoryBasedStorage.getFile(fileName, dir, this)
|
||||
}
|
||||
|
||||
writeAction {
|
||||
runWriteAction {
|
||||
file!!.getOutputStream(this).use {
|
||||
byteOut.writeTo(it)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user