From dd05a9b11bea3ce783954dbfef6e395c343db8e2 Mon Sep 17 00:00:00 2001 From: "Vitaliy.Bibaev" Date: Fri, 27 Oct 2017 13:41:40 +0300 Subject: [PATCH] Add kotlin stdlib to psi tests --- .../kotlin/KotlinPsiChainBuilderTestCase.kt | 14 +++++++++++++- .../debugger/streams/kotlin/LibraryUtil.kt | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/idea/tests/com/intellij/debugger/streams/kotlin/KotlinPsiChainBuilderTestCase.kt b/idea/tests/com/intellij/debugger/streams/kotlin/KotlinPsiChainBuilderTestCase.kt index 657332e90cd..f5dc8e853c9 100644 --- a/idea/tests/com/intellij/debugger/streams/kotlin/KotlinPsiChainBuilderTestCase.kt +++ b/idea/tests/com/intellij/debugger/streams/kotlin/KotlinPsiChainBuilderTestCase.kt @@ -4,14 +4,18 @@ package com.intellij.debugger.streams.kotlin import com.intellij.debugger.streams.test.StreamChainBuilderTestCase import com.intellij.debugger.streams.wrapper.StreamChain import com.intellij.debugger.streams.wrapper.StreamChainBuilder +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.Project import com.intellij.openapi.projectRoots.Sdk +import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable import com.intellij.openapi.vfs.VirtualFile +import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess import com.intellij.psi.PsiManager import com.intellij.psi.impl.PsiManagerEx import com.intellij.psi.impl.file.impl.FileManagerImpl import com.intellij.psi.impl.source.PsiFileImpl import com.intellij.testFramework.LightPlatformTestCase +import com.intellij.testFramework.PsiTestUtil import junit.framework.TestCase import org.jetbrains.kotlin.idea.caches.resolve.LibraryModificationTracker import org.jetbrains.kotlin.idea.decompiler.KotlinDecompiledFileViewProvider @@ -27,8 +31,8 @@ abstract class KotlinPsiChainBuilderTestCase(private val relativePath: String) : override fun getTestDataPath(): String = Paths.get(File("").absolutePath, "/testData/psi/$relativeTestPath/").toString() override fun getFileExtension(): String = ".kt" abstract val kotlinChainBuilder: StreamChainBuilder - override final fun getChainBuilder(): StreamChainBuilder = kotlinChainBuilder + private val stdLibName = "kotlin-stdlib" protected abstract fun doTest() @@ -40,9 +44,17 @@ abstract class KotlinPsiChainBuilderTestCase(private val relativePath: String) : override fun setUp() { super.setUp() + ApplicationManager.getApplication().runWriteAction { + if (ProjectLibraryTable.getInstance(LightPlatformTestCase.getProject()).getLibraryByName(stdLibName) == null) { + VfsRootAccess.allowRootAccess(LibraryUtil.LIBRARIES_DIRECTORY) + PsiTestUtil.addLibrary(testRootDisposable, LightPlatformTestCase.getModule(), stdLibName, + LibraryUtil.LIBRARIES_DIRECTORY, LibraryUtil.KOTLIN_STD_LIBRARY_JAR_NAME) + } + } LibraryModificationTracker.getInstance(LightPlatformTestCase.getProject()).incModificationCount() } + override fun getProjectJDK(): Sdk { return JdkManager.mockJdk18 } diff --git a/idea/tests/com/intellij/debugger/streams/kotlin/LibraryUtil.kt b/idea/tests/com/intellij/debugger/streams/kotlin/LibraryUtil.kt index 3bbbf9e9f0e..e2ca5e8fe77 100644 --- a/idea/tests/com/intellij/debugger/streams/kotlin/LibraryUtil.kt +++ b/idea/tests/com/intellij/debugger/streams/kotlin/LibraryUtil.kt @@ -9,5 +9,5 @@ import java.io.File object LibraryUtil { val LIBRARIES_DIRECTORY: String = File("lib").absolutePath - val KOTLIN_STD_LIBRARY = "kotlin-stdlib.jar" + val KOTLIN_STD_LIBRARY_JAR_NAME = "kotlin-stdlib.jar" } \ No newline at end of file