Minor: remove unused methods
This commit is contained in:
@@ -23,38 +23,9 @@ import com.intellij.openapi.roots.ModuleRootManager
|
|||||||
import com.intellij.openapi.roots.OrderRootType
|
import com.intellij.openapi.roots.OrderRootType
|
||||||
import com.intellij.openapi.roots.libraries.Library
|
import com.intellij.openapi.roots.libraries.Library
|
||||||
import com.intellij.util.text.VersionComparatorUtil
|
import com.intellij.util.text.VersionComparatorUtil
|
||||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
|
||||||
import org.jetbrains.kotlin.idea.framework.JavaRuntimeDetectionUtil
|
import org.jetbrains.kotlin.idea.framework.JavaRuntimeDetectionUtil
|
||||||
import org.jetbrains.kotlin.idea.framework.JsLibraryStdDetectionUtil
|
import org.jetbrains.kotlin.idea.framework.JsLibraryStdDetectionUtil
|
||||||
|
|
||||||
data class VersionedLibrary(val library: Library, val version: String?, val usedInModules: Collection<Module>)
|
|
||||||
|
|
||||||
fun findOutdatedKotlinLibraries(project: Project): List<VersionedLibrary> {
|
|
||||||
if (KotlinPluginUtil.isSnapshotVersion()) return emptyList() // plugin is run from sources, can't compare versions
|
|
||||||
if (KotlinPluginUtil.isDevVersion()) return emptyList()
|
|
||||||
if (project.isDisposed) return emptyList()
|
|
||||||
|
|
||||||
val outdatedLibraries = arrayListOf<VersionedLibrary>()
|
|
||||||
|
|
||||||
for ((library, modules) in findAllUsedLibraries(project).entrySet()) {
|
|
||||||
getOutdatedRuntimeLibraryVersion(library, project)?.let { version ->
|
|
||||||
outdatedLibraries.add(VersionedLibrary(library, version, modules))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return outdatedLibraries
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getOutdatedRuntimeLibraryVersion(library: Library, project: Project): String? {
|
|
||||||
val libraryVersion = getKotlinLibraryVersion(library, project) ?: return null
|
|
||||||
val runtimeVersion = bundledRuntimeVersion()
|
|
||||||
|
|
||||||
return if (isRuntimeOutdated(libraryVersion, runtimeVersion)) libraryVersion else null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getKotlinLibraryVersion(library: Library, project: Project): String? =
|
|
||||||
JavaRuntimeDetectionUtil.getJavaRuntimeVersion(library) ?: JsLibraryStdDetectionUtil.getJsLibraryStdVersion(library, project)
|
|
||||||
|
|
||||||
fun findKotlinRuntimeLibrary(module: Module, predicate: (Library, Project) -> Boolean = ::isKotlinRuntime): Library? {
|
fun findKotlinRuntimeLibrary(module: Module, predicate: (Library, Project) -> Boolean = ::isKotlinRuntime): Library? {
|
||||||
val orderEntries = ModuleRootManager.getInstance(module).orderEntries.filterIsInstance<LibraryOrderEntry>()
|
val orderEntries = ModuleRootManager.getInstance(module).orderEntries.filterIsInstance<LibraryOrderEntry>()
|
||||||
return orderEntries.asSequence()
|
return orderEntries.asSequence()
|
||||||
@@ -70,9 +41,6 @@ private fun isKotlinJavaRuntime(library: Library) =
|
|||||||
private fun isKotlinJsRuntime(library: Library, project: Project) =
|
private fun isKotlinJsRuntime(library: Library, project: Project) =
|
||||||
JsLibraryStdDetectionUtil.hasJsStdlibJar(library, project)
|
JsLibraryStdDetectionUtil.hasJsStdlibJar(library, project)
|
||||||
|
|
||||||
fun collectModulesWithOutdatedRuntime(libraries: List<VersionedLibrary>): List<Module> =
|
|
||||||
libraries.flatMap { it.usedInModules }
|
|
||||||
|
|
||||||
fun isRuntimeOutdated(libraryVersion: String?, runtimeVersion: String): Boolean {
|
fun isRuntimeOutdated(libraryVersion: String?, runtimeVersion: String): Boolean {
|
||||||
return libraryVersion == null || libraryVersion.startsWith("internal-") != runtimeVersion.startsWith("internal-") ||
|
return libraryVersion == null || libraryVersion.startsWith("internal-") != runtimeVersion.startsWith("internal-") ||
|
||||||
VersionComparatorUtil.compare(runtimeVersion.substringBefore("-release-"), libraryVersion) > 0
|
VersionComparatorUtil.compare(runtimeVersion.substringBefore("-release-"), libraryVersion) > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user