Merge pull request #4497 from tdroxler/feature/preserve-error-order

Preserve errors order when publishing diagnostics
This commit is contained in:
eugene yokota 2019-01-04 10:48:01 -05:00 committed by GitHub
commit ed1200a763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -582,6 +582,8 @@ lazy val mainProj = (project in file("main"))
mimaBinaryIssueFilters ++= Vector(
// New and changed methods on KeyIndex. internal.
exclude[ReversedMissingMethodProblem]("sbt.internal.KeyIndex.*"),
// internal
exclude[IncompatibleMethTypeProblem]("sbt.internal.server.LanguageServerReporter.*"),
// Changed signature or removed private[sbt] methods
exclude[DirectMissingMethodProblem]("sbt.Classpaths.unmanagedLibs0"),

View File

@ -40,7 +40,7 @@ class LanguageServerReporter(
) extends ManagedLoggedReporter(maximumErrors, logger, sourcePositionMapper) {
lazy val exchange = StandardMain.exchange
private[sbt] lazy val problemsByFile = new mutable.HashMap[File, List[Problem]]
private[sbt] lazy val problemsByFile = new mutable.HashMap[File, mutable.ListBuffer[Problem]]
override def reset(): Unit = {
super.reset()
@ -51,8 +51,8 @@ class LanguageServerReporter(
val pos = problem.position
pos.sourceFile.toOption foreach { sourceFile: File =>
problemsByFile.get(sourceFile) match {
case Some(xs: List[Problem]) => problemsByFile(sourceFile) = problem :: xs
case _ => problemsByFile(sourceFile) = List(problem)
case Some(xs: mutable.ListBuffer[Problem]) => problemsByFile(sourceFile) = xs :+ problem
case _ => problemsByFile(sourceFile) = mutable.ListBuffer(problem)
}
}
super.log(problem)
@ -93,7 +93,7 @@ class LanguageServerReporter(
val pos = problem.position
pos.sourceFile.toOption foreach { sourceFile: File =>
problemsByFile.get(sourceFile) match {
case Some(xs: List[Problem]) =>
case Some(xs: mutable.ListBuffer[Problem]) =>
val ds = toDiagnostics(xs)
val params = PublishDiagnosticsParams(IO.toURI(sourceFile).toString, ds)
exchange.notifyEvent("textDocument/publishDiagnostics", params)
@ -102,7 +102,7 @@ class LanguageServerReporter(
}
}
private[sbt] def toDiagnostics(ps: List[Problem]): Vector[Diagnostic] = {
private[sbt] def toDiagnostics(ps: Seq[Problem]): Vector[Diagnostic] = {
for {
problem <- ps.toVector
pos = problem.position