Consistent naming: common platform is common, not default
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.cli.metadata
|
package org.jetbrains.kotlin.cli.metadata
|
||||||
|
|
||||||
import org.jetbrains.kotlin.analyzer.common.DefaultAnalyzerFacade
|
import org.jetbrains.kotlin.analyzer.common.CommonAnalyzerFacade
|
||||||
import org.jetbrains.kotlin.builtins.BuiltInsBinaryVersion
|
import org.jetbrains.kotlin.builtins.BuiltInsBinaryVersion
|
||||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||||
@@ -64,7 +64,7 @@ open class MetadataSerializer(private val dependOnOldBuiltIns: Boolean) {
|
|||||||
|
|
||||||
val analyzer = AnalyzerWithCompilerReport(messageCollector)
|
val analyzer = AnalyzerWithCompilerReport(messageCollector)
|
||||||
analyzer.analyzeAndReport(files) {
|
analyzer.analyzeAndReport(files) {
|
||||||
DefaultAnalyzerFacade.analyzeFiles(files, moduleName, dependOnOldBuiltIns, configuration.languageVersionSettings) { _, content ->
|
CommonAnalyzerFacade.analyzeFiles(files, moduleName, dependOnOldBuiltIns, configuration.languageVersionSettings) { _, content ->
|
||||||
environment.createPackagePartProvider(content.moduleContentScope)
|
environment.createPackagePartProvider(content.moduleContentScope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import java.util.*
|
|||||||
object JvmPlatform : TargetPlatform("JVM") {
|
object JvmPlatform : TargetPlatform("JVM") {
|
||||||
private val defaultImports = LockBasedStorageManager().createMemoizedFunction<Boolean, List<ImportPath>> { includeKotlinComparisons ->
|
private val defaultImports = LockBasedStorageManager().createMemoizedFunction<Boolean, List<ImportPath>> { includeKotlinComparisons ->
|
||||||
ArrayList<ImportPath>().apply {
|
ArrayList<ImportPath>().apply {
|
||||||
addAll(Default.getDefaultImports(includeKotlinComparisons))
|
addAll(Common.getDefaultImports(includeKotlinComparisons))
|
||||||
|
|
||||||
add(ImportPath.fromString("java.lang.*"))
|
add(ImportPath.fromString("java.lang.*"))
|
||||||
add(ImportPath.fromString("kotlin.jvm.*"))
|
add(ImportPath.fromString("kotlin.jvm.*"))
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ interface ModuleInfo {
|
|||||||
// but if they are present, they should come after JVM built-ins in the dependencies list, because JVM built-ins contain
|
// but if they are present, they should come after JVM built-ins in the dependencies list, because JVM built-ins contain
|
||||||
// additional members dependent on the JDK
|
// additional members dependent on the JDK
|
||||||
fun dependencyOnBuiltIns(): ModuleInfo.DependencyOnBuiltIns =
|
fun dependencyOnBuiltIns(): ModuleInfo.DependencyOnBuiltIns =
|
||||||
if (platform == TargetPlatform.Default)
|
if (platform == TargetPlatform.Common)
|
||||||
ModuleInfo.DependencyOnBuiltIns.AFTER_SDK
|
ModuleInfo.DependencyOnBuiltIns.AFTER_SDK
|
||||||
else
|
else
|
||||||
ModuleInfo.DependencyOnBuiltIns.LAST
|
ModuleInfo.DependencyOnBuiltIns.LAST
|
||||||
|
|||||||
+4
-4
@@ -46,9 +46,9 @@ import org.jetbrains.kotlin.serialization.deserialization.MetadataPackageFragmen
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A facade that is used to analyze common (platform-independent) modules in multi-platform projects.
|
* A facade that is used to analyze common (platform-independent) modules in multi-platform projects.
|
||||||
* See [TargetPlatform.Default]
|
* See [TargetPlatform.Common]
|
||||||
*/
|
*/
|
||||||
object DefaultAnalyzerFacade : AnalyzerFacade() {
|
object CommonAnalyzerFacade : AnalyzerFacade() {
|
||||||
private class SourceModuleInfo(
|
private class SourceModuleInfo(
|
||||||
override val name: Name,
|
override val name: Name,
|
||||||
override val capabilities: Map<ModuleDescriptor.Capability<*>, Any?>,
|
override val capabilities: Map<ModuleDescriptor.Capability<*>, Any?>,
|
||||||
@@ -77,7 +77,7 @@ object DefaultAnalyzerFacade : AnalyzerFacade() {
|
|||||||
@Suppress("NAME_SHADOWING")
|
@Suppress("NAME_SHADOWING")
|
||||||
val resolver = ResolverForProjectImpl (
|
val resolver = ResolverForProjectImpl (
|
||||||
"sources for metadata serializer",
|
"sources for metadata serializer",
|
||||||
ProjectContext(project), listOf(moduleInfo), { DefaultAnalyzerFacade },
|
ProjectContext(project), listOf(moduleInfo), { CommonAnalyzerFacade },
|
||||||
{ ModuleContent(files, GlobalSearchScope.allScope(project)) },
|
{ ModuleContent(files, GlobalSearchScope.allScope(project)) },
|
||||||
object : PlatformAnalysisParameters {},
|
object : PlatformAnalysisParameters {},
|
||||||
languageSettingsProvider = object : LanguageSettingsProvider {
|
languageSettingsProvider = object : LanguageSettingsProvider {
|
||||||
@@ -159,5 +159,5 @@ object DefaultAnalyzerFacade : AnalyzerFacade() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val targetPlatform: TargetPlatform
|
override val targetPlatform: TargetPlatform
|
||||||
get() = TargetPlatform.Default
|
get() = TargetPlatform.Common
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ fun createLazyResolveSession(moduleContext: ModuleContext, files: Collection<KtF
|
|||||||
moduleContext,
|
moduleContext,
|
||||||
FileBasedDeclarationProviderFactory(moduleContext.storageManager, files),
|
FileBasedDeclarationProviderFactory(moduleContext.storageManager, files),
|
||||||
BindingTraceContext(),
|
BindingTraceContext(),
|
||||||
TargetPlatform.Default,
|
TargetPlatform.Common,
|
||||||
TargetPlatformVersion.NoVersion,
|
TargetPlatformVersion.NoVersion,
|
||||||
CompilerEnvironment,
|
CompilerEnvironment,
|
||||||
LanguageVersionSettingsImpl.DEFAULT
|
LanguageVersionSettingsImpl.DEFAULT
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ abstract class TargetPlatform(val platformName: String) {
|
|||||||
|
|
||||||
abstract val multiTargetPlatform: MultiTargetPlatform
|
abstract val multiTargetPlatform: MultiTargetPlatform
|
||||||
|
|
||||||
object Default : TargetPlatform("Default") {
|
object Common : TargetPlatform("Default") {
|
||||||
private val defaultImports = LockBasedStorageManager().createMemoizedFunction<Boolean, List<ImportPath>> {
|
private val defaultImports = LockBasedStorageManager().createMemoizedFunction<Boolean, List<ImportPath>> {
|
||||||
includeKotlinComparisons ->
|
includeKotlinComparisons ->
|
||||||
ArrayList<ImportPath>().apply {
|
ArrayList<ImportPath>().apply {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import com.intellij.openapi.util.io.FileUtil
|
|||||||
import com.intellij.openapi.util.text.StringUtil
|
import com.intellij.openapi.util.text.StringUtil
|
||||||
import com.intellij.psi.search.GlobalSearchScope
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||||
import org.jetbrains.kotlin.analyzer.common.DefaultAnalyzerFacade
|
import org.jetbrains.kotlin.analyzer.common.CommonAnalyzerFacade
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.CliLightClassGenerationSupport
|
import org.jetbrains.kotlin.cli.jvm.compiler.CliLightClassGenerationSupport
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM
|
import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.*
|
||||||
@@ -293,7 +293,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
|
|||||||
|
|
||||||
val platform = moduleDescriptor.getMultiTargetPlatform()
|
val platform = moduleDescriptor.getMultiTargetPlatform()
|
||||||
if (platform == MultiTargetPlatform.Common) {
|
if (platform == MultiTargetPlatform.Common) {
|
||||||
return DefaultAnalyzerFacade.analyzeFiles(
|
return CommonAnalyzerFacade.analyzeFiles(
|
||||||
files, moduleDescriptor.name, true, languageVersionSettings,
|
files, moduleDescriptor.name, true, languageVersionSettings,
|
||||||
mapOf(
|
mapOf(
|
||||||
MultiTargetPlatform.CAPABILITY to MultiTargetPlatform.Common,
|
MultiTargetPlatform.CAPABILITY to MultiTargetPlatform.Common,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import com.intellij.openapi.extensions.Extensions
|
|||||||
import com.intellij.openapi.module.Module
|
import com.intellij.openapi.module.Module
|
||||||
import com.intellij.openapi.roots.libraries.PersistentLibraryKind
|
import com.intellij.openapi.roots.libraries.PersistentLibraryKind
|
||||||
import org.jetbrains.kotlin.analyzer.AnalyzerFacade
|
import org.jetbrains.kotlin.analyzer.AnalyzerFacade
|
||||||
import org.jetbrains.kotlin.analyzer.common.DefaultAnalyzerFacade
|
import org.jetbrains.kotlin.analyzer.common.CommonAnalyzerFacade
|
||||||
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider
|
import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider
|
||||||
@@ -107,10 +107,10 @@ class JsPlatformSupport : IdePlatformSupport() {
|
|||||||
|
|
||||||
class CommonPlatformSupport : IdePlatformSupport() {
|
class CommonPlatformSupport : IdePlatformSupport() {
|
||||||
override val platform: TargetPlatform
|
override val platform: TargetPlatform
|
||||||
get() = TargetPlatform.Default
|
get() = TargetPlatform.Common
|
||||||
|
|
||||||
override val analyzerFacade: AnalyzerFacade
|
override val analyzerFacade: AnalyzerFacade
|
||||||
get() = DefaultAnalyzerFacade
|
get() = CommonAnalyzerFacade
|
||||||
|
|
||||||
override val libraryKind: PersistentLibraryKind<*>?
|
override val libraryKind: PersistentLibraryKind<*>?
|
||||||
get() = CommonLibraryKind
|
get() = CommonLibraryKind
|
||||||
|
|||||||
+1
-1
@@ -102,7 +102,7 @@ class LibraryDependenciesCacheImpl(private val project: Project) : LibraryDepend
|
|||||||
* @return true if it's OK to add a dependency from a library with platform [from] to a library with platform [to]
|
* @return true if it's OK to add a dependency from a library with platform [from] to a library with platform [to]
|
||||||
*/
|
*/
|
||||||
private fun compatiblePlatforms(from: TargetPlatform, to: TargetPlatform): Boolean {
|
private fun compatiblePlatforms(from: TargetPlatform, to: TargetPlatform): Boolean {
|
||||||
return from == to || to == TargetPlatform.Default
|
return from == to || to == TargetPlatform.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getLibraryUsageIndex(): LibraryUsageIndex {
|
private fun getLibraryUsageIndex(): LibraryUsageIndex {
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.serialization.deserialization.MetadataPackageFragmen
|
|||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
|
|
||||||
class KotlinBuiltInDecompiler : KotlinMetadataDecompiler<BuiltInsBinaryVersion>(
|
class KotlinBuiltInDecompiler : KotlinMetadataDecompiler<BuiltInsBinaryVersion>(
|
||||||
KotlinBuiltInFileType, TargetPlatform.Default, BuiltInSerializerProtocol,
|
KotlinBuiltInFileType, TargetPlatform.Common, BuiltInSerializerProtocol,
|
||||||
FlexibleTypeDeserializer.ThrowException, BuiltInsBinaryVersion.INSTANCE, BuiltInsBinaryVersion.INVALID_VERSION,
|
FlexibleTypeDeserializer.ThrowException, BuiltInsBinaryVersion.INSTANCE, BuiltInsBinaryVersion.INVALID_VERSION,
|
||||||
KotlinStubVersions.BUILTIN_STUB_VERSION
|
KotlinStubVersions.BUILTIN_STUB_VERSION
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ fun getLibraryPlatform(library: Library): TargetPlatform {
|
|||||||
|
|
||||||
return when (library.kind) {
|
return when (library.kind) {
|
||||||
JSLibraryKind -> JsPlatform
|
JSLibraryKind -> JsPlatform
|
||||||
CommonLibraryKind -> TargetPlatform.Default
|
CommonLibraryKind -> TargetPlatform.Common
|
||||||
else -> JvmPlatform
|
else -> JvmPlatform
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -58,7 +58,7 @@ class PlatformHeaderAnnotator : Annotator {
|
|||||||
val declaration = element as? KtDeclaration ?: return
|
val declaration = element as? KtDeclaration ?: return
|
||||||
if (!isHeaderDeclaration(declaration)) return
|
if (!isHeaderDeclaration(declaration)) return
|
||||||
|
|
||||||
if (TargetPlatformDetector.getPlatform(declaration.containingKtFile) !is TargetPlatform.Default) return
|
if (TargetPlatformDetector.getPlatform(declaration.containingKtFile) !is TargetPlatform.Common) return
|
||||||
|
|
||||||
val implementingModules = declaration.findModuleDescriptor().allImplementingCompatibleModules
|
val implementingModules = declaration.findModuleDescriptor().allImplementingCompatibleModules
|
||||||
if (implementingModules.isEmpty()) return
|
if (implementingModules.isEmpty()) return
|
||||||
|
|||||||
+2
-2
@@ -144,7 +144,7 @@ class KotlinGenerateEqualsAndHashcodeAction : KotlinGenerateMemberActionBase<Kot
|
|||||||
if (!targetClass.languageVersionSettings.supportsFeature(LanguageFeature.BoundCallableReferences)) return defaultExpression
|
if (!targetClass.languageVersionSettings.supportsFeature(LanguageFeature.BoundCallableReferences)) return defaultExpression
|
||||||
return when (targetClass.platform) {
|
return when (targetClass.platform) {
|
||||||
is JsPlatform -> "other == null || this::class.js != $paramName::class.js"
|
is JsPlatform -> "other == null || this::class.js != $paramName::class.js"
|
||||||
is TargetPlatform.Default -> "other == null || this::class != $paramName::class"
|
is TargetPlatform.Common -> "other == null || this::class != $paramName::class"
|
||||||
else -> defaultExpression
|
else -> defaultExpression
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ class KotlinGenerateEqualsAndHashcodeAction : KotlinGenerateMemberActionBase<Kot
|
|||||||
if (!targetClass.languageVersionSettings.supportsFeature(LanguageFeature.BoundCallableReferences)) return defaultExpression
|
if (!targetClass.languageVersionSettings.supportsFeature(LanguageFeature.BoundCallableReferences)) return defaultExpression
|
||||||
return when (targetClass.platform) {
|
return when (targetClass.platform) {
|
||||||
is JsPlatform -> "this::class.js"
|
is JsPlatform -> "this::class.js"
|
||||||
is TargetPlatform.Default -> "this::class"
|
is TargetPlatform.Common -> "this::class"
|
||||||
else -> defaultExpression
|
else -> defaultExpression
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -91,7 +91,7 @@ abstract class AbstractCodeInsightActionTest : KotlinLightCodeInsightFixtureTest
|
|||||||
val targetPlatform = when (targetPlatformName) {
|
val targetPlatform = when (targetPlatformName) {
|
||||||
"JVM" -> JvmPlatform
|
"JVM" -> JvmPlatform
|
||||||
"JavaScript" -> JsPlatform
|
"JavaScript" -> JsPlatform
|
||||||
"Common" -> TargetPlatform.Default
|
"Common" -> TargetPlatform.Common
|
||||||
else -> error("Unexpected platform name: $targetPlatformName")
|
else -> error("Unexpected platform name: $targetPlatformName")
|
||||||
}
|
}
|
||||||
mainPsiFile.targetPlatform = targetPlatform
|
mainPsiFile.targetPlatform = targetPlatform
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
|||||||
|
|
||||||
object JsPlatform : TargetPlatform("JS") {
|
object JsPlatform : TargetPlatform("JS") {
|
||||||
private val defaultImports = LockBasedStorageManager().createMemoizedFunction<Boolean, List<ImportPath>> { includeKotlinComparisons ->
|
private val defaultImports = LockBasedStorageManager().createMemoizedFunction<Boolean, List<ImportPath>> { includeKotlinComparisons ->
|
||||||
Default.getDefaultImports(includeKotlinComparisons) + ImportPath.fromString("kotlin.js.*")
|
Common.getDefaultImports(includeKotlinComparisons) + ImportPath.fromString("kotlin.js.*")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getDefaultImports(includeKotlinComparisons: Boolean): List<ImportPath> = defaultImports(includeKotlinComparisons)
|
override fun getDefaultImports(includeKotlinComparisons: Boolean): List<ImportPath> = defaultImports(includeKotlinComparisons)
|
||||||
|
|||||||
Reference in New Issue
Block a user