CLion/AppCode: Do not import sourceSets with unsupported platforms
This commit is contained in:
committed by
Dmitriy Dolovov
parent
4a99cb274b
commit
7f0fcf7ef1
+2
-13
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.framework
|
||||
+1
-1
@@ -85,7 +85,7 @@ class KotlinAndroidMPPGradleProjectResolver : AbstractProjectResolverExtension()
|
||||
.asSequence()
|
||||
.flatMap { it.compilations.asSequence() }
|
||||
.filter { it.platform == KotlinPlatform.ANDROID }
|
||||
.map { KotlinMPPGradleProjectResolver.createSourceSetInfo(it, gradleModule, resolverCtx) }
|
||||
.mapNotNull { KotlinMPPGradleProjectResolver.createSourceSetInfo(it, gradleModule, resolverCtx) }
|
||||
.toList()
|
||||
mainModuleData.createChild(KotlinAndroidSourceSetData.KEY, KotlinAndroidSourceSetData(androidSourceSets))
|
||||
}
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ class KotlinAndroidMPPGradleProjectResolver : AbstractProjectResolverExtension()
|
||||
.asSequence()
|
||||
.flatMap { it.compilations.asSequence() }
|
||||
.filter { it.platform == KotlinPlatform.ANDROID }
|
||||
.map { KotlinMPPGradleProjectResolver.createSourceSetInfo(it, gradleModule, resolverCtx) }
|
||||
.mapNotNull { KotlinMPPGradleProjectResolver.createSourceSetInfo(it, gradleModule, resolverCtx) }
|
||||
.toList()
|
||||
mainModuleData.createChild(KotlinAndroidSourceSetData.KEY, KotlinAndroidSourceSetData(androidSourceSets))
|
||||
}
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ class KotlinAndroidMPPGradleProjectResolver : AbstractProjectResolverExtension()
|
||||
.asSequence()
|
||||
.flatMap { it.compilations.asSequence() }
|
||||
.filter { it.platform == KotlinPlatform.ANDROID }
|
||||
.map { KotlinMPPGradleProjectResolver.createSourceSetInfo(it, gradleModule, resolverCtx) }
|
||||
.mapNotNull { KotlinMPPGradleProjectResolver.createSourceSetInfo(it, gradleModule, resolverCtx) }
|
||||
.toList()
|
||||
mainModuleData.createChild(KotlinAndroidSourceSetData.KEY, KotlinAndroidSourceSetData(androidSourceSets))
|
||||
}
|
||||
|
||||
+11
-4
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.gradle.*
|
||||
import org.jetbrains.kotlin.idea.configuration.GradlePropertiesFileFacade.Companion.KOTLIN_NOT_IMPORTED_COMMON_SOURCE_SETS_SETTING
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinMPPGradleProjectResolver.Companion.isNotSupported
|
||||
import org.jetbrains.kotlin.idea.platform.IdePlatformKindTooling
|
||||
import org.jetbrains.plugins.gradle.model.*
|
||||
import org.jetbrains.plugins.gradle.model.data.BuildScriptClasspathData
|
||||
@@ -231,7 +232,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
||||
it.sdkName = jdkName
|
||||
}
|
||||
|
||||
val kotlinSourceSet = createSourceSetInfo(compilation, gradleModule, resolverCtx)
|
||||
val kotlinSourceSet = createSourceSetInfo(compilation, gradleModule, resolverCtx) ?: continue
|
||||
|
||||
if (compilation.platform == KotlinPlatform.JVM || compilation.platform == KotlinPlatform.ANDROID) {
|
||||
compilationData.targetCompatibility = (kotlinSourceSet.compilerArguments as? K2JVMCompilerArguments)?.jvmTarget
|
||||
@@ -290,7 +291,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
||||
?.minWith(VersionComparatorUtil.COMPARATOR)
|
||||
}
|
||||
|
||||
val kotlinSourceSet = createSourceSetInfo(sourceSet, gradleModule, resolverCtx)
|
||||
val kotlinSourceSet = createSourceSetInfo(sourceSet, gradleModule, resolverCtx) ?: continue
|
||||
|
||||
val sourceSetDataNode =
|
||||
(existingSourceSetDataNode ?: mainModuleNode.createChild(GradleSourceSetData.KEY, sourceSetData)).also {
|
||||
@@ -613,7 +614,8 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
||||
sourceSet: KotlinSourceSet,
|
||||
gradleModule: IdeaModule,
|
||||
resolverCtx: ProjectResolverContext
|
||||
): KotlinSourceSetInfo {
|
||||
): KotlinSourceSetInfo? {
|
||||
if (sourceSet.platform.isNotSupported()) return null
|
||||
return KotlinSourceSetInfo(sourceSet).also { info ->
|
||||
val languageSettings = sourceSet.languageSettings
|
||||
info.moduleId = getKotlinModuleId(gradleModule, sourceSet, resolverCtx)
|
||||
@@ -637,11 +639,13 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Unite with other createSourceSetInfo
|
||||
fun createSourceSetInfo(
|
||||
compilation: KotlinCompilation,
|
||||
gradleModule: IdeaModule,
|
||||
resolverCtx: ProjectResolverContext
|
||||
): KotlinSourceSetInfo {
|
||||
): KotlinSourceSetInfo? {
|
||||
if (compilation.platform.isNotSupported()) return null
|
||||
return KotlinSourceSetInfo(compilation).also { sourceSetInfo ->
|
||||
sourceSetInfo.moduleId = getKotlinModuleId(gradleModule, compilation, resolverCtx)
|
||||
sourceSetInfo.gradleModuleId = getModuleId(resolverCtx, gradleModule)
|
||||
@@ -656,6 +660,9 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Checks if our IDE doesn't support such platform */
|
||||
private fun KotlinPlatform.isNotSupported() = IdePlatformKindTooling.getToolingIfAny(this) == null
|
||||
|
||||
private fun KotlinSourceSetInfo.addSourceSets(
|
||||
sourceSets: Collection<KotlinModule>,
|
||||
selfName: String,
|
||||
|
||||
@@ -104,7 +104,6 @@
|
||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.script.standalone.KotlinStandaloneScriptRunConfigurationProducer"/>
|
||||
|
||||
<library.type implementation="org.jetbrains.kotlin.idea.framework.JSLibraryType"/>
|
||||
<library.type implementation="org.jetbrains.kotlin.idea.framework.CommonLibraryType"/>
|
||||
<library.javaSourceRootDetector implementation="org.jetbrains.kotlin.idea.configuration.KotlinSourceRootDetector"/>
|
||||
|
||||
<multipleRunLocationsProvider implementation="org.jetbrains.kotlin.idea.run.multiplatform.KotlinMultiplatformRunLocationsProvider"/>
|
||||
|
||||
@@ -104,7 +104,6 @@
|
||||
<runConfigurationProducer implementation="org.jetbrains.kotlin.idea.run.script.standalone.KotlinStandaloneScriptRunConfigurationProducer"/>
|
||||
|
||||
<library.type implementation="org.jetbrains.kotlin.idea.framework.JSLibraryType"/>
|
||||
<library.type implementation="org.jetbrains.kotlin.idea.framework.CommonLibraryType"/>
|
||||
<library.javaSourceRootDetector implementation="org.jetbrains.kotlin.idea.configuration.KotlinSourceRootDetector"/>
|
||||
|
||||
<editorNotificationProvider implementation="org.jetbrains.kotlin.idea.configuration.KotlinSetupEnvironmentNotificationProvider"/>
|
||||
|
||||
@@ -369,6 +369,7 @@
|
||||
<compiler.task execute="BEFORE" implementation="org.jetbrains.kotlin.idea.internal.makeBackup.MakeBackupCompileTask"/>
|
||||
<jps.plugin />
|
||||
|
||||
<library.type implementation="org.jetbrains.kotlin.idea.framework.CommonLibraryType"/>
|
||||
<lang.syntaxHighlighterFactory key="kotlin" implementationClass="org.jetbrains.kotlin.idea.highlighter.KotlinSyntaxHighlighterFactory"/>
|
||||
<syntaxHighlighter factoryClass="org.jetbrains.kotlin.idea.decompiler.builtIns.KotlinSyntaxHighlighterProviderForDecompiledBuiltIns"/>
|
||||
<lang.braceMatcher language="kotlin" implementationClass="org.jetbrains.kotlin.idea.KotlinPairMatcher"/>
|
||||
|
||||
@@ -71,8 +71,15 @@ abstract class IdePlatformKindTooling {
|
||||
return TOOLING_SUPPORT_BY_KIND[kind] ?: error("Unknown platform $kind")
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null if current IDE doesn't know given platform
|
||||
*/
|
||||
fun getToolingIfAny(platformId: KotlinPlatform): IdePlatformKindTooling? {
|
||||
return TOOLING_SUPPORT_BY_PLATFORM_ID[platformId]
|
||||
}
|
||||
|
||||
fun getTooling(platformId: KotlinPlatform): IdePlatformKindTooling {
|
||||
return TOOLING_SUPPORT_BY_PLATFORM_ID[platformId] ?: error("Unknown Gradle platform $platformId")
|
||||
return getToolingIfAny(platformId) ?: error("Unknown Gradle platform $platformId")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user