@@ -15,7 +15,7 @@ import util.{ SourcePosition, NoSourcePosition }
1515import util .Chars .{ LF , CR , FF , SU }
1616import scala .annotation .switch
1717
18- import scala .collection .mutable
18+ import scala .collection .mutable . StringBuilder
1919
2020trait MessageRendering {
2121 import Highlight .*
@@ -209,22 +209,27 @@ trait MessageRendering {
209209 sb.toString
210210 }
211211
212- private def appendFilterHelp (dia : Diagnostic , sb : mutable. StringBuilder ): Unit =
213- import dia .*
212+ private def appendFilterHelp (dia : Diagnostic , sb : StringBuilder ): Unit =
213+ import dia .msg
214214 val hasId = msg.errorId.errorNumber >= 0
215- val category = dia match {
216- case _ : UncheckedWarning => " unchecked"
217- case _ : DeprecationWarning => " deprecation"
218- case _ : FeatureWarning => " feature"
219- case _ => " "
220- }
221- if (hasId || category.nonEmpty)
222- sb.append(EOL ).append(" Matching filters for @nowarn or -Wconf:" )
223- if (hasId)
224- sb.append(EOL ).append(" - id=E" ).append(msg.errorId.errorNumber)
225- sb.append(EOL ).append(" - name=" ).append(msg.errorId.productPrefix.stripSuffix(" ID" ))
226- if (category.nonEmpty)
227- sb.append(EOL ).append(" - cat=" ).append(category)
215+ val (category, origin) = dia match
216+ case _ : UncheckedWarning => (" unchecked" , " " )
217+ case w : DeprecationWarning => (" deprecation" , w.origin)
218+ case _ : FeatureWarning => (" feature" , " " )
219+ case _ => (" " , " " )
220+ var entitled = false
221+ def addHelp (what : String )(value : String ): Unit =
222+ if ! entitled then
223+ sb.append(EOL ).append(" Matching filters for @nowarn or -Wconf:" )
224+ entitled = true
225+ sb.append(EOL ).append(" - " ).append(what).append(value)
226+ if hasId then
227+ addHelp(" id=E" )(msg.errorId.errorNumber.toString)
228+ addHelp(" name=" )(msg.errorId.productPrefix.stripSuffix(" ID" ))
229+ if category.nonEmpty then
230+ addHelp(" cat=" )(category)
231+ if origin.nonEmpty then
232+ addHelp(" origin=" )(origin)
228233
229234 /** The whole message rendered from `msg` */
230235 def messageAndPos (dia : Diagnostic )(using Context ): String = {
@@ -236,7 +241,7 @@ trait MessageRendering {
236241 else 0
237242 given Level = Level (level)
238243 given Offset = Offset (maxLineNumber.toString.length + 2 )
239- val sb = mutable. StringBuilder ()
244+ val sb = StringBuilder ()
240245 val posString = posStr(pos, msg, diagnosticLevel(dia))
241246 if (posString.nonEmpty) sb.append(posString).append(EOL )
242247 if (pos.exists) {
0 commit comments