From 41f7950ab874e48c229abcecae56f0ae8e75e20a Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 15 Feb 2017 18:21:37 +0100 Subject: [PATCH] UAST tests: don't null out the application if we have a valid one that we restored from a previous test --- plugins/uast-kotlin/tests/AbstractKotlinUastTest.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/uast-kotlin/tests/AbstractKotlinUastTest.kt b/plugins/uast-kotlin/tests/AbstractKotlinUastTest.kt index 211e85cbb71..6a434f5493c 100644 --- a/plugins/uast-kotlin/tests/AbstractKotlinUastTest.kt +++ b/plugins/uast-kotlin/tests/AbstractKotlinUastTest.kt @@ -84,6 +84,7 @@ abstract class AbstractKotlinUastTest : AbstractUastTest() { } override fun createEnvironment(source: File): AbstractCoreEnvironment { + val appWasNull = ApplicationManager.getApplication() == null compilerConfiguration = createKotlinCompilerConfiguration(source) val parentDisposable = Disposer.newDisposable() val kotlinCoreEnvironment = KotlinCoreEnvironment.createForTests( @@ -96,7 +97,7 @@ abstract class AbstractKotlinUastTest : AbstractUastTest() { AnalysisHandlerExtension.registerExtension( kotlinCoreEnvironment.project, UastAnalysisHandlerExtension()) - return KotlinCoreEnvironmentWrapper(kotlinCoreEnvironment, parentDisposable) + return KotlinCoreEnvironmentWrapper(kotlinCoreEnvironment, parentDisposable, appWasNull) } override fun tearDown() { @@ -123,7 +124,8 @@ abstract class AbstractKotlinUastTest : AbstractUastTest() { } private class KotlinCoreEnvironmentWrapper(val environment: KotlinCoreEnvironment, - val parentDisposable: Disposable) : AbstractCoreEnvironment() { + val parentDisposable: Disposable, + val appWasNull: Boolean) : AbstractCoreEnvironment() { override fun addJavaSourceRoot(root: File) { TODO("not implemented") } @@ -137,7 +139,9 @@ abstract class AbstractKotlinUastTest : AbstractUastTest() { override fun dispose() { Disposer.dispose(parentDisposable) - KtUsefulTestCase.resetApplicationToNull() + if (appWasNull) { + KtUsefulTestCase.resetApplicationToNull() + } } } } \ No newline at end of file