Detect K/N library kind if library is a ZIP file (common part)
Issue #KT-26730
This commit is contained in:
@@ -68,10 +68,13 @@ fun getLibraryPlatform(project: Project, library: Library): TargetPlatform {
|
|||||||
fun detectLibraryKind(roots: Array<VirtualFile>): PersistentLibraryKind<*>? {
|
fun detectLibraryKind(roots: Array<VirtualFile>): PersistentLibraryKind<*>? {
|
||||||
val jarFile = roots.firstOrNull() ?: return null
|
val jarFile = roots.firstOrNull() ?: return null
|
||||||
if (jarFile.fileSystem is JarFileSystem) {
|
if (jarFile.fileSystem is JarFileSystem) {
|
||||||
return when (jarFile.getLibraryKindForJar()) {
|
// TODO: Detect library kind for Jar file using IdePlatformKindResolution.
|
||||||
KnownLibraryKindForIndex.COMMON -> CommonLibraryKind
|
when (jarFile.getLibraryKindForJar()) {
|
||||||
KnownLibraryKindForIndex.JS -> JSLibraryKind
|
KnownLibraryKindForIndex.COMMON -> return CommonLibraryKind
|
||||||
KnownLibraryKindForIndex.UNKNOWN -> null
|
KnownLibraryKindForIndex.JS -> return JSLibraryKind
|
||||||
|
KnownLibraryKindForIndex.UNKNOWN -> {
|
||||||
|
/* Continue detection of library kind via IdePlatformKindResolution. */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ private val KOTLIN_LIBRARY_KIND_FILE_ATTRIBUTE: String = "kotlin-library-kind".a
|
|||||||
ServiceManager.getService(FileAttributeService::class.java)?.register(this, 1)
|
ServiceManager.getService(FileAttributeService::class.java)?.register(this, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Detect library kind for Jar file using IdePlatformKindResolution.
|
||||||
fun VirtualFile.getLibraryKindForJar(): KnownLibraryKindForIndex {
|
fun VirtualFile.getLibraryKindForJar(): KnownLibraryKindForIndex {
|
||||||
if (this !is VirtualFileWithId) return detectLibraryKindFromJarContentsForIndex(this)
|
if (this !is VirtualFileWithId) return detectLibraryKindFromJarContentsForIndex(this)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user