Line marker tests for header <----> impl
This commit is contained in:
@@ -0,0 +1,4 @@
|
|||||||
|
header class <lineMarker>Header</lineMarker> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
impl typealias <lineMarker>Header</lineMarker> = String
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
header class <lineMarker>Header</lineMarker> {
|
||||||
|
fun foo(): Int
|
||||||
|
}
|
||||||
|
|
||||||
|
header fun <lineMarker>foo</lineMarker>(arg: Int): String
|
||||||
|
|
||||||
|
header val <lineMarker>flag</lineMarker>: Boolean
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// !CHECK_HIGHLIGHTING
|
||||||
|
|
||||||
|
impl class Header {
|
||||||
|
impl fun foo() = 42
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fun foo(arg: Int) = arg.toString()
|
||||||
|
|
||||||
|
impl val flag = true
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// !CHECK_HIGHLIGHTING
|
||||||
|
|
||||||
|
header class Header {
|
||||||
|
fun foo(): Int
|
||||||
|
}
|
||||||
|
|
||||||
|
header fun foo(arg: Int): String
|
||||||
|
|
||||||
|
header val flag: Boolean
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
impl class <lineMarker>Header</lineMarker> {
|
||||||
|
impl fun foo() = 42
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fun <lineMarker>foo</lineMarker>(arg: Int) = arg.toString()
|
||||||
|
|
||||||
|
impl val <lineMarker>flag</lineMarker> = true
|
||||||
|
|
||||||
|
|
||||||
+22
-18
@@ -16,43 +16,47 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.caches.resolve
|
package org.jetbrains.kotlin.idea.caches.resolve
|
||||||
|
|
||||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
|
||||||
import com.intellij.openapi.module.StdModuleTypes
|
|
||||||
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
|
||||||
import org.jetbrains.kotlin.idea.project.PluginJetFilesProvider
|
|
||||||
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase
|
|
||||||
import com.intellij.openapi.application.WriteAction
|
import com.intellij.openapi.application.WriteAction
|
||||||
import com.intellij.openapi.module.Module
|
|
||||||
import com.intellij.openapi.vfs.LocalFileSystem
|
|
||||||
import com.intellij.openapi.command.WriteCommandAction
|
import com.intellij.openapi.command.WriteCommandAction
|
||||||
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl
|
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl
|
||||||
import com.intellij.testFramework.PsiTestUtil
|
import com.intellij.openapi.module.Module
|
||||||
import java.io.File
|
import com.intellij.openapi.module.StdModuleTypes
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
|
||||||
import com.intellij.openapi.roots.DependencyScope
|
import com.intellij.openapi.roots.DependencyScope
|
||||||
|
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
||||||
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
|
import com.intellij.openapi.vfs.LocalFileSystem
|
||||||
|
import com.intellij.testFramework.PsiTestUtil
|
||||||
import com.sampullara.cli.Argument
|
import com.sampullara.cli.Argument
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.CompilerSettings
|
||||||
|
import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider
|
||||||
|
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||||
import org.jetbrains.kotlin.idea.facet.getOrCreateFacet
|
import org.jetbrains.kotlin.idea.facet.getOrCreateFacet
|
||||||
|
import org.jetbrains.kotlin.idea.project.PluginJetFilesProvider
|
||||||
|
import org.jetbrains.kotlin.idea.stubs.AbstractMultiHighlightingTest
|
||||||
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil
|
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil
|
||||||
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
abstract class AbstractMultiModuleHighlightingTest : DaemonAnalyzerTestCase() {
|
abstract class AbstractMultiModuleHighlightingTest : AbstractMultiHighlightingTest() {
|
||||||
|
|
||||||
private val TEST_DATA_PATH = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleHighlighting/"
|
protected open val testPath = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleHighlighting/"
|
||||||
|
|
||||||
protected fun checkHighlightingInAllFiles() {
|
protected fun checkHighlightingInAllFiles() {
|
||||||
var atLeastOneFile = false
|
var atLeastOneFile = false
|
||||||
PluginJetFilesProvider.allFilesInProject(myProject!!).forEach { file ->
|
PluginJetFilesProvider.allFilesInProject(myProject!!).forEach { file ->
|
||||||
atLeastOneFile = true
|
if (!file.text.contains("// !CHECK_HIGHLIGHTING")) {
|
||||||
configureByExistingFile(file.virtualFile!!)
|
atLeastOneFile = true
|
||||||
checkHighlighting(myEditor, true, false)
|
configureByExistingFile(file.virtualFile!!)
|
||||||
|
checkHighlighting(myEditor, true, false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Assert.assertTrue(atLeastOneFile)
|
Assert.assertTrue(atLeastOneFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun module(name: String, hasTestRoot: Boolean = false, useFullJdk: Boolean = false): Module {
|
protected fun module(name: String, hasTestRoot: Boolean = false, useFullJdk: Boolean = false): Module {
|
||||||
val srcDir = TEST_DATA_PATH + "${getTestName(true)}/$name"
|
val srcDir = testPath + "${getTestName(true)}/$name"
|
||||||
val moduleWithSrcRootSet = createModuleFromTestData(srcDir, name, StdModuleTypes.JAVA, true)!!
|
val moduleWithSrcRootSet = createModuleFromTestData(srcDir, name, StdModuleTypes.JAVA, true)!!
|
||||||
if (hasTestRoot) {
|
if (hasTestRoot) {
|
||||||
setTestRoot(moduleWithSrcRootSet, name)
|
setTestRoot(moduleWithSrcRootSet, name)
|
||||||
@@ -65,7 +69,7 @@ abstract class AbstractMultiModuleHighlightingTest : DaemonAnalyzerTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected fun setTestRoot(module: Module, name: String) {
|
protected fun setTestRoot(module: Module, name: String) {
|
||||||
val testDir = TEST_DATA_PATH + "${getTestName(true)}/${name}Test"
|
val testDir = testPath + "${getTestName(true)}/${name}Test"
|
||||||
val testRootDirInTestData = File(testDir)
|
val testRootDirInTestData = File(testDir)
|
||||||
val testRootDir = createTempDirectory()!!
|
val testRootDir = createTempDirectory()!!
|
||||||
FileUtil.copyDir(testRootDirInTestData, testRootDir)
|
FileUtil.copyDir(testRootDirInTestData, testRootDir)
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 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 org.jetbrains.kotlin.idea.caches.resolve
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||||
|
|
||||||
|
abstract class AbstractMultiModuleLineMarkerTest : AbstractMultiModuleHighlightingTest() {
|
||||||
|
|
||||||
|
override val testPath = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleLineMarker/"
|
||||||
|
|
||||||
|
override val shouldCheckLineMarkers = true
|
||||||
|
|
||||||
|
override val shouldCheckResult = false
|
||||||
|
|
||||||
|
override fun doTestLineMarkers() = true
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 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 org.jetbrains.kotlin.idea.caches.resolve
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||||
|
|
||||||
|
class MultiModuleLineMarkerTest : AbstractMultiModuleLineMarkerTest() {
|
||||||
|
fun testFromCommonToJvmHeader() {
|
||||||
|
val header = module("header")
|
||||||
|
header.setPlatformKind(TargetPlatformKind.Default)
|
||||||
|
|
||||||
|
val jvm = module("jvm")
|
||||||
|
jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6)
|
||||||
|
jvm.enableMultiPlatform()
|
||||||
|
jvm.addDependency(header)
|
||||||
|
|
||||||
|
checkHighlightingInAllFiles()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testFromCommonToJvmImpl() {
|
||||||
|
val header = module("header")
|
||||||
|
header.setPlatformKind(TargetPlatformKind.Default)
|
||||||
|
|
||||||
|
val jvm = module("jvm")
|
||||||
|
jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6)
|
||||||
|
jvm.enableMultiPlatform()
|
||||||
|
jvm.addDependency(header)
|
||||||
|
|
||||||
|
checkHighlightingInAllFiles()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testFromClassToAlias() {
|
||||||
|
val header = module("header")
|
||||||
|
header.setPlatformKind(TargetPlatformKind.Default)
|
||||||
|
|
||||||
|
val jvm = module("jvm")
|
||||||
|
jvm.setPlatformKind(TargetPlatformKind.Jvm.JVM_1_6)
|
||||||
|
jvm.enableMultiPlatform()
|
||||||
|
jvm.addDependency(header)
|
||||||
|
|
||||||
|
checkHighlightingInAllFiles()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user