Provide heuristic dependencies for LibraryInfo

This is not and cannot be (with current IDEA model) accurate
For now we use the following approximation:
    If a module dependends on library 'a' and among module's dependencies (including this module)
	there is a module that depends on library 'b' then
	we assume that library 'a' depends on library 'b'
This commit is contained in:
Pavel V. Talanov
2014-09-28 13:42:10 +04:00
parent 691068c0c2
commit 23a45ae689
@@ -133,12 +133,15 @@ public data class LibraryInfo(val project: Project, val library: Library) : Idea
override fun contentScope() = LibraryWithoutSourceScope(project, library)
override fun dependencies(): List<IdeaModuleInfo> {
//TODO: (module refactoring) heuristic dependencies for libraries
val orderEntry = ModuleManager.getInstance(project).getModules().stream().flatMap {
ModuleRootManager.getInstance(it).getOrderEntries().stream()
}.firstOrNull { it is JdkOrderEntry } as? JdkOrderEntry
val sdk = orderEntry?.getJdk()
return if (sdk != null) listOf(SdkInfo(project, sdk), this) else listOf(this)
val result = LinkedHashSet<IdeaModuleInfo>()
result.add(this)
val (libraries, sdks) = LibraryDependenciesCache(project).getLibrariesAndSdksUsedWith(library)
sdks.mapTo(result) { SdkInfo(project, it) }
libraries.mapTo(result) { LibraryInfo(project, it) }
return result.toList()
}
}