|
7 | 7 |
|
8 | 8 | package sbt.util
|
9 | 9 |
|
10 |
| -import xsbti.{ Position, Problem, Severity, T2 } |
11 | 10 | import java.io.File
|
12 | 11 | import java.util.Optional
|
13 | 12 | import java.util.function.Supplier
|
| 13 | +import java.{ util => ju } |
| 14 | + |
| 15 | +import xsbti.{ DiagnosticCode, DiagnosticRelatedInformation, Position, Problem, Severity, T2 } |
| 16 | + |
| 17 | +import scala.collection.mutable.ListBuffer |
14 | 18 |
|
15 | 19 | object InterfaceUtil {
|
16 | 20 | def toSupplier[A](a: => A): Supplier[A] = new Supplier[A] {
|
@@ -43,6 +47,18 @@ object InterfaceUtil {
|
43 | 47 | case None => Optional.empty[A]()
|
44 | 48 | }
|
45 | 49 |
|
| 50 | + def l2jl[A](l: List[A]): ju.List[A] = { |
| 51 | + val jl = new ju.ArrayList[A](l.size) |
| 52 | + l.foreach(jl.add(_)) |
| 53 | + jl |
| 54 | + } |
| 55 | + |
| 56 | + def jl2l[A](jl: ju.List[A]): List[A] = { |
| 57 | + val l = ListBuffer[A]() |
| 58 | + jl.forEach(l += _) |
| 59 | + l.toList |
| 60 | + } |
| 61 | + |
46 | 62 | @deprecated("Use the overload of this method with more arguments", "1.2.2")
|
47 | 63 | def position(
|
48 | 64 | line0: Option[Integer],
|
@@ -104,14 +120,26 @@ object InterfaceUtil {
|
104 | 120 | def problem(cat: String, pos: Position, msg: String, sev: Severity): Problem =
|
105 | 121 | problem(cat, pos, msg, sev, None)
|
106 | 122 |
|
| 123 | + @deprecated("Use the overload of this method with more arguments", "1.7.2") |
107 | 124 | def problem(
|
108 | 125 | cat: String,
|
109 | 126 | pos: Position,
|
110 | 127 | msg: String,
|
111 | 128 | sev: Severity,
|
112 | 129 | rendered: Option[String]
|
113 | 130 | ): Problem =
|
114 |
| - new ConcreteProblem(cat, pos, msg, sev, rendered) |
| 131 | + problem(cat, pos, msg, sev, None, None, List.empty[DiagnosticRelatedInformation]) |
| 132 | + |
| 133 | + def problem( |
| 134 | + cat: String, |
| 135 | + pos: Position, |
| 136 | + msg: String, |
| 137 | + sev: Severity, |
| 138 | + rendered: Option[String], |
| 139 | + diagnosticCode: Option[DiagnosticCode], |
| 140 | + diagnosticRelatedInforamation: List[DiagnosticRelatedInformation] |
| 141 | + ): Problem = |
| 142 | + new ConcreteProblem(cat, pos, msg, sev, rendered, diagnosticCode, diagnosticRelatedInforamation) |
115 | 143 |
|
116 | 144 | private final class ConcreteT2[A1, A2](a1: A1, a2: A2) extends T2[A1, A2] {
|
117 | 145 | val get1: A1 = a1
|
@@ -166,13 +194,18 @@ object InterfaceUtil {
|
166 | 194 | pos: Position,
|
167 | 195 | msg: String,
|
168 | 196 | sev: Severity,
|
169 |
| - rendered0: Option[String] |
| 197 | + rendered0: Option[String], |
| 198 | + diagnosticCode0: Option[DiagnosticCode], |
| 199 | + diagnosticRelatedInformation0: List[DiagnosticRelatedInformation] |
170 | 200 | ) extends Problem {
|
171 | 201 | val category = cat
|
172 | 202 | val position = pos
|
173 | 203 | val message = msg
|
174 | 204 | val severity = sev
|
175 | 205 | override val rendered = o2jo(rendered0)
|
| 206 | + override def diagnosticCode: Optional[DiagnosticCode] = o2jo(diagnosticCode0) |
| 207 | + override def diagnosticRelatedInforamation(): ju.List[DiagnosticRelatedInformation] = |
| 208 | + l2jl(diagnosticRelatedInformation0) |
176 | 209 | override def toString = s"[$severity] $pos: $message"
|
177 | 210 | }
|
178 | 211 | }
|
0 commit comments