diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractKotlinProjectsPerformanceTest.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractKotlinProjectsPerformanceTest.kt index 47fd34be010..492422851de 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractKotlinProjectsPerformanceTest.kt +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/AbstractKotlinProjectsPerformanceTest.kt @@ -40,7 +40,6 @@ import com.intellij.testFramework.LightPlatformTestCase import com.intellij.testFramework.PsiTestUtil import com.intellij.testFramework.RunAll import com.intellij.testFramework.UsefulTestCase -import com.intellij.testFramework.fixtures.IdeaTestExecutionPolicy import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory import com.intellij.testFramework.fixtures.TempDirTestFixture import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl @@ -113,7 +112,7 @@ abstract class AbstractKotlinProjectsPerformanceTest : UsefulTestCase() { val perfHighlightFile = perfHighlightFile(project, "src/HelloMain.kt", "warm-up ") assertTrue("kotlin project has been not imported properly", perfHighlightFile.isNotEmpty()) PsiDocumentManager.getInstance(project).commitAllDocuments() - ProjectManagerEx.getInstanceEx().forceCloseProject(project, true) + ProjectManagerEx.getInstanceEx().closeAndDispose(project) warmedUp = true } @@ -132,13 +131,8 @@ abstract class AbstractKotlinProjectsPerformanceTest : UsefulTestCase() { .run() } - private fun getTempDirFixture(): TempDirTestFixture { - val policy = IdeaTestExecutionPolicy.current() - return if (policy != null) - policy.createTempDirTestFixture() - else - LightTempDirTestFixtureImpl(true) - } + private fun getTempDirFixture(): TempDirTestFixture = + LightTempDirTestFixtureImpl(true) protected fun perfChangeDocument(fileName: String, note: String = "", block: (document: Document) -> Unit) = perfChangeDocument(myProject!!, fileName, note, block) @@ -185,7 +179,7 @@ abstract class AbstractKotlinProjectsPerformanceTest : UsefulTestCase() { ProjectManagerEx.getInstanceEx().openTestProject(project) - disposeOnTearDown(Disposable { ProjectManagerEx.getInstanceEx().forceCloseProject(project, true) }) + disposeOnTearDown(Disposable { ProjectManagerEx.getInstanceEx().closeAndDispose(project) }) } val changeListManagerImpl = ChangeListManager.getInstance(project) as ChangeListManagerImpl diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/WholeProjectLightClassTest.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/WholeProjectLightClassTest.kt index 914b5601d93..6f708424561 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/WholeProjectLightClassTest.kt +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/WholeProjectLightClassTest.kt @@ -7,10 +7,10 @@ package org.jetbrains.kotlin.idea.perf import com.intellij.openapi.util.registry.Registry import com.intellij.openapi.vfs.VirtualFile +import com.intellij.psi.PsiManager import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration import org.jetbrains.kotlin.asJava.toLightClass import org.jetbrains.kotlin.cfg.pseudocode.containingDeclarationForPseudocode -import org.jetbrains.kotlin.idea.core.util.toPsiFile import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtVisitorVoid import java.util.* @@ -24,7 +24,7 @@ class WholeProjectLightClassTest : WholeProjectPerformanceTest(), WholeProjectKo val results = mutableMapOf() var totalNs = 0L - val psiFile = file.toPsiFile(project) ?: run { + val psiFile = PsiManager.getInstance(project).findFile(file) ?: run { return PerFileTestResult(results, totalNs, listOf(AssertionError("PsiFile not found for $file"))) } diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/WholeProjectLightClassTest.kt.182 b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/WholeProjectLightClassTest.kt.182 deleted file mode 100644 index 3ec0997db43..00000000000 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/WholeProjectLightClassTest.kt.182 +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2010-2018 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.vfs.VirtualFile -import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration -import org.jetbrains.kotlin.asJava.toLightClass -import org.jetbrains.kotlin.cfg.pseudocode.containingDeclarationForPseudocode -import org.jetbrains.kotlin.idea.refactoring.toPsiFile -import org.jetbrains.kotlin.psi.KtClassOrObject -import org.jetbrains.kotlin.psi.KtVisitorVoid -import java.util.* -import kotlin.system.measureNanoTime - -class WholeProjectLightClassTest : WholeProjectPerformanceTest(), WholeProjectKotlinFileProvider { - - override fun doTest(file: VirtualFile): PerFileTestResult { - val results = mutableMapOf() - var totalNs = 0L - - val psiFile = file.toPsiFile(project) ?: run { - return WholeProjectPerformanceTest.PerFileTestResult(results, totalNs, listOf(AssertionError("PsiFile not found for $file"))) - } - - val errors = mutableListOf() - - fun buildAllLightClasses(name: String, predicate: (KtClassOrObject) -> Boolean) { - val result = measureNanoTime { - try { - // Build light class by PsiFile - psiFile.acceptRecursively(object : KtVisitorVoid() { - override fun visitClassOrObject(classOrObject: KtClassOrObject) { - if (!predicate(classOrObject)) return - val lightClass = classOrObject.toLightClass() as? KtLightClassForSourceDeclaration ?: return - Arrays.hashCode(lightClass.superTypes) - Arrays.hashCode(lightClass.fields) - Arrays.hashCode(lightClass.methods) - // Just to be sure: access types - lightClass.fields.map { it.type }.hashCode() - lightClass.methods.map { it.returnType }.hashCode() - lightClass.hashCode() - } - }) - - } catch (t: Throwable) { - t.printStackTrace() - errors += t - } - } - results[name] = result - totalNs += result - } - - buildAllLightClasses("LightClasses_Top") { - it.containingDeclarationForPseudocode == null - } - - buildAllLightClasses("LightClasses_Members") { - !it.isLocal && it.containingDeclarationForPseudocode is KtClassOrObject - } - - return PerFileTestResult(results, totalNs, errors) - } -} \ No newline at end of file diff --git a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/WholeProjectPerformanceTest.kt b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/WholeProjectPerformanceTest.kt index cf0f0026ae0..48b48b62410 100644 --- a/idea/performanceTests/org/jetbrains/kotlin/idea/perf/WholeProjectPerformanceTest.kt +++ b/idea/performanceTests/org/jetbrains/kotlin/idea/perf/WholeProjectPerformanceTest.kt @@ -69,18 +69,21 @@ abstract class WholeProjectPerformanceTest : DaemonAnalyzerTestCase(), WholeProj InjectedLanguageManager.getInstance(project) // zillion of Dom Sem classes LanguageAnnotators.INSTANCE.allForLanguage(JavaLanguage.INSTANCE) // pile of annotator classes loads LanguageAnnotators.INSTANCE.allForLanguage(StdLanguages.XML) - ProblemHighlightFilter.EP_NAME.extensions - ImplicitUsageProvider.EP_NAME.extensionList - XmlSchemaProvider.EP_NAME.extensionList - XmlFileNSInfoProvider.EP_NAME.extensionList - ExternalAnnotatorsFilter.EXTENSION_POINT_NAME.extensionList - IndexPatternBuilder.EP_NAME.extensionList + assertTrue( + "side effect: to load extensions", + ProblemHighlightFilter.EP_NAME.extensions.toMutableList() + .plus(ImplicitUsageProvider.EP_NAME.extensions) + .plus(XmlSchemaProvider.EP_NAME.extensions) + .plus(XmlFileNSInfoProvider.EP_NAME.extensions) + .plus(ExternalAnnotatorsFilter.EXTENSION_POINT_NAME.extensions) + .plus(IndexPatternBuilder.EP_NAME.extensions).isNotEmpty() + ) } override fun setUpProject() { println("Using project in $tmp") - (ApplicationManager.getApplication() as ApplicationEx).doNotSave() + (ApplicationManager.getApplication() as ApplicationEx).isSaveAllowed = false myProject = ProjectUtil.openOrImport(tmp.path, null, false) }