Enabling Haskell custom tools should be all or nothing.

This commit is contained in:
Rik van der Kleij 2019-08-04 21:43:52 +02:00
parent 35999bff4b
commit 607d8795a1
3 changed files with 22 additions and 12 deletions

View File

@ -26,9 +26,8 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.projectRoots.ProjectJdkTable
import com.intellij.openapi.roots.{ModifiableRootModel, ModuleRootModificationUtil}
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.vfs.VirtualFileManager
import intellij.haskell.action.{HaskellReformatAction, HindentReformatAction, StylishHaskellReformatAction}
import intellij.haskell.action.HaskellReformatAction
import intellij.haskell.annotator.HaskellAnnotator
import intellij.haskell.external.execution.StackCommandLine
import intellij.haskell.external.repl.StackRepl.LibType
@ -111,7 +110,7 @@ object StackProjectManager {
ProgressManager.getInstance().run(new Task.Backgroundable(project, title, false, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
private def isToolAvailable(progressIndicator: ProgressIndicator, tool: HTool) = {
HaskellSettingsState.useCustomTool(tool) || {
HaskellSettingsState.useCustomTools || {
if (!GlobalInfo.toolPath(tool).exists() || update) {
progressIndicator.setText(s"Busy with installing ${tool.name} in ${GlobalInfo.toolsBinPath}")
StackCommandLine.installTool(project, tool.name)

View File

@ -21,7 +21,7 @@ import java.awt.{GridBagConstraints, GridBagLayout, Insets}
import com.intellij.openapi.options.{Configurable, ConfigurationException}
import com.intellij.ui.DocumentAdapter
import javax.swing._
import javax.swing.event.{ChangeListener, DocumentEvent}
import javax.swing.event.DocumentEvent
class HaskellConfigurable extends Configurable {
private var isModifiedByUser = false
@ -123,7 +123,7 @@ class HaskellConfigurable extends Configurable {
(new JLabel(BuildToolsUsingSystemGhc), useSystemGhcToggle),
(new JLabel(UseCustomTool), useCustomToolsToggle),
(new JLabel(""), afterRestartLabel),
(new JLabel(""), {
(new JLabel(""), {
val x = new JTextArea(PathWarning)
x.setLineWrap(true)
x.setWrapStyleWord(true)
@ -151,6 +151,9 @@ class HaskellConfigurable extends Configurable {
val validREPLTimeout = validateREPLTimeout()
val state = HaskellSettingsPersistentStateComponent.getInstance().getState
validateCustomTools()
state.replTimeout = validREPLTimeout
state.hlintOptions = hlintOptionsField.getText
state.useSystemGhc = useSystemGhcToggle.isSelected
@ -175,6 +178,18 @@ class HaskellConfigurable extends Configurable {
timeout
}
private def validateCustomTools(): Unit = {
if (useCustomToolsToggle.isSelected) {
if (hindentPathField.getText.trim.isEmpty ||
hlintPathField.getText.trim.isEmpty ||
hooglePathField.getText.trim.isEmpty ||
stylishHaskellPathField.getText.trim.isEmpty) {
throw new ConfigurationException(s"All Haskell tools paths have to be set")
}
}
}
override def disposeUIResources(): Unit = {}
override def getHelpTopic: String = ""

View File

@ -16,8 +16,6 @@
package intellij.haskell.settings
import intellij.haskell.HTool
object HaskellSettingsState {
private def state = HaskellSettingsPersistentStateComponent.getInstance().getState
@ -73,10 +71,8 @@ object HaskellSettingsState {
Option.when(customTools && state.stylishHaskellPath.nonEmpty)(state.stylishHaskellPath)
}
def useCustomTool(tool: HTool): Boolean = tool match {
case HTool.Hindent => hindentPath.isDefined
case HTool.Hlint => hlintPath.isDefined
case HTool.Hoogle => hooglePath.isDefined
case HTool.StylishHaskell => stylishHaskellPath.isDefined
def useCustomTools: Boolean = {
state.customTools
}
}