From 5c65266354145789a9eedb9512421f4badec55ce Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Wed, 26 Oct 2016 14:50:11 +0300 Subject: [PATCH] Refactoring: Move facet configuration classes to idea-jps-common module Original commit: a6dbdbd3e548edcf347b234fcac66da1afae6f03 --- jps/jps-common/idea-jps-common.iml | 2 + .../kotlin/config/DescriptionAware.kt | 37 +++++++ .../kotlin/config/KotlinFacetSettings.kt | 103 ++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 jps/jps-common/src/org/jetbrains/kotlin/config/DescriptionAware.kt create mode 100644 jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt diff --git a/jps/jps-common/idea-jps-common.iml b/jps/jps-common/idea-jps-common.iml index 8902bc86b9b..914a19b4ad5 100644 --- a/jps/jps-common/idea-jps-common.iml +++ b/jps/jps-common/idea-jps-common.iml @@ -9,5 +9,7 @@ + + \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/DescriptionAware.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/DescriptionAware.kt new file mode 100644 index 00000000000..346a984832e --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/DescriptionAware.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2016 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-2016 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. + */ + +package org.jetbrains.kotlin.config; + +interface DescriptionAware { + val description: String +} \ No newline at end of file diff --git a/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt new file mode 100644 index 00000000000..a2db9376e59 --- /dev/null +++ b/jps/jps-common/src/org/jetbrains/kotlin/config/KotlinFacetSettings.kt @@ -0,0 +1,103 @@ +/* + * Copyright 2010-2016 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-2016 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. + */ + +package org.jetbrains.kotlin.config + +import com.intellij.util.xmlb.annotations.Property +import com.intellij.util.xmlb.annotations.Transient +import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments +import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments + +enum class LanguageLevel(override val description: String) : DescriptionAware { + KOTLIN_1_0("1.0"), + KOTLIN_1_1("1.1") +} + +sealed class TargetPlatformKind( + val version: Version, + val name: String +) : DescriptionAware { + override val description = "$name ${version.description}" + + companion object { + val ALL_PLATFORMS: List> by lazy { JVMPlatform.JVM_PLATFORMS + JSPlatform } + } +} + +object NoVersion : DescriptionAware { + override val description = "" +} + +enum class JVMVersion(override val description: String) : DescriptionAware { + JVM_1_6("1.6"), + JVM_1_8("1.8") +} + +class JVMPlatform(version: JVMVersion) : TargetPlatformKind(version, "JVM") { + companion object { + val JVM_PLATFORMS by lazy { JVMVersion.values().map(::JVMPlatform) } + + operator fun get(version: JVMVersion) = JVM_PLATFORMS[version.ordinal] + } +} + +object JSPlatform : TargetPlatformKind(NoVersion, "JavaScript") + +data class KotlinVersionInfo( + var languageLevel: LanguageLevel? = null, + var apiLevel: LanguageLevel? = null, + @get:Transient var targetPlatformKindKind: TargetPlatformKind<*>? = null +) { + // To be serialized + var targetPlatformName: String + get() = targetPlatformKindKind?.description ?: "" + set(value) { + targetPlatformKindKind = TargetPlatformKind.ALL_PLATFORMS.firstOrNull { it.description == value } + } +} + +class KotlinCompilerInfo { + // To be serialized + @Property private var _commonCompilerArguments: CommonCompilerArguments.DummyImpl? = null + @get:Transient var commonCompilerArguments: CommonCompilerArguments? + get() = _commonCompilerArguments + set(value) { + _commonCompilerArguments = value as? CommonCompilerArguments.DummyImpl + } + var k2jsCompilerArguments: K2JSCompilerArguments? = null + var compilerSettings: CompilerSettings? = null +} + +class KotlinFacetSettings { + var versionInfo = KotlinVersionInfo() + var compilerInfo = KotlinCompilerInfo() +} \ No newline at end of file