Configuration: Drop Java -> Kotlin/JS configurator
#KT-24504 Fixed
This commit is contained in:
+2
-3
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.framework;
|
package org.jetbrains.kotlin.idea.framework;
|
||||||
|
|
||||||
import com.intellij.framework.FrameworkType;
|
|
||||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||||
import com.intellij.openapi.roots.OrderEntry;
|
import com.intellij.openapi.roots.OrderEntry;
|
||||||
@@ -39,7 +38,7 @@ public class FrameworksCompatibilityUtils {
|
|||||||
public static void suggestRemoveIncompatibleFramework(
|
public static void suggestRemoveIncompatibleFramework(
|
||||||
@NotNull ModifiableRootModel rootModel,
|
@NotNull ModifiableRootModel rootModel,
|
||||||
@NotNull Set<? extends LibraryKind> frameworkLibraryKinds,
|
@NotNull Set<? extends LibraryKind> frameworkLibraryKinds,
|
||||||
@NotNull FrameworkType frameworkType
|
@NotNull String presentableName
|
||||||
) {
|
) {
|
||||||
List<OrderEntry> existingEntries = new ArrayList<OrderEntry>();
|
List<OrderEntry> existingEntries = new ArrayList<OrderEntry>();
|
||||||
|
|
||||||
@@ -57,7 +56,7 @@ public class FrameworksCompatibilityUtils {
|
|||||||
|
|
||||||
removeWithConfirm(rootModel, existingEntries,
|
removeWithConfirm(rootModel, existingEntries,
|
||||||
String.format("Current module is already configured with '%s' framework.\nDo you want to remove it?",
|
String.format("Current module is already configured with '%s' framework.\nDo you want to remove it?",
|
||||||
frameworkType.getPresentableName()),
|
presentableName),
|
||||||
"Framework Conflict");
|
"Framework Conflict");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2000-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
|
|
||||||
|
|
||||||
import com.intellij.framework.FrameworkTypeEx
|
|
||||||
import com.intellij.framework.addSupport.FrameworkSupportInModuleConfigurable
|
|
||||||
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider
|
|
||||||
import com.intellij.ide.util.frameworkSupport.FrameworkSupportModel
|
|
||||||
import com.intellij.openapi.module.JavaModuleType
|
|
||||||
import com.intellij.openapi.module.Module
|
|
||||||
import com.intellij.openapi.module.ModuleType
|
|
||||||
import com.intellij.openapi.roots.ModifiableModelsProvider
|
|
||||||
import com.intellij.openapi.roots.ModifiableRootModel
|
|
||||||
import com.intellij.openapi.roots.ui.configuration.FacetsProvider
|
|
||||||
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription
|
|
||||||
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
|
|
||||||
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
|
|
||||||
import javax.swing.JComponent
|
|
||||||
|
|
||||||
class JSFrameworkSupportProvider : FrameworkSupportInModuleProvider() {
|
|
||||||
override fun getFrameworkType(): FrameworkTypeEx = JSFrameworkType.instance
|
|
||||||
|
|
||||||
override fun createConfigurable(model: FrameworkSupportModel): FrameworkSupportInModuleConfigurable {
|
|
||||||
return object : FrameworkSupportInModuleConfigurable() {
|
|
||||||
lateinit var description: JSLibraryStdDescription
|
|
||||||
|
|
||||||
override fun createLibraryDescription(): CustomLibraryDescription? {
|
|
||||||
description = JSLibraryStdDescription(model.project)
|
|
||||||
return description
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun createComponent(): JComponent? = null
|
|
||||||
|
|
||||||
override fun isOnlyLibraryAdded(): Boolean = true
|
|
||||||
|
|
||||||
override fun addSupport(
|
|
||||||
module: Module,
|
|
||||||
rootModel: ModifiableRootModel,
|
|
||||||
modifiableModelsProvider: ModifiableModelsProvider) {
|
|
||||||
FrameworksCompatibilityUtils.suggestRemoveIncompatibleFramework(
|
|
||||||
rootModel,
|
|
||||||
JavaRuntimeLibraryDescription.SUITABLE_LIBRARY_KINDS,
|
|
||||||
JavaFrameworkType.instance)
|
|
||||||
|
|
||||||
description.finishLibConfiguration(module, rootModel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onFrameworkSelectionChanged(selected: Boolean) {
|
|
||||||
if (selected) {
|
|
||||||
val providerId = JavaFrameworkType.instance.id
|
|
||||||
if (model.isFrameworkSelected(providerId)) {
|
|
||||||
model.setFrameworkComponentEnabled(providerId, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun isEnabledForModuleType(moduleType: ModuleType<*>): Boolean = moduleType is JavaModuleType
|
|
||||||
|
|
||||||
override fun canAddSupport(module: Module, facetsProvider: FacetsProvider): Boolean {
|
|
||||||
return super.canAddSupport(module, facetsProvider) && module.getBuildSystemType() == BuildSystemType.JPS
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 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.idea.framework
|
|
||||||
|
|
||||||
import com.intellij.framework.FrameworkTypeEx
|
|
||||||
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinIcons
|
|
||||||
import javax.swing.Icon
|
|
||||||
|
|
||||||
class JSFrameworkType : FrameworkTypeEx("kotlin-js-framework-id") {
|
|
||||||
|
|
||||||
override fun createProvider(): FrameworkSupportInModuleProvider = JSFrameworkSupportProvider()
|
|
||||||
|
|
||||||
override fun getPresentableName() = "Kotlin/\u200BJS"
|
|
||||||
|
|
||||||
override fun getIcon(): Icon = KotlinIcons.JS
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val instance: JSFrameworkType
|
|
||||||
get() = FrameworkTypeEx.EP_NAME.findExtension(JSFrameworkType::class.java)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-2
@@ -43,14 +43,14 @@ class JavaFrameworkSupportProvider : FrameworkSupportInModuleProvider() {
|
|||||||
FrameworksCompatibilityUtils.suggestRemoveIncompatibleFramework(
|
FrameworksCompatibilityUtils.suggestRemoveIncompatibleFramework(
|
||||||
rootModel,
|
rootModel,
|
||||||
JSLibraryStdDescription.SUITABLE_LIBRARY_KINDS,
|
JSLibraryStdDescription.SUITABLE_LIBRARY_KINDS,
|
||||||
JSFrameworkType.instance)
|
"Kotlin/\u200BJS")
|
||||||
|
|
||||||
description!!.finishLibConfiguration(module, rootModel)
|
description!!.finishLibConfiguration(module, rootModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFrameworkSelectionChanged(selected: Boolean) {
|
override fun onFrameworkSelectionChanged(selected: Boolean) {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
val providerId = JSFrameworkType.instance.id
|
val providerId = "kotlin-js-framework-id"
|
||||||
if (model.isFrameworkSelected(providerId)) {
|
if (model.isFrameworkSelected(providerId)) {
|
||||||
model.setFrameworkComponentEnabled(providerId, false)
|
model.setFrameworkComponentEnabled(providerId, false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,6 @@
|
|||||||
<debugger.simplePropertyGetterProvider implementation="org.jetbrains.kotlin.idea.debugger.stepping.KotlinSimpleGetterProvider"/>
|
<debugger.simplePropertyGetterProvider implementation="org.jetbrains.kotlin.idea.debugger.stepping.KotlinSimpleGetterProvider"/>
|
||||||
|
|
||||||
<framework.type implementation="org.jetbrains.kotlin.idea.framework.JavaFrameworkType"/>
|
<framework.type implementation="org.jetbrains.kotlin.idea.framework.JavaFrameworkType"/>
|
||||||
<framework.type implementation="org.jetbrains.kotlin.idea.framework.JSFrameworkType"/>
|
|
||||||
<projectTemplatesFactory implementation="org.jetbrains.kotlin.idea.framework.KotlinTemplatesFactory" />
|
<projectTemplatesFactory implementation="org.jetbrains.kotlin.idea.framework.KotlinTemplatesFactory" />
|
||||||
|
|
||||||
<library.presentationProvider implementation="org.jetbrains.kotlin.idea.framework.JavaRuntimePresentationProvider"/>
|
<library.presentationProvider implementation="org.jetbrains.kotlin.idea.framework.JavaRuntimePresentationProvider"/>
|
||||||
|
|||||||
-3
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.config.VersionView
|
|||||||
import org.jetbrains.kotlin.config.apiVersionView
|
import org.jetbrains.kotlin.config.apiVersionView
|
||||||
import org.jetbrains.kotlin.config.languageVersionView
|
import org.jetbrains.kotlin.config.languageVersionView
|
||||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||||
import org.jetbrains.kotlin.idea.framework.JSFrameworkSupportProvider
|
|
||||||
import org.jetbrains.kotlin.idea.framework.JavaFrameworkSupportProvider
|
import org.jetbrains.kotlin.idea.framework.JavaFrameworkSupportProvider
|
||||||
|
|
||||||
class KotlinFrameworkSupportProviderTest : FrameworkSupportProviderTestCase() {
|
class KotlinFrameworkSupportProviderTest : FrameworkSupportProviderTestCase() {
|
||||||
@@ -28,6 +27,4 @@ class KotlinFrameworkSupportProviderTest : FrameworkSupportProviderTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun testJvm() = doTest(JavaFrameworkSupportProvider())
|
fun testJvm() = doTest(JavaFrameworkSupportProvider())
|
||||||
|
|
||||||
fun testJs() = doTest(JSFrameworkSupportProvider())
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user