Test not creating resolvers for modules that have no relevant packages
This commit is contained in:
@@ -213,6 +213,8 @@ abstract class AnalyzerFacade<in P : PlatformAnalysisParameters> {
|
|||||||
for (module in modules) {
|
for (module in modules) {
|
||||||
val descriptor = resolverForProject.descriptorForModule(module)
|
val descriptor = resolverForProject.descriptorForModule(module)
|
||||||
val computeResolverForModule = storageManager.createLazyValue {
|
val computeResolverForModule = storageManager.createLazyValue {
|
||||||
|
ResolverForModuleComputationTracker.getInstance(projectContext.project)?.onResolverComputed(module)
|
||||||
|
|
||||||
val content = modulesContent(module)
|
val content = modulesContent(module)
|
||||||
analyzerFacade(module).createResolverForModule(
|
analyzerFacade(module).createResolverForModule(
|
||||||
module, descriptor, projectContext.withModule(descriptor), modulesContent(module),
|
module, descriptor, projectContext.withModule(descriptor), modulesContent(module),
|
||||||
@@ -271,4 +273,13 @@ interface LanguageSettingsProvider {
|
|||||||
companion object {
|
companion object {
|
||||||
fun getInstance(project: Project) = ServiceManager.getService(project, LanguageSettingsProvider::class.java) ?: Default
|
fun getInstance(project: Project) = ServiceManager.getService(project, LanguageSettingsProvider::class.java) ?: Default
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ResolverForModuleComputationTracker {
|
||||||
|
|
||||||
|
fun onResolverComputed(moduleInfo: ModuleInfo)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun getInstance(project: Project): ResolverForModuleComputationTracker? = ServiceManager.getService(project, ResolverForModuleComputationTracker::class.java) ?: null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package foo.bar.used
|
||||||
|
|
||||||
|
public fun m1() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package foo.bar.unused
|
||||||
|
|
||||||
|
public fun m2() {
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package foo.bar.source
|
||||||
|
|
||||||
|
import foo.bar.used.*
|
||||||
|
|
||||||
|
public fun m3() {
|
||||||
|
m1()
|
||||||
|
}
|
||||||
+2
-2
@@ -56,10 +56,10 @@ abstract class AbstractMultiModuleHighlightingTest : AbstractMultiHighlightingTe
|
|||||||
checkHighlightingInAllFiles()
|
checkHighlightingInAllFiles()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun checkHighlightingInAllFiles() {
|
protected fun checkHighlightingInAllFiles(nameFilter: (fileName: String) -> Boolean = { true }) {
|
||||||
var atLeastOneFile = false
|
var atLeastOneFile = false
|
||||||
PluginJetFilesProvider.allFilesInProject(myProject!!).forEach { file ->
|
PluginJetFilesProvider.allFilesInProject(myProject!!).forEach { file ->
|
||||||
if (!file.text.contains("// !CHECK_HIGHLIGHTING")) {
|
if (nameFilter(file.name) && !file.text.contains("// !CHECK_HIGHLIGHTING")) {
|
||||||
atLeastOneFile = true
|
atLeastOneFile = true
|
||||||
configureByExistingFile(file.virtualFile!!)
|
configureByExistingFile(file.virtualFile!!)
|
||||||
checkHighlighting(myEditor, true, false)
|
checkHighlighting(myEditor, true, false)
|
||||||
|
|||||||
@@ -16,12 +16,23 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.caches.resolve
|
package org.jetbrains.kotlin.idea.caches.resolve
|
||||||
|
|
||||||
|
import com.intellij.openapi.module.Module
|
||||||
import com.intellij.openapi.roots.DependencyScope
|
import com.intellij.openapi.roots.DependencyScope
|
||||||
|
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
|
||||||
|
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||||
|
import org.jetbrains.kotlin.analyzer.ResolverForModuleComputationTracker
|
||||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
||||||
import org.jetbrains.kotlin.config.JvmTarget
|
import org.jetbrains.kotlin.config.JvmTarget
|
||||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||||
|
import org.jetbrains.kotlin.idea.completion.test.withServiceRegistered
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
|
|
||||||
class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
||||||
|
override fun setUp() {
|
||||||
|
super.setUp()
|
||||||
|
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
|
||||||
|
}
|
||||||
|
|
||||||
fun testVisibility() {
|
fun testVisibility() {
|
||||||
val module1 = module("m1")
|
val module1 = module("m1")
|
||||||
val module2 = module("m2")
|
val module2 = module("m2")
|
||||||
@@ -50,6 +61,40 @@ class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
|||||||
checkHighlightingInAllFiles()
|
checkHighlightingInAllFiles()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testLazyResolvers() {
|
||||||
|
val resolversComputed = mutableSetOf<Module>()
|
||||||
|
|
||||||
|
val resolversTracker = object : ResolverForModuleComputationTracker {
|
||||||
|
override fun onResolverComputed(moduleInfo: ModuleInfo) {
|
||||||
|
(moduleInfo as IdeaModuleInfo).let {
|
||||||
|
if (it is ModuleSourceInfo) {
|
||||||
|
val module = it.module
|
||||||
|
resolversComputed.add(module)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.withServiceRegistered<ResolverForModuleComputationTracker, Unit>(resolversTracker) {
|
||||||
|
val module1 = module("m1")
|
||||||
|
val module2 = module("m2")
|
||||||
|
val module3 = module("m3")
|
||||||
|
|
||||||
|
module3.addDependency(module2)
|
||||||
|
module3.addDependency(module1)
|
||||||
|
|
||||||
|
assertTrue(module1 !in resolversComputed)
|
||||||
|
assertTrue(module2 !in resolversComputed)
|
||||||
|
assertTrue(module3 !in resolversComputed)
|
||||||
|
|
||||||
|
checkHighlightingInAllFiles { "m3" in it }
|
||||||
|
|
||||||
|
assertTrue(module1 in resolversComputed)
|
||||||
|
assertTrue(module2 !in resolversComputed)
|
||||||
|
assertTrue(module3 in resolversComputed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun testTestRoot() {
|
fun testTestRoot() {
|
||||||
val module1 = module("m1", hasTestRoot = true)
|
val module1 = module("m1", hasTestRoot = true)
|
||||||
val module2 = module("m2", hasTestRoot = true)
|
val module2 = module("m2", hasTestRoot = true)
|
||||||
|
|||||||
Reference in New Issue
Block a user