CLion/AppCode: Use default platform for libraries, if no LibraryKind is specified
To avoid Unknown platform JVM
This commit is contained in:
committed by
Dmitriy Dolovov
parent
1b9b545643
commit
2b3b5876aa
@@ -57,12 +57,12 @@ object CommonLibraryKind : PersistentLibraryKind<DummyLibraryProperties>("kotlin
|
||||
val PersistentLibraryKind<*>?.platform: TargetPlatform
|
||||
get() = when (this) {
|
||||
is KotlinLibraryKind -> this.compilerPlatform
|
||||
else -> JvmPlatform
|
||||
else -> DefaultIdeTargetPlatformKindProvider.defaultCompilerPlatform
|
||||
}
|
||||
|
||||
fun getLibraryPlatform(project: Project, library: Library): TargetPlatform {
|
||||
if (library !is LibraryEx) return JvmPlatform
|
||||
if (library.isDisposed) return JvmPlatform
|
||||
if (library !is LibraryEx) return DefaultIdeTargetPlatformKindProvider.defaultCompilerPlatform
|
||||
if (library.isDisposed) return DefaultIdeTargetPlatformKindProvider.defaultCompilerPlatform
|
||||
|
||||
return library.effectiveKind(project).platform
|
||||
}
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.platform.DefaultIdeTargetPlatformKindProvider;
|
||||
import org.jetbrains.kotlin.psi.KtCodeFragment;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactoryKt;
|
||||
@@ -62,7 +63,7 @@ public class TargetPlatformDetector {
|
||||
}
|
||||
}
|
||||
|
||||
return JvmPlatform.INSTANCE;
|
||||
return DefaultIdeTargetPlatformKindProvider.Companion.getDefaultCompilerPlatform();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+4
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.platform
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import org.jetbrains.kotlin.config.isJps
|
||||
import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
|
||||
interface DefaultIdeTargetPlatformKindProvider {
|
||||
val defaultPlatform: IdePlatform<*, *>
|
||||
@@ -22,5 +23,8 @@ interface DefaultIdeTargetPlatformKindProvider {
|
||||
|
||||
return ServiceManager.getService(DefaultIdeTargetPlatformKindProvider::class.java).defaultPlatform
|
||||
}
|
||||
|
||||
val defaultCompilerPlatform: TargetPlatform
|
||||
get() = defaultPlatform.kind.compilerPlatform
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user