Introduce MultiModuleHighlightingTest
Checks that analysis produces expected diagnostics when configured by real IDEA module
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
public fun accessM1() {
|
||||||
|
accessM1()
|
||||||
|
accessM2()
|
||||||
|
<error>accessM3</error>()
|
||||||
|
<error>accessM4</error>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
public fun accessM2() {
|
||||||
|
accessM1()
|
||||||
|
accessM2()
|
||||||
|
<error>accessM3</error>()
|
||||||
|
<error>accessM4</error>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
public fun accessM3() {
|
||||||
|
<error>accessM1</error>()
|
||||||
|
accessM2()
|
||||||
|
accessM3()
|
||||||
|
<error>accessM4</error>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
public fun accessM4() {
|
||||||
|
accessM1()
|
||||||
|
accessM2()
|
||||||
|
accessM3()
|
||||||
|
accessM4()
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package m1
|
||||||
|
|
||||||
|
public class PublicClassInM1
|
||||||
|
class InternalClassInM1
|
||||||
|
private class PrivateClassInM1
|
||||||
|
|
||||||
|
public fun publicFunInM1() {
|
||||||
|
}
|
||||||
|
fun internalFunInM1() {
|
||||||
|
}
|
||||||
|
private fun privateFunInM1() {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testVisibility() {
|
||||||
|
<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: ClassInM2">ClassInM2</error>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class A internal () {
|
||||||
|
private fun pri() {
|
||||||
|
}
|
||||||
|
fun int() {
|
||||||
|
}
|
||||||
|
protected fun pro() {
|
||||||
|
}
|
||||||
|
public fun pub() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package m2
|
||||||
|
|
||||||
|
import m1.*
|
||||||
|
|
||||||
|
fun testVisibility() {
|
||||||
|
PublicClassInM1()
|
||||||
|
|
||||||
|
<error descr="[INVISIBLE_MEMBER] Cannot access 'InternalClassInM1': it is 'internal' in 'm1'">InternalClassInM1</error>()
|
||||||
|
|
||||||
|
<error descr="[INVISIBLE_MEMBER] Cannot access 'PrivateClassInM1': it is 'private' in 'm1'">PrivateClassInM1</error>()
|
||||||
|
|
||||||
|
publicFunInM1()
|
||||||
|
|
||||||
|
<error descr="[INVISIBLE_MEMBER] Cannot access 'internalFunInM1': it is 'internal' in 'm1'">internalFunInM1</error>()
|
||||||
|
|
||||||
|
<error descr="[INVISIBLE_MEMBER] Cannot access 'privateFunInM1': it is 'private' in 'm1'">privateFunInM1</error>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ClassInM2
|
||||||
|
|
||||||
|
public class B: <error descr="[INVISIBLE_MEMBER] Cannot access '<init>': it is 'internal' in 'A'">A</error>() {
|
||||||
|
|
||||||
|
fun accessA(<warning>a</warning>: A) {}
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
<error descr="[INVISIBLE_MEMBER] Cannot access 'pri': it is 'invisible_fake' in 'B'">pri</error>()
|
||||||
|
|
||||||
|
pro()
|
||||||
|
|
||||||
|
pub()
|
||||||
|
|
||||||
|
<error descr="[INVISIBLE_MEMBER] Cannot access 'int': it is 'invisible_fake' in 'B'">int</error>()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2014 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.jet.plugin.caches.resolve
|
||||||
|
|
||||||
|
import org.jetbrains.jet.plugin.PluginTestCaseBase
|
||||||
|
import com.intellij.openapi.module.StdModuleTypes
|
||||||
|
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
||||||
|
import org.jetbrains.jet.plugin.project.PluginJetFilesProvider
|
||||||
|
import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase
|
||||||
|
import com.intellij.openapi.module.Module
|
||||||
|
|
||||||
|
class MultiModuleHighlightingTest : DaemonAnalyzerTestCase() {
|
||||||
|
|
||||||
|
private val TEST_DATA_PATH = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleHighlighting/"
|
||||||
|
|
||||||
|
fun testVisibility() {
|
||||||
|
val module1 = module("m1")
|
||||||
|
val module2 = module("m2")
|
||||||
|
|
||||||
|
module2.addDependency(module1)
|
||||||
|
|
||||||
|
checkHighlightingInAllFiles()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testDependency() {
|
||||||
|
val module1 = module("m1")
|
||||||
|
val module2 = module("m2")
|
||||||
|
val module3 = module("m3")
|
||||||
|
val module4 = module("m4")
|
||||||
|
|
||||||
|
module2.addDependency(module1)
|
||||||
|
|
||||||
|
module1.addDependency(module2)
|
||||||
|
|
||||||
|
module3.addDependency(module2)
|
||||||
|
|
||||||
|
module4.addDependency(module1)
|
||||||
|
module4.addDependency(module2)
|
||||||
|
module4.addDependency(module3)
|
||||||
|
|
||||||
|
checkHighlightingInAllFiles()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkHighlightingInAllFiles() {
|
||||||
|
PluginJetFilesProvider.allFilesInProject(myProject!!).forEach { file ->
|
||||||
|
configureByExistingFile(file.getVirtualFile()!!)
|
||||||
|
checkHighlighting(myEditor, true, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun module(name: String): Module {
|
||||||
|
return createModuleFromTestData(TEST_DATA_PATH + "${getTestName(true)}/$name", "$name", StdModuleTypes.JAVA, true)!!
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Module.addDependency(other: Module) = ModuleRootModificationUtil.addDependency(this, other)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user