Kotlin Facet: Add custom settings and configuration extension point
This commit is contained in:
@@ -34,5 +34,7 @@
|
||||
<extensionPoint name="scriptTemplatesProvider"
|
||||
interface="org.jetbrains.kotlin.script.ScriptTemplatesProvider"
|
||||
area="IDEA_PROJECT"/>
|
||||
<extensionPoint name="facetConfigurationExtension"
|
||||
interface="org.jetbrains.kotlin.idea.facet.KotlinFacetConfigurationExtension"/>
|
||||
</extensionPoints>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -21,8 +21,10 @@ import com.intellij.facet.ui.FacetEditorContext
|
||||
import com.intellij.facet.ui.FacetEditorTab
|
||||
import com.intellij.facet.ui.FacetValidatorsManager
|
||||
import com.intellij.openapi.components.PersistentStateComponent
|
||||
import com.intellij.openapi.util.Key
|
||||
import org.jdom.Element
|
||||
import org.jetbrains.kotlin.idea.util.DescriptionAware
|
||||
import java.util.*
|
||||
|
||||
class KotlinFacetConfiguration : FacetConfiguration, PersistentStateComponent<KotlinFacetConfiguration.Settings> {
|
||||
enum class LanguageLevel(override val description: String) : DescriptionAware {
|
||||
@@ -62,5 +64,9 @@ class KotlinFacetConfiguration : FacetConfiguration, PersistentStateComponent<Ko
|
||||
override fun createEditorTabs(
|
||||
editorContext: FacetEditorContext,
|
||||
validatorsManager: FacetValidatorsManager
|
||||
): Array<FacetEditorTab> = arrayOf(KotlinFacetEditorTab(this, editorContext, validatorsManager))
|
||||
): Array<FacetEditorTab> {
|
||||
val tabs = arrayListOf<FacetEditorTab>(KotlinFacetEditorTab(this, editorContext, validatorsManager))
|
||||
KotlinFacetConfigurationExtension.EP_NAME.extensions.flatMapTo(tabs) { it.createEditorTabs(editorContext, validatorsManager) }
|
||||
return tabs.toTypedArray()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.idea.facet
|
||||
|
||||
import com.intellij.facet.ui.FacetEditorContext
|
||||
import com.intellij.facet.ui.FacetEditorTab
|
||||
import com.intellij.facet.ui.FacetValidatorsManager
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
|
||||
interface KotlinFacetConfigurationExtension {
|
||||
companion object {
|
||||
val EP_NAME: ExtensionPointName<KotlinFacetConfigurationExtension> = ExtensionPointName.create("org.jetbrains.kotlin.facetConfigurationExtension")!!
|
||||
}
|
||||
|
||||
fun createEditorTabs(editorContext: FacetEditorContext, validatorsManager: FacetValidatorsManager): List<FacetEditorTab>
|
||||
}
|
||||
@@ -146,7 +146,7 @@ class KotlinFacetEditorTab(
|
||||
configuration.state.targetPlatformKind = targetPlatformComboBox.selectedItem as KotlinFacetConfiguration.TargetPlatform?
|
||||
}
|
||||
|
||||
override fun getDisplayName() = "Kotlin"
|
||||
override fun getDisplayName() = "General"
|
||||
|
||||
override fun createComponent(): JComponent {
|
||||
val mainPanel = JPanel(BorderLayout())
|
||||
|
||||
Reference in New Issue
Block a user