Clean up declarations of runReadAction() etc
This commit is contained in:
@@ -144,7 +144,7 @@ public class KotlinPsiSearchHelper(private val project: Project): PsiSearchHelpe
|
||||
FileBasedIndex.getInstance().processFilesContainingAllKeys(IdIndex.NAME, entries, scope, checker) { file ->
|
||||
!index.shouldBeFound(scope, file) || processor.process(file)
|
||||
}
|
||||
}!!
|
||||
}
|
||||
}
|
||||
|
||||
public fun processFilesWithText(item: UsagesSearchRequestItem, consumer: Processor<PsiReference>): Boolean {
|
||||
|
||||
@@ -20,20 +20,21 @@ import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.command.CommandProcessor
|
||||
|
||||
public fun runReadAction<T: Any>(action: () -> T?): T? {
|
||||
return ApplicationManager.getApplication()?.runReadAction<T>(action)
|
||||
public fun runReadAction<T>(action: () -> T): T {
|
||||
return ApplicationManager.getApplication().runReadAction<T>(action)
|
||||
}
|
||||
|
||||
public fun runWriteAction<T: Any>(action: () -> T?): T? {
|
||||
return ApplicationManager.getApplication()?.runWriteAction<T>(action)
|
||||
public fun runWriteAction<T>(action: () -> T): T {
|
||||
return ApplicationManager.getApplication().runWriteAction<T>(action)
|
||||
}
|
||||
|
||||
public fun Project.executeWriteCommand(name: String, command: () -> Unit) {
|
||||
CommandProcessor.getInstance().executeCommand(this, { runWriteAction(command) }, name, null)
|
||||
}
|
||||
|
||||
public fun <T: Any> Project.executeWriteCommand(name: String, command: () -> T): T {
|
||||
var result: T? = null
|
||||
public fun <T> Project.executeWriteCommand(name: String, command: () -> T): T {
|
||||
var result: T = null as T
|
||||
CommandProcessor.getInstance().executeCommand(this, { result = runWriteAction(command) }, name, null)
|
||||
return result!!
|
||||
[suppress("USELESS_CAST")]
|
||||
return result as T
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public object ProjectRootsUtil {
|
||||
|
||||
val project = element.getProject()
|
||||
return@runReadAction isInSources(project, virtualFile, includeLibrarySources, withLibraryClassesRoots)
|
||||
}!!
|
||||
}
|
||||
}
|
||||
|
||||
platformStatic
|
||||
|
||||
@@ -221,7 +221,7 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
|
||||
}
|
||||
}
|
||||
parameters
|
||||
}!!
|
||||
}
|
||||
}
|
||||
|
||||
private fun EvaluationContextImpl.getArgumentsForEval4j(parameterNames: List<String>, parameterTypes: Array<Type>): List<Value> {
|
||||
@@ -246,7 +246,7 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
|
||||
KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION)
|
||||
|
||||
state.getFactory()
|
||||
}!!
|
||||
}
|
||||
}
|
||||
|
||||
private fun exception(msg: String) = throw EvaluateExceptionUtil.createEvaluateException(msg)
|
||||
@@ -328,7 +328,7 @@ fun EvaluationContextImpl.findLocalVariable(name: String, asmType: Type?, checkT
|
||||
|
||||
val thisDesc = value.asmType.getClassDescriptor(project)
|
||||
val expDesc = asmType.getClassDescriptor(project)
|
||||
return thisDesc != null && expDesc != null && runReadAction { DescriptorUtils.isSubclass(thisDesc, expDesc) }!!
|
||||
return thisDesc != null && expDesc != null && runReadAction { DescriptorUtils.isSubclass(thisDesc, expDesc) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public class KotlinFindClassUsagesHandler(
|
||||
val declarationUsages = kotlinOptions.toClassDeclarationsHelper().newRequest(target).search()
|
||||
|
||||
(classUsages + declarationUsages).all { ref -> KotlinFindUsagesHandler.processUsage(processor, ref) } && processInheritors()
|
||||
}!!
|
||||
}
|
||||
}
|
||||
|
||||
protected override fun isSearchForTextOccurencesAvailable(psiElement: PsiElement, isSingleFile: Boolean): Boolean {
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class KotlinTypeParameterFindUsagesHandler(
|
||||
val target = options.toSearchTarget(element as JetNamedDeclaration, true)
|
||||
val request = DefaultSearchHelper<JetNamedDeclaration>().newRequest(target)
|
||||
request.search().all { ref -> KotlinFindUsagesHandler.processUsage(processor, ref) }
|
||||
}!!
|
||||
}
|
||||
}
|
||||
|
||||
public override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions {
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() {
|
||||
val jetProperty = element?.namedUnwrappedElement as? JetProperty
|
||||
if (jetProperty == null) throw IllegalStateException("Can't be for element $element there because of canProcessElement()")
|
||||
|
||||
val propertyMethods = runReadAction { LightClassUtil.getLightClassPropertyMethods(jetProperty) }!!
|
||||
val propertyMethods = runReadAction { LightClassUtil.getLightClassPropertyMethods(jetProperty) }
|
||||
|
||||
for (propertyMethod in propertyMethods) {
|
||||
addRenameElements(propertyMethod, jetProperty.getName(), newName, allRenames, scope)
|
||||
|
||||
@@ -128,6 +128,6 @@ public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestBase() {
|
||||
else -> BasicStepMethodFilter(stepTarget.getMethod(), stepTarget.getCallingExpressionLines())
|
||||
}
|
||||
}
|
||||
}!!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public abstract class AbstractJetMoveTest : MultiFileTestCase() {
|
||||
}
|
||||
|
||||
offset
|
||||
}!!
|
||||
}
|
||||
}
|
||||
|
||||
val config = JsonParser().parse(FileUtil.loadFile(File(path), true)) as JsonObject
|
||||
|
||||
@@ -62,7 +62,7 @@ class RunConfigurationTest: CodeInsightTestCase() {
|
||||
fun testDependencyModuleClasspath() {
|
||||
val dependencyModuleSrcDir = configureModule(moduleDirPath("module"), getTestProject().getBaseDir()!!).src
|
||||
|
||||
val moduleWithDependencyDir = runWriteAction { getTestProject().getBaseDir()!!.createChildDirectory(this, "moduleWithDependency") }!!
|
||||
val moduleWithDependencyDir = runWriteAction { getTestProject().getBaseDir()!!.createChildDirectory(this, "moduleWithDependency") }
|
||||
|
||||
val moduleWithDependency = createModule("moduleWithDependency")
|
||||
ModuleRootModificationUtil.setModuleSdk(moduleWithDependency, getTestProjectJdk())
|
||||
@@ -109,7 +109,7 @@ class RunConfigurationTest: CodeInsightTestCase() {
|
||||
PsiTestUtil.setCompilerOutputPath(configModule, testOutDir.getUrl(), true)
|
||||
|
||||
Pair(srcOutDir, testOutDir)
|
||||
}!!
|
||||
}
|
||||
|
||||
PsiDocumentManager.getInstance(getTestProject()).commitAllDocuments()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user