@@ -6,6 +6,7 @@ import dotty.tools.dotc.core.Contexts._
6
6
import dotty .tools .dotc .util .SourcePosition
7
7
8
8
import java .util .regex .PatternSyntaxException
9
+ import scala .annotation .internal .sharable
9
10
import scala .collection .mutable .ListBuffer
10
11
import scala .util .matching .Regex
11
12
@@ -17,10 +18,12 @@ enum MessageFilter:
17
18
case MessagePattern (pattern) =>
18
19
val noHighlight = message.msg.rawMessage.replaceAll(" \\ e\\ [[\\ d;]*[^\\ d;]" ," " )
19
20
pattern.findFirstIn(noHighlight).nonEmpty
21
+ case MessageID (errorId) => message.msg.errorId == errorId
20
22
case None => false
21
23
}
22
24
case Any , Deprecated , Feature , None
23
25
case MessagePattern (pattern : Regex )
26
+ case MessageID (errorId : ErrorMessageID )
24
27
25
28
enum Action :
26
29
case Error , Warning , Info , Silent
@@ -48,18 +51,28 @@ object WConf:
48
51
try Right (s.r)
49
52
catch { case e : PatternSyntaxException => Left (s " invalid pattern ` $s`: ${e.getMessage}" ) }
50
53
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" )
63
76
64
77
def parsed (using Context ): WConf =
65
78
val setting = ctx.settings.Wconf .value
0 commit comments