From 3c41db654a78aaff1fd66004ef7c518df65dde32 Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Tue, 9 Jul 2019 20:49:21 +0300 Subject: [PATCH] Fix performance test compilation for 192 --- .../kotlin/idea/perf/projectRoutines.kt | 4 +- .../kotlin/idea/perf/projectRoutines.kt.191 | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 idea/performanceTests/org/jetbrains/kotlin/idea/perf/projectRoutines.kt.191 diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/projectRoutines.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/projectRoutines.kt index 25a38f07876..f1f627530f9 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/projectRoutines.kt +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/projectRoutines.kt @@ -13,8 +13,6 @@ import com.intellij.testFramework.EdtTestUtil import com.intellij.util.ThrowableRunnable import com.intellij.util.ui.UIUtil import org.jetbrains.kotlin.idea.parameterInfo.HintType -import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl.waitForAllEditorsFinallyLoaded -import java.util.concurrent.TimeUnit fun commitAllDocuments() { ProjectManagerEx.getInstanceEx().openProjects.forEach { project -> @@ -49,5 +47,5 @@ fun closeProject(project: Project) { } fun waitForAllEditorsFinallyLoaded(project: Project) { - waitForAllEditorsFinallyLoaded(project, 30, TimeUnit.SECONDS) + // nothing } \ No newline at end of file diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/projectRoutines.kt.191 b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/projectRoutines.kt.191 new file mode 100644 index 00000000000..25a38f07876 --- /dev/null +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/projectRoutines.kt.191 @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.perf + +import com.intellij.openapi.project.Project +import com.intellij.openapi.project.ex.ProjectManagerEx +import com.intellij.psi.PsiDocumentManager +import com.intellij.psi.impl.PsiDocumentManagerBase +import com.intellij.testFramework.EdtTestUtil +import com.intellij.util.ThrowableRunnable +import com.intellij.util.ui.UIUtil +import org.jetbrains.kotlin.idea.parameterInfo.HintType +import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl.waitForAllEditorsFinallyLoaded +import java.util.concurrent.TimeUnit + +fun commitAllDocuments() { + ProjectManagerEx.getInstanceEx().openProjects.forEach { project -> + val psiDocumentManagerBase = PsiDocumentManager.getInstance(project) as PsiDocumentManagerBase + + EdtTestUtil.runInEdtAndWait(ThrowableRunnable { + psiDocumentManagerBase.clearUncommittedDocuments() + psiDocumentManagerBase.commitAllDocuments() + }) + } +} + +fun enableHints(enable: Boolean) = + HintType.values().forEach { it.option.set(enable) } + +fun runInEdtAndWait(block: () -> Unit) { + EdtTestUtil.runInEdtAndWait(ThrowableRunnable { + block() + }) +} + +fun dispatchAllInvocationEvents() { + runInEdtAndWait { + UIUtil.dispatchAllInvocationEvents() + } +} + +fun closeProject(project: Project) { + dispatchAllInvocationEvents() + val projectManagerEx = ProjectManagerEx.getInstanceEx() + projectManagerEx.forceCloseProject(project, true) +} + +fun waitForAllEditorsFinallyLoaded(project: Project) { + waitForAllEditorsFinallyLoaded(project, 30, TimeUnit.SECONDS) +} \ No newline at end of file