mirror of https://github.com/sbt/sbt.git
Merge pull request #7039 from eed3si9n/bport/7006
[1.8.x] fix: also include diagnosticCode and related info in InterfaceUtil
This commit is contained in:
commit
abd9f13b6f
|
|
@ -7,10 +7,14 @@
|
||||||
|
|
||||||
package sbt.util
|
package sbt.util
|
||||||
|
|
||||||
import xsbti.{ Position, Problem, Severity, T2 }
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
import java.util.function.Supplier
|
import java.util.function.Supplier
|
||||||
|
import java.{ util => ju }
|
||||||
|
|
||||||
|
import xsbti.{ DiagnosticCode, DiagnosticRelatedInformation, Position, Problem, Severity, T2 }
|
||||||
|
|
||||||
|
import scala.collection.mutable.ListBuffer
|
||||||
|
|
||||||
object InterfaceUtil {
|
object InterfaceUtil {
|
||||||
def toSupplier[A](a: => A): Supplier[A] = new Supplier[A] {
|
def toSupplier[A](a: => A): Supplier[A] = new Supplier[A] {
|
||||||
|
|
@ -43,6 +47,18 @@ object InterfaceUtil {
|
||||||
case None => Optional.empty[A]()
|
case None => Optional.empty[A]()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def l2jl[A](l: List[A]): ju.List[A] = {
|
||||||
|
val jl = new ju.ArrayList[A](l.size)
|
||||||
|
l.foreach(jl.add(_))
|
||||||
|
jl
|
||||||
|
}
|
||||||
|
|
||||||
|
def jl2l[A](jl: ju.List[A]): List[A] = {
|
||||||
|
val l = ListBuffer[A]()
|
||||||
|
jl.forEach(l += _)
|
||||||
|
l.toList
|
||||||
|
}
|
||||||
|
|
||||||
@deprecated("Use the overload of this method with more arguments", "1.2.2")
|
@deprecated("Use the overload of this method with more arguments", "1.2.2")
|
||||||
def position(
|
def position(
|
||||||
line0: Option[Integer],
|
line0: Option[Integer],
|
||||||
|
|
@ -104,6 +120,7 @@ object InterfaceUtil {
|
||||||
def problem(cat: String, pos: Position, msg: String, sev: Severity): Problem =
|
def problem(cat: String, pos: Position, msg: String, sev: Severity): Problem =
|
||||||
problem(cat, pos, msg, sev, None)
|
problem(cat, pos, msg, sev, None)
|
||||||
|
|
||||||
|
@deprecated("Use the overload of this method with more arguments", "1.7.2")
|
||||||
def problem(
|
def problem(
|
||||||
cat: String,
|
cat: String,
|
||||||
pos: Position,
|
pos: Position,
|
||||||
|
|
@ -111,7 +128,18 @@ object InterfaceUtil {
|
||||||
sev: Severity,
|
sev: Severity,
|
||||||
rendered: Option[String]
|
rendered: Option[String]
|
||||||
): Problem =
|
): Problem =
|
||||||
new ConcreteProblem(cat, pos, msg, sev, rendered)
|
problem(cat, pos, msg, sev, rendered, None, List.empty[DiagnosticRelatedInformation])
|
||||||
|
|
||||||
|
def problem(
|
||||||
|
cat: String,
|
||||||
|
pos: Position,
|
||||||
|
msg: String,
|
||||||
|
sev: Severity,
|
||||||
|
rendered: Option[String],
|
||||||
|
diagnosticCode: Option[DiagnosticCode],
|
||||||
|
diagnosticRelatedInforamation: List[DiagnosticRelatedInformation]
|
||||||
|
): Problem =
|
||||||
|
new ConcreteProblem(cat, pos, msg, sev, rendered, diagnosticCode, diagnosticRelatedInforamation)
|
||||||
|
|
||||||
private final class ConcreteT2[A1, A2](a1: A1, a2: A2) extends T2[A1, A2] {
|
private final class ConcreteT2[A1, A2](a1: A1, a2: A2) extends T2[A1, A2] {
|
||||||
val get1: A1 = a1
|
val get1: A1 = a1
|
||||||
|
|
@ -166,13 +194,18 @@ object InterfaceUtil {
|
||||||
pos: Position,
|
pos: Position,
|
||||||
msg: String,
|
msg: String,
|
||||||
sev: Severity,
|
sev: Severity,
|
||||||
rendered0: Option[String]
|
rendered0: Option[String],
|
||||||
|
diagnosticCode0: Option[DiagnosticCode],
|
||||||
|
diagnosticRelatedInformation0: List[DiagnosticRelatedInformation]
|
||||||
) extends Problem {
|
) extends Problem {
|
||||||
val category = cat
|
val category = cat
|
||||||
val position = pos
|
val position = pos
|
||||||
val message = msg
|
val message = msg
|
||||||
val severity = sev
|
val severity = sev
|
||||||
override val rendered = o2jo(rendered0)
|
override val rendered = o2jo(rendered0)
|
||||||
|
override def diagnosticCode: Optional[DiagnosticCode] = o2jo(diagnosticCode0)
|
||||||
|
override def diagnosticRelatedInforamation(): ju.List[DiagnosticRelatedInformation] =
|
||||||
|
l2jl(diagnosticRelatedInformation0)
|
||||||
override def toString = s"[$severity] $pos: $message"
|
override def toString = s"[$severity] $pos: $message"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue