Kotlin Facet: Show project-level settings when "Use project settings" is selected
#KT-16023 Fixed
This commit is contained in:
+28
-4
@@ -69,14 +69,14 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_UMD, "UMD (detect AMD or CommonJS if available, fallback to plain)");
|
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_UMD, "UMD (detect AMD or CommonJS if available, fallback to plain)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final CommonCompilerArguments commonCompilerArguments;
|
|
||||||
private final K2JSCompilerArguments k2jsCompilerArguments;
|
|
||||||
private final K2JVMCompilerArguments k2jvmCompilerArguments;
|
|
||||||
private final CompilerSettings compilerSettings;
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final KotlinCompilerWorkspaceSettings compilerWorkspaceSettings;
|
private final KotlinCompilerWorkspaceSettings compilerWorkspaceSettings;
|
||||||
private final Project project;
|
private final Project project;
|
||||||
private final boolean isProjectSettings;
|
private final boolean isProjectSettings;
|
||||||
|
private CommonCompilerArguments commonCompilerArguments;
|
||||||
|
private K2JSCompilerArguments k2jsCompilerArguments;
|
||||||
|
private K2JVMCompilerArguments k2jvmCompilerArguments;
|
||||||
|
private CompilerSettings compilerSettings;
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
||||||
private ThreeStateCheckBox generateNoWarningsCheckBox;
|
private ThreeStateCheckBox generateNoWarningsCheckBox;
|
||||||
private RawCommandLineEditor additionalArgsOptionsField;
|
private RawCommandLineEditor additionalArgsOptionsField;
|
||||||
@@ -508,11 +508,35 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
|||||||
UIUtil.setEnabled(getContentPane(), value, true);
|
UIUtil.setEnabled(getContentPane(), value, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommonCompilerArguments getCommonCompilerArguments() {
|
||||||
|
return commonCompilerArguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommonCompilerArguments(CommonCompilerArguments commonCompilerArguments) {
|
||||||
|
this.commonCompilerArguments = commonCompilerArguments;
|
||||||
|
}
|
||||||
|
|
||||||
public K2JSCompilerArguments getK2jsCompilerArguments() {
|
public K2JSCompilerArguments getK2jsCompilerArguments() {
|
||||||
return k2jsCompilerArguments;
|
return k2jsCompilerArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setK2jsCompilerArguments(K2JSCompilerArguments k2jsCompilerArguments) {
|
||||||
|
this.k2jsCompilerArguments = k2jsCompilerArguments;
|
||||||
|
}
|
||||||
|
|
||||||
public K2JVMCompilerArguments getK2jvmCompilerArguments() {
|
public K2JVMCompilerArguments getK2jvmCompilerArguments() {
|
||||||
return k2jvmCompilerArguments;
|
return k2jvmCompilerArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setK2jvmCompilerArguments(K2JVMCompilerArguments k2jvmCompilerArguments) {
|
||||||
|
this.k2jvmCompilerArguments = k2jvmCompilerArguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompilerSettings getCompilerSettings() {
|
||||||
|
return compilerSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompilerSettings(CompilerSettings compilerSettings) {
|
||||||
|
this.compilerSettings = compilerSettings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,7 @@ import com.intellij.util.ui.FormBuilder
|
|||||||
import com.intellij.util.ui.ThreeStateCheckBox
|
import com.intellij.util.ui.ThreeStateCheckBox
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.*
|
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.*
|
||||||
import org.jetbrains.kotlin.idea.compiler.configuration.Kotlin2JsCompilerArgumentsHolder
|
import org.jetbrains.kotlin.idea.compiler.configuration.*
|
||||||
import org.jetbrains.kotlin.idea.compiler.configuration.Kotlin2JvmCompilerArgumentsHolder
|
|
||||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCompilerConfigurableTab
|
|
||||||
import java.awt.BorderLayout
|
import java.awt.BorderLayout
|
||||||
import javax.swing.JComboBox
|
import javax.swing.JComboBox
|
||||||
import javax.swing.JComponent
|
import javax.swing.JComponent
|
||||||
@@ -40,41 +38,46 @@ class KotlinFacetEditorGeneralTab(
|
|||||||
validatorsManager: FacetValidatorsManager
|
validatorsManager: FacetValidatorsManager
|
||||||
) : FacetEditorTab() {
|
) : FacetEditorTab() {
|
||||||
class EditorComponent(
|
class EditorComponent(
|
||||||
project: Project,
|
private val project: Project,
|
||||||
configuration: KotlinFacetConfiguration?
|
configuration: KotlinFacetConfiguration?
|
||||||
) : JPanel(BorderLayout()) {
|
) : JPanel(BorderLayout()) {
|
||||||
private val isMultiEditor = configuration == null
|
private val isMultiEditor = configuration == null
|
||||||
|
|
||||||
val compilerConfigurable = with(configuration?.settings) {
|
var editableCommonArguments: CommonCompilerArguments
|
||||||
|
var editableJvmArguments: K2JVMCompilerArguments
|
||||||
|
var editableJsArguments: K2JSCompilerArguments
|
||||||
|
var editableCompilerSettings: CompilerSettings
|
||||||
|
|
||||||
|
val compilerConfigurable: KotlinCompilerConfigurableTab
|
||||||
|
|
||||||
|
init {
|
||||||
if (isMultiEditor) {
|
if (isMultiEditor) {
|
||||||
KotlinCompilerConfigurableTab(
|
editableCommonArguments = object : CommonCompilerArguments() {}
|
||||||
project,
|
editableJvmArguments = K2JVMCompilerArguments()
|
||||||
object : CommonCompilerArguments() {},
|
editableJsArguments = K2JSCompilerArguments()
|
||||||
K2JSCompilerArguments(),
|
editableCompilerSettings = CompilerSettings()
|
||||||
K2JVMCompilerArguments(),
|
|
||||||
CompilerSettings(),
|
|
||||||
null,
|
|
||||||
false,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val compilerArguments = configuration!!.settings.compilerArguments!!
|
editableCommonArguments = configuration!!.settings.compilerArguments!!
|
||||||
val k2jvmCompilerArguments = compilerArguments as? K2JVMCompilerArguments
|
editableJvmArguments = editableCommonArguments as? K2JVMCompilerArguments
|
||||||
?: copyBean(Kotlin2JvmCompilerArgumentsHolder.getInstance(project).settings)
|
?: copyBean(Kotlin2JvmCompilerArgumentsHolder.getInstance(project).settings)
|
||||||
val k2jsCompilerArguments = compilerArguments as? K2JSCompilerArguments
|
editableJsArguments = editableCommonArguments as? K2JSCompilerArguments
|
||||||
?: copyBean(Kotlin2JsCompilerArgumentsHolder.getInstance(project).settings)
|
?: copyBean(Kotlin2JsCompilerArgumentsHolder.getInstance(project).settings)
|
||||||
KotlinCompilerConfigurableTab(
|
editableCompilerSettings = configuration.settings.compilerSettings!!
|
||||||
project,
|
|
||||||
compilerArguments,
|
|
||||||
k2jsCompilerArguments,
|
|
||||||
k2jvmCompilerArguments,
|
|
||||||
configuration.settings.compilerSettings!!,
|
|
||||||
null,
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compilerConfigurable = KotlinCompilerConfigurableTab(
|
||||||
|
project,
|
||||||
|
editableCommonArguments,
|
||||||
|
editableJsArguments,
|
||||||
|
editableJvmArguments,
|
||||||
|
editableCompilerSettings,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
isMultiEditor
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val useProjectSettingsCheckBox = ThreeStateCheckBox("Use project settings").apply { isThirdStateEnabled = isMultiEditor }
|
val useProjectSettingsCheckBox = ThreeStateCheckBox("Use project settings").apply { isThirdStateEnabled = isMultiEditor }
|
||||||
@@ -103,8 +106,22 @@ class KotlinFacetEditorGeneralTab(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun updateCompilerConfigurable() {
|
internal fun updateCompilerConfigurable() {
|
||||||
|
val useProjectSettings = useProjectSettingsCheckBox.isSelected
|
||||||
compilerConfigurable.setTargetPlatform(chosenPlatform)
|
compilerConfigurable.setTargetPlatform(chosenPlatform)
|
||||||
compilerConfigurable.setEnabled(!useProjectSettingsCheckBox.isSelected)
|
compilerConfigurable.setEnabled(!useProjectSettings)
|
||||||
|
if (useProjectSettings) {
|
||||||
|
compilerConfigurable.commonCompilerArguments = copyBean(KotlinCommonCompilerArgumentsHolder.getInstance(project).settings)
|
||||||
|
compilerConfigurable.k2jvmCompilerArguments = copyBean(Kotlin2JvmCompilerArgumentsHolder.getInstance(project).settings)
|
||||||
|
compilerConfigurable.k2jsCompilerArguments = copyBean(Kotlin2JsCompilerArgumentsHolder.getInstance(project).settings)
|
||||||
|
compilerConfigurable.compilerSettings = copyBean(KotlinCompilerSettings.getInstance(project).settings)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
compilerConfigurable.commonCompilerArguments = editableCommonArguments
|
||||||
|
compilerConfigurable.k2jvmCompilerArguments = editableJvmArguments
|
||||||
|
compilerConfigurable.k2jsCompilerArguments = editableJsArguments
|
||||||
|
compilerConfigurable.compilerSettings = editableCompilerSettings
|
||||||
|
}
|
||||||
|
compilerConfigurable.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
val chosenPlatform: TargetPlatformKind<*>?
|
val chosenPlatform: TargetPlatformKind<*>?
|
||||||
|
|||||||
Reference in New Issue
Block a user