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<*>? {
|
||||
val jarFile = roots.firstOrNull() ?: return null
|
||||
if (jarFile.fileSystem is JarFileSystem) {
|
||||
return when (jarFile.getLibraryKindForJar()) {
|
||||
KnownLibraryKindForIndex.COMMON -> CommonLibraryKind
|
||||
KnownLibraryKindForIndex.JS -> JSLibraryKind
|
||||
KnownLibraryKindForIndex.UNKNOWN -> null
|
||||
// TODO: Detect library kind for Jar file using IdePlatformKindResolution.
|
||||
when (jarFile.getLibraryKindForJar()) {
|
||||
KnownLibraryKindForIndex.COMMON -> return CommonLibraryKind
|
||||
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)
|
||||
}
|
||||
|
||||
// TODO: Detect library kind for Jar file using IdePlatformKindResolution.
|
||||
fun VirtualFile.getLibraryKindForJar(): KnownLibraryKindForIndex {
|
||||
if (this !is VirtualFileWithId) return detectLibraryKindFromJarContentsForIndex(this)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user