@@ -6,6 +6,7 @@ import dotty.tools.dotc.core.Contexts._
66import dotty .tools .dotc .util .SourcePosition
77
88import java .util .regex .PatternSyntaxException
9+ import scala .annotation .internal .sharable
910import scala .collection .mutable .ListBuffer
1011import scala .util .matching .Regex
1112
@@ -17,10 +18,12 @@ enum MessageFilter:
1718 case MessagePattern (pattern) =>
1819 val noHighlight = message.msg.rawMessage.replaceAll(" \\ e\\ [[\\ d;]*[^\\ d;]" ," " )
1920 pattern.findFirstIn(noHighlight).nonEmpty
21+ case MessageID (errorId) => message.msg.errorId == errorId
2022 case None => false
2123 }
2224 case Any , Deprecated , Feature , None
2325 case MessagePattern (pattern : Regex )
26+ case MessageID (errorId : ErrorMessageID )
2427
2528enum Action :
2629 case Error , Warning , Info , Silent
@@ -48,18 +51,28 @@ object WConf:
4851 try Right (s.r)
4952 catch { case e : PatternSyntaxException => Left (s " invalid pattern ` $s`: ${e.getMessage}" ) }
5053
51- def parseFilter (s : String ): Either [String , MessageFilter ] =
52- val splitter = raw " ([^=]+)=(.+) " .r
53- s match
54- case " any" => Right (Any )
55- case splitter(filter, conf) => filter match
56- case " msg" => regex(conf).map(MessagePattern .apply)
57- case " cat" => conf match
58- case " deprecation" => Right (Deprecated )
59- case " feature" => Right (Feature )
60- case _ => Left (s " unknown category: $conf" )
61- case _ => Left (s " unknown filter: $filter" )
62- case _ => Left (s " unknown filter: $s" )
54+ @ sharable val Splitter = raw " ([^=]+)=(.+) " .r
55+ @ sharable val ErrorId = raw " E?(\d+) " .r
56+
57+ def parseFilter (s : String ): Either [String , MessageFilter ] = s match
58+ case " any" => Right (Any )
59+ case Splitter (filter, conf) => filter match
60+ case " msg" => regex(conf).map(MessagePattern .apply)
61+ case " id" => conf match
62+ case ErrorId (num) =>
63+ val n = num.toInt + 2
64+ if n < ErrorMessageID .values.length then
65+ Right (MessageID (ErrorMessageID .fromOrdinal(n)))
66+ else
67+ Left (s " unknonw error message id: E $n" )
68+ case _ =>
69+ Left (s " invalid error message id: $conf" )
70+ case " cat" => conf match
71+ case " deprecation" => Right (Deprecated )
72+ case " feature" => Right (Feature )
73+ case _ => Left (s " unknown category: $conf" )
74+ case _ => Left (s " unknown filter: $filter" )
75+ case _ => Left (s " unknown filter: $s" )
6376
6477 def parsed (using Context ): WConf =
6578 val setting = ctx.settings.Wconf .value
0 commit comments