Skip to content

Commit 3abebb7

Browse files
ckipp01eed3si9n
authored andcommitted
fix: also include diagnosticCode and related info in InterfaceUtil
Looks like I missed this in sbt#6874 and I hit on it in Mill when I couldn't figure out why it was also empty, and thanks to @adpi realized it was because of the `LoggedReporter` in zinc not taking it into account. However before I can bump that this needs to be bumped as well. refs: scala/scala3#14904
1 parent d720c53 commit 3abebb7

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

internal/util-logging/src/main/scala/sbt/util/InterfaceUtil.scala

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77

88
package sbt.util
99

10-
import xsbti.{ Position, Problem, Severity, T2 }
1110
import java.io.File
1211
import java.util.Optional
1312
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
1418

1519
object InterfaceUtil {
1620
def toSupplier[A](a: => A): Supplier[A] = new Supplier[A] {
@@ -43,6 +47,18 @@ object InterfaceUtil {
4347
case None => Optional.empty[A]()
4448
}
4549

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+
4662
@deprecated("Use the overload of this method with more arguments", "1.2.2")
4763
def position(
4864
line0: Option[Integer],
@@ -104,14 +120,26 @@ object InterfaceUtil {
104120
def problem(cat: String, pos: Position, msg: String, sev: Severity): Problem =
105121
problem(cat, pos, msg, sev, None)
106122

123+
@deprecated("Use the overload of this method with more arguments", "1.7.2")
107124
def problem(
108125
cat: String,
109126
pos: Position,
110127
msg: String,
111128
sev: Severity,
112129
rendered: Option[String]
113130
): Problem =
114-
new ConcreteProblem(cat, pos, msg, sev, rendered)
131+
problem(cat, pos, msg, sev, rendered, 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)
115143

116144
private final class ConcreteT2[A1, A2](a1: A1, a2: A2) extends T2[A1, A2] {
117145
val get1: A1 = a1
@@ -166,13 +194,18 @@ object InterfaceUtil {
166194
pos: Position,
167195
msg: String,
168196
sev: Severity,
169-
rendered0: Option[String]
197+
rendered0: Option[String],
198+
diagnosticCode0: Option[DiagnosticCode],
199+
diagnosticRelatedInformation0: List[DiagnosticRelatedInformation]
170200
) extends Problem {
171201
val category = cat
172202
val position = pos
173203
val message = msg
174204
val severity = sev
175205
override val rendered = o2jo(rendered0)
206+
override def diagnosticCode: Optional[DiagnosticCode] = o2jo(diagnosticCode0)
207+
override def diagnosticRelatedInforamation(): ju.List[DiagnosticRelatedInformation] =
208+
l2jl(diagnosticRelatedInformation0)
176209
override def toString = s"[$severity] $pos: $message"
177210
}
178211
}

0 commit comments

Comments
 (0)