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:
@@ -133,12 +133,15 @@ public data class LibraryInfo(val project: Project, val library: Library) : Idea
|
|||||||
override fun contentScope() = LibraryWithoutSourceScope(project, library)
|
override fun contentScope() = LibraryWithoutSourceScope(project, library)
|
||||||
|
|
||||||
override fun dependencies(): List<IdeaModuleInfo> {
|
override fun dependencies(): List<IdeaModuleInfo> {
|
||||||
//TODO: (module refactoring) heuristic dependencies for libraries
|
val result = LinkedHashSet<IdeaModuleInfo>()
|
||||||
val orderEntry = ModuleManager.getInstance(project).getModules().stream().flatMap {
|
result.add(this)
|
||||||
ModuleRootManager.getInstance(it).getOrderEntries().stream()
|
|
||||||
}.firstOrNull { it is JdkOrderEntry } as? JdkOrderEntry
|
val (libraries, sdks) = LibraryDependenciesCache(project).getLibrariesAndSdksUsedWith(library)
|
||||||
val sdk = orderEntry?.getJdk()
|
|
||||||
return if (sdk != null) listOf(SdkInfo(project, sdk), this) else listOf(this)
|
sdks.mapTo(result) { SdkInfo(project, it) }
|
||||||
|
libraries.mapTo(result) { LibraryInfo(project, it) }
|
||||||
|
|
||||||
|
return result.toList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user