Fix IdeModuleInfoTests (related to KT-21771)

This commit is contained in:
Mikhail Glukhikh
2018-02-16 13:15:02 +03:00
parent d5df8c60fc
commit 6c328e7845
@@ -154,11 +154,15 @@ sealed class ModuleSourceInfoWithExpectedBy(private val forProduction: Boolean)
return if (forProduction) expectedByModule?.productionSourceInfo() else expectedByModule?.testSourceInfo() return if (forProduction) expectedByModule?.productionSourceInfo() else expectedByModule?.testSourceInfo()
} }
override fun dependencies(): List<IdeaModuleInfo> = module.cached(CachedValueProvider { override fun dependencies(): List<IdeaModuleInfo> = module.cached(createCachedValueProvider {
CachedValueProvider.Result( CachedValueProvider.Result(
ideaModelDependencies(module, forProduction), ideaModelDependencies(module, forProduction),
ProjectRootModificationTracker.getInstance(module.project)) ProjectRootModificationTracker.getInstance(module.project))
}) })
// NB: CachedValueProvider must exist separately in Production / Test source info,
// otherwise caching does not work properly
protected abstract fun <T> createCachedValueProvider(f: () -> CachedValueProvider.Result<T>): CachedValueProvider<T>
} }
data class ModuleProductionSourceInfo internal constructor( data class ModuleProductionSourceInfo internal constructor(
@@ -168,6 +172,8 @@ data class ModuleProductionSourceInfo internal constructor(
override val name = Name.special("<production sources for module ${module.name}>") override val name = Name.special("<production sources for module ${module.name}>")
override fun contentScope(): GlobalSearchScope = ModuleProductionSourceScope(module) override fun contentScope(): GlobalSearchScope = ModuleProductionSourceScope(module)
override fun <T> createCachedValueProvider(f: () -> CachedValueProvider.Result<T>) = CachedValueProvider { f() }
} }
//TODO: (module refactoring) do not create ModuleTestSourceInfo when there are no test roots for module //TODO: (module refactoring) do not create ModuleTestSourceInfo when there are no test roots for module
@@ -192,6 +198,8 @@ data class ModuleTestSourceInfo internal constructor(
CachedValueProvider.Result(list, ProjectRootModificationTracker.getInstance(module.project)) CachedValueProvider.Result(list, ProjectRootModificationTracker.getInstance(module.project))
}) })
override fun <T> createCachedValueProvider(f: () -> CachedValueProvider.Result<T>) = CachedValueProvider { f() }
} }
internal fun ModuleSourceInfo.isTests() = this is ModuleTestSourceInfo internal fun ModuleSourceInfo.isTests() = this is ModuleTestSourceInfo