mirror of
https://github.com/ilyakooo0/intellij-haskell.git
synced 2024-09-11 14:56:19 +03:00
Enabling Haskell custom tools should be all or nothing.
This commit is contained in:
parent
35999bff4b
commit
607d8795a1
@ -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)
|
||||
|
@ -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 = ""
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user