diff --git a/idea/testData/multiModuleLineMarker/fromClassToAlias/header/header.kt b/idea/testData/multiModuleLineMarker/fromClassToAlias/header/header.kt new file mode 100644 index 00000000000..39b606b7093 --- /dev/null +++ b/idea/testData/multiModuleLineMarker/fromClassToAlias/header/header.kt @@ -0,0 +1,4 @@ +header class Header { + +} + diff --git a/idea/testData/multiModuleLineMarker/fromClassToAlias/jvm/jvm.kt b/idea/testData/multiModuleLineMarker/fromClassToAlias/jvm/jvm.kt new file mode 100644 index 00000000000..d26182884a1 --- /dev/null +++ b/idea/testData/multiModuleLineMarker/fromClassToAlias/jvm/jvm.kt @@ -0,0 +1,2 @@ +impl typealias Header = String + diff --git a/idea/testData/multiModuleLineMarker/fromCommonToJvmHeader/header/header.kt b/idea/testData/multiModuleLineMarker/fromCommonToJvmHeader/header/header.kt new file mode 100644 index 00000000000..9a1269f4166 --- /dev/null +++ b/idea/testData/multiModuleLineMarker/fromCommonToJvmHeader/header/header.kt @@ -0,0 +1,7 @@ +header class Header { + fun foo(): Int +} + +header fun foo(arg: Int): String + +header val flag: Boolean diff --git a/idea/testData/multiModuleLineMarker/fromCommonToJvmHeader/jvm/jvm.kt b/idea/testData/multiModuleLineMarker/fromCommonToJvmHeader/jvm/jvm.kt new file mode 100644 index 00000000000..7f327bb49bd --- /dev/null +++ b/idea/testData/multiModuleLineMarker/fromCommonToJvmHeader/jvm/jvm.kt @@ -0,0 +1,11 @@ +// !CHECK_HIGHLIGHTING + +impl class Header { + impl fun foo() = 42 +} + +impl fun foo(arg: Int) = arg.toString() + +impl val flag = true + + diff --git a/idea/testData/multiModuleLineMarker/fromCommonToJvmImpl/header/header.kt b/idea/testData/multiModuleLineMarker/fromCommonToJvmImpl/header/header.kt new file mode 100644 index 00000000000..c845d60bc7d --- /dev/null +++ b/idea/testData/multiModuleLineMarker/fromCommonToJvmImpl/header/header.kt @@ -0,0 +1,9 @@ +// !CHECK_HIGHLIGHTING + +header class Header { + fun foo(): Int +} + +header fun foo(arg: Int): String + +header val flag: Boolean diff --git a/idea/testData/multiModuleLineMarker/fromCommonToJvmImpl/jvm/jvm.kt b/idea/testData/multiModuleLineMarker/fromCommonToJvmImpl/jvm/jvm.kt new file mode 100644 index 00000000000..a6a9f3856bd --- /dev/null +++ b/idea/testData/multiModuleLineMarker/fromCommonToJvmImpl/jvm/jvm.kt @@ -0,0 +1,9 @@ +impl class Header { + impl fun foo() = 42 +} + +impl fun foo(arg: Int) = arg.toString() + +impl val flag = true + + diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt index 0d17919848b..0d670952005 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleHighlightingTest.kt @@ -16,43 +16,47 @@ 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.module.Module -import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl -import com.intellij.testFramework.PsiTestUtil -import java.io.File -import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.module.Module +import com.intellij.openapi.module.StdModuleTypes 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 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.project.PluginJetFilesProvider +import org.jetbrains.kotlin.idea.stubs.AbstractMultiHighlightingTest import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil +import org.jetbrains.kotlin.idea.test.PluginTestCaseBase 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() { var atLeastOneFile = false PluginJetFilesProvider.allFilesInProject(myProject!!).forEach { file -> - atLeastOneFile = true - configureByExistingFile(file.virtualFile!!) - checkHighlighting(myEditor, true, false) + if (!file.text.contains("// !CHECK_HIGHLIGHTING")) { + atLeastOneFile = true + configureByExistingFile(file.virtualFile!!) + checkHighlighting(myEditor, true, false) + } } Assert.assertTrue(atLeastOneFile) } 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)!! if (hasTestRoot) { setTestRoot(moduleWithSrcRootSet, name) @@ -65,7 +69,7 @@ abstract class AbstractMultiModuleHighlightingTest : DaemonAnalyzerTestCase() { } 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 testRootDir = createTempDirectory()!! FileUtil.copyDir(testRootDirInTestData, testRootDir) diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleLineMarkerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleLineMarkerTest.kt new file mode 100644 index 00000000000..f192de100e3 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/AbstractMultiModuleLineMarkerTest.kt @@ -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 +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleLineMarkerTest.kt b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleLineMarkerTest.kt new file mode 100644 index 00000000000..475a86523ae --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiModuleLineMarkerTest.kt @@ -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() + } +} \ No newline at end of file