Improved finding usages.

This commit is contained in:
Rik van der Kleij 2019-06-21 12:00:45 +02:00
parent f9cc57e1e8
commit 503dbcd5dd
4 changed files with 12 additions and 3 deletions

View File

@ -44,7 +44,7 @@ private[component] object BrowseModuleComponent {
private def matchResult(key: Key, result: Future[BrowseModuleInternalResult])(implicit ec: ExecutionContext): Future[Option[Iterable[ModuleIdentifier]]] = {
concurrent.blocking(result.map {
case Right(ids) => Some(ids)
case Left(NoInfoAvailable(_, _)) =>
case Left(NoInfoAvailable(_, _)) | Left(NoMatchingExport) =>
None
case Left(ReplNotAvailable) | Left(IndexNotReady) | Left(ModuleNotAvailable(_)) | Left(ReadActionTimeout(_)) =>
Cache.synchronous().invalidate(key)

View File

@ -219,6 +219,7 @@ private[component] object DefinitionLocationComponent {
} else {
f(repl) match {
case Some(o) if o.stderrLines.isEmpty && o.stdoutLines.nonEmpty => Right(o.stdoutLines)
case Some(o) if o.stderrLines.mkString.contains("No matching export in any local modules.") => Left(NoMatchingExport)
case Some(o) if o.stdoutLines.isEmpty && o.stderrLines.nonEmpty => Right(o.stderrLines) // For some unknown reason REPL write sometimes correct output to stderr
case None => Left(ReplNotAvailable)
case _ => Left(NoInfoAvailable(name, psiFile.getName))
@ -233,6 +234,10 @@ private[component] object DefinitionLocationComponent {
case Some(r) => r
case None => Left(NoInfoAvailable(name, key.psiFile.getName))
}
case Left(NoMatchingExport) => HaskellReference.findIdentifierInFileByName(psiFile, name) match {
case Some(ne) => Right(LocalModuleLocation(psiFile, ne, name))
case None => Left(NoInfoAvailable(name, psiFile.getName))
}
case Left(noInfo) => Left(noInfo)
}
}

View File

@ -119,7 +119,7 @@ private[component] object TypeInfoComponent {
Cache.getIfPresent(key) match {
case Some(result) => result match {
case Right(_) => result
case Left(NoInfoAvailable(_, _)) =>
case Left(NoInfoAvailable(_, _)) | Left(NoMatchingExport) =>
result
case Left(ReplNotAvailable) | Left(IndexNotReady) | Left(ModuleNotAvailable(_)) | Left(ReadActionTimeout(_)) =>
Cache.invalidate(key)
@ -130,7 +130,7 @@ private[component] object TypeInfoComponent {
result match {
case Right(_) =>
result
case Left(NoInfoAvailable(_, _)) =>
case Left(NoInfoAvailable(_, _)) | Left(NoMatchingExport) =>
result
case Left(ReplNotAvailable) | Left(IndexNotReady) | Left(ModuleNotAvailable(_)) | Left(ReadActionTimeout(_)) =>
Cache.invalidate(key)

View File

@ -26,4 +26,8 @@ package object component {
def message = s"No info because read action timed out while $readActionDescription"
}
// GHCi output: No matching export in any local modules.
case object NoMatchingExport extends NoInfo {
def message: String = "No matching export in any local modules"
}
}