Makes 'system-ghc' Stack option configurable

This commit is contained in:
Daniel Brice 2019-07-18 18:46:34 -07:00
parent 4778d10bc4
commit 464406637b
4 changed files with 13 additions and 2 deletions

View File

@ -29,6 +29,7 @@ import com.intellij.openapi.util.Key
import com.intellij.openapi.vfs.{CharsetToolkit, VfsUtil}
import intellij.haskell.HaskellNotificationGroup
import intellij.haskell.sdk.HaskellSdkType
import intellij.haskell.settings.HaskellSettingsState
import intellij.haskell.stackyaml.StackYamlComponent
import intellij.haskell.util.{HaskellFileUtil, HaskellProjectUtil}
@ -60,7 +61,7 @@ object StackCommandLine {
def installTool(project: Project, toolName: String): Boolean = {
import intellij.haskell.GlobalInfo._
val systemGhcOption = if (StackYamlComponent.isNixEnabled(project)) {
val systemGhcOption = if (StackYamlComponent.isNixEnabled(project) || !HaskellSettingsState.useSystemGhc) {
Seq()
} else {
Seq("--system-ghc")

View File

@ -26,6 +26,7 @@ import javax.swing.event.DocumentEvent
class HaskellConfigurable extends Configurable {
private var isModifiedByUser = false
private val hlintOptionsField = new JTextField
private val useSystemGhcToggle = new JCheckBox
private val replTimeoutField = new JTextField
private val replTimeoutLabel = new JLabel("Changed timeout will take effect after restarting project")
private val newProjectTemplateNameField = new JTextField
@ -92,6 +93,7 @@ class HaskellConfigurable extends Configurable {
addLabeledControl(2, ReplTimeout, replTimeoutField)
addLabeledControl(3, "", replTimeoutLabel)
addLabeledControl(4, NewProjectTemplateName, newProjectTemplateNameField)
addLabeledControl(5, BuildToolsUsingSystemGhc, useSystemGhcToggle)
settingsPanel.add(new JPanel(), baseGridBagConstraints.setConstraints(
gridx = 0,
@ -107,6 +109,7 @@ class HaskellConfigurable extends Configurable {
val state = HaskellSettingsPersistentStateComponent.getInstance().getState
state.replTimeout = validREPLTimeout
state.hlintOptions = hlintOptionsField.getText
state.useSystemGhc = useSystemGhcToggle.isSelected
state.newProjectTemplateName = newProjectTemplateNameField.getText
}
@ -130,6 +133,7 @@ class HaskellConfigurable extends Configurable {
override def reset(): Unit = {
val state = HaskellSettingsPersistentStateComponent.getInstance().getState
hlintOptionsField.setText(state.hlintOptions)
useSystemGhcToggle.setSelected(state.useSystemGhc)
replTimeoutField.setText(state.replTimeout.toString)
newProjectTemplateNameField.setText(state.newProjectTemplateName)
}
@ -139,4 +143,5 @@ object HaskellConfigurable {
final val ReplTimeout = "Background REPL timeout in seconds"
final val HlintOptions = "Hlint options"
final val NewProjectTemplateName = "Template name for new project"
}
final val BuildToolsUsingSystemGhc = "Build tools using system GHC"
}

View File

@ -50,6 +50,7 @@ public class HaskellSettingsPersistentStateComponent implements PersistentStateC
static class HaskellSettingsState {
public Integer replTimeout = 30;
public String hlintOptions = "";
public Boolean useSystemGhc = true;
public Boolean reformatCodeBeforeCommit = false;
public Boolean optimizeImportsBeforeCommit = false;
public String newProjectTemplateName = "new-template";

View File

@ -27,6 +27,10 @@ object HaskellSettingsState {
state.hlintOptions
}
def useSystemGhc(): Boolean = {
state.useSystemGhc
}
def getNewProjectTemplateName: String = {
state.newProjectTemplateName
}