Various improvements.

This commit is contained in:
Rik van der Kleij 2019-02-05 20:15:34 +01:00
parent 47dbe78f9e
commit 05d710b4cd
7 changed files with 24 additions and 10 deletions

View File

@ -480,6 +480,12 @@ object FileModuleIdentifiers {
Cache.refresh(Key(psiFile))
}
// Invalidate files which have imported this module
def invalidate(moduleName: String): Unit = {
val keys = Cache.asMap().filter { case (_, v) => v.exists(_.exists(_.exists(_.exists(_.moduleName == moduleName)))) }.keys
Cache.invalidateAll(keys)
}
def invalidateAll(project: Project): Unit = {
Cache.asMap().filter(_._1.psiFile.getProject == project).keys.foreach(Cache.invalidate)
}
@ -498,7 +504,7 @@ object FileModuleIdentifiers {
case None =>
if (ApplicationManager.getApplication.isReadAccessAllowed) {
val f = Future(Cache.get(key))
ScalaFutureUtil.waitWithCheckCancelled(psiFile.getProject, f, "getModuleIdentifiers", 4900.millis).flatten match {
ScalaFutureUtil.waitWithCheckCancelled(psiFile.getProject, f, "getModuleIdentifiers", 5.seconds).flatten match {
case Some(x) =>
if (x.toSeq.contains(None)) {
Cache.invalidate(key)

View File

@ -33,7 +33,7 @@ object HLintComponent {
final val HLintName = "hlint"
private final val HLintPath = GlobalInfo.toolPath(HLintName).toString
private final val Timeout = 1.second
private final val Timeout = 500.millis
def check(psiFile: PsiFile): Seq[HLintInfo] = {
if (StackProjectManager.isHlintAvailable(psiFile.getProject)) {

View File

@ -88,8 +88,9 @@ private[component] object LoadComponent {
NameInfoComponent.invalidate(psiFile)
moduleName.foreach(mn => {
BrowseModuleComponent.invalidateTopLevel(project, mn, psiFile)
FileModuleIdentifiers.refresh(psiFile)
BrowseModuleComponent.invalidateExportedModuleName(project, mn)
FileModuleIdentifiers.refresh(psiFile)
FileModuleIdentifiers.invalidate(mn)
})
}

View File

@ -172,6 +172,9 @@ object StackProjectManager {
StackReplsManager.getGlobalRepl(project).foreach(_.exit())
projectRepsl.foreach(_.exit())
// Wait a moment otherwise REPLs (sometime s) will not start yet
Thread.sleep(1000)
progressIndicator.setText("Busy with cleaning up cache")
HaskellComponentsManager.invalidateGlobalCaches(project)

View File

@ -71,14 +71,14 @@ object StackCommandLine {
Seq("--system-ghc")
}
val arguments = systemGhcOption ++ Seq("-j1", "--stack-root", toolsStackRootPath.getPath, "--resolver", StackageLtsVersion, "--compiler", "ghc-8.4.4", "--local-bin-path", toolsBinPath.getPath, "install", toolName)
val processOutput = run(project, arguments, -1, logOutput = true, notifyBalloonError = true, workDir = Some(VfsUtil.getUserHomeDir.getPath))
val processOutput = run(project, arguments, -1, logOutput = true, notifyBalloonError = true, workDir = Some(VfsUtil.getUserHomeDir.getPath), enableExtraArguments = false)
processOutput.exists(o => o.getExitCode == 0 && !o.isTimeout)
}
def updateStackIndex(project: Project): Option[ProcessOutput] = {
import intellij.haskell.GlobalInfo._
val arguments = Seq("update", "--stack-root", toolsStackRootPath.getPath)
run(project, arguments, -1, logOutput = true, notifyBalloonError = true)
run(project, arguments, -1, logOutput = true, notifyBalloonError = true, enableExtraArguments = false)
}
def build(project: Project, buildTargets: Seq[String]): Option[ProcessOutput] = {

View File

@ -129,11 +129,13 @@ case class ProjectStackRepl(project: Project, stackComponentInfo: StackComponent
}
}
private final val FailedModuleLoaded = "Failed, modules loaded: "
private final val OkModulesLoaded = "Ok, modules loaded: "
private def setLoadedModules(o: StackReplOutput): Unit = {
loadedDependentModules.clear()
val loadedModuleNames = o.stdoutLines.find(l => l.startsWith(OkModulesLoaded)).map(findLoadedModuleNames).getOrElse(Array())
val loadedModuleNames = o.stdoutLines.find(l => l.startsWith(OkModulesLoaded) || l.startsWith(FailedModuleLoaded)).map(findLoadedModuleNames).getOrElse(Array())
loadedModuleNames.foreach(mn => loadedDependentModules.put(mn, DependentModuleInfo()))
loadedModuleNames.foreach(mn => everLoadedDependentModules.put(mn, DependentModuleInfo()))
}
@ -173,10 +175,12 @@ case class ProjectStackRepl(project: Project, stackComponentInfo: StackComponent
}
private def findLoadedModuleNames(line: String): Array[String] = {
if (line == "none") {
Array()
} else {
if (line.startsWith(OkModulesLoaded)) {
line.replace(OkModulesLoaded, "").init.split(",").map(_.trim)
} else if (line.startsWith(FailedModuleLoaded)) {
line.replace(FailedModuleLoaded, "").init.split(",").map(_.trim)
} else {
Array()
}
}

View File

@ -34,7 +34,7 @@ object ApplicationUtil {
}
}
private final val RunInReadActionTimeout = 5.seconds
private final val RunInReadActionTimeout = 20.millis
def runInReadActionWithWriteActionPriority[A](project: Project, f: => A, readActionDescription: => String, timeout: FiniteDuration = RunInReadActionTimeout): Either[NoInfo, A] = {
val r = new AtomicReference[A]