From 8d9b021ef2b857a3a2b37180f9edcb5afa960b91 Mon Sep 17 00:00:00 2001 From: "Vitaliy.Bibaev" Date: Tue, 17 Oct 2017 19:05:06 +0300 Subject: [PATCH] Support psi tests for standard stream api --- .../debugger/streams/kotlin/JdkManager.kt | 32 +++++++++++++++++++ .../kotlin/KotlinPsiChainBuilderTestCase.kt | 6 ++++ 2 files changed, 38 insertions(+) create mode 100644 idea/tests/com/intellij/debugger/streams/kotlin/JdkManager.kt diff --git a/idea/tests/com/intellij/debugger/streams/kotlin/JdkManager.kt b/idea/tests/com/intellij/debugger/streams/kotlin/JdkManager.kt new file mode 100644 index 00000000000..dcf77f1627e --- /dev/null +++ b/idea/tests/com/intellij/debugger/streams/kotlin/JdkManager.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.debugger.streams.kotlin + +import com.intellij.openapi.projectRoots.JavaSdk +import com.intellij.openapi.projectRoots.Sdk +import com.intellij.openapi.projectRoots.impl.JavaSdkImpl + +import java.io.File + +/** + * @author Vitaliy.Bibaev + */ +object JdkManager { + private val MOCK_JDK_DIR_NAME_PREFIX = "mockJDK-" + val JDK18_PATH: String = File("lib/" + MOCK_JDK_DIR_NAME_PREFIX + "1.8").absolutePath + + val mockJdk18: Sdk by lazy { (JavaSdk.getInstance() as JavaSdkImpl).createMockJdk("java 1.8", JDK18_PATH, false) } +} diff --git a/idea/tests/com/intellij/debugger/streams/kotlin/KotlinPsiChainBuilderTestCase.kt b/idea/tests/com/intellij/debugger/streams/kotlin/KotlinPsiChainBuilderTestCase.kt index 9b46d071f82..fe794fa764e 100644 --- a/idea/tests/com/intellij/debugger/streams/kotlin/KotlinPsiChainBuilderTestCase.kt +++ b/idea/tests/com/intellij/debugger/streams/kotlin/KotlinPsiChainBuilderTestCase.kt @@ -3,6 +3,8 @@ 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.projectRoots.Sdk +import com.intellij.pom.java.LanguageLevel import junit.framework.TestCase import java.io.File import java.nio.file.Paths @@ -21,6 +23,10 @@ abstract class KotlinPsiChainBuilderTestCase(private val relativePath: String) : override final fun getRelativeTestPath(): String = relativePath + override fun getProjectJDK(): Sdk { + return JdkManager.mockJdk18 + } + abstract class Positive(relativePath: String) : KotlinPsiChainBuilderTestCase(relativePath) { override fun doTest() { val chains = buildChains()