@@ -10,6 +10,7 @@ import dotty.tools.dotc.interfaces.SourceFile
10
10
import dotty .tools .dotc .reporting .MessageFilter .SourcePattern
11
11
12
12
import java .util .regex .PatternSyntaxException
13
+ import scala .PartialFunction .cond
13
14
import scala .annotation .internal .sharable
14
15
import scala .util .matching .Regex
15
16
@@ -136,13 +137,38 @@ object WConf:
136
137
if (parseErrorss.nonEmpty) Left (parseErrorss.flatten)
137
138
else Right (WConf (configs))
138
139
139
- class Suppression (val annotPos : SourcePosition , filters : List [MessageFilter ], val start : Int , val end : Int , val verbose : Boolean ):
140
+ class Suppression (val annotPos : SourcePosition , val filters : List [MessageFilter ], val start : Int , val end : Int , val verbose : Boolean ):
140
141
private var _used = false
141
142
def used : Boolean = _used
142
143
def markUsed (): Unit =
143
144
_used = true
144
145
def matches (dia : Diagnostic ): Boolean =
145
146
val pos = dia.pos
146
147
pos.exists && start <= pos.start && pos.end <= end && filters.forall(_.matches(dia))
148
+ def matches (other : Suppression ): Boolean =
149
+ start == other.start
150
+ && end == other.end
151
+ && verbose == other.verbose
152
+ && filters.lengthCompare(other.filters) == 0
153
+ && filters.forall(other.hasFilter)
154
+ && other.filters.forall(hasFilter)
155
+
156
+ private def hasFilter (filter : MessageFilter ): Boolean =
157
+ import MessageFilter .*
158
+ filters.exists:
159
+ case MessageID (errorId) =>
160
+ cond(filter):
161
+ case MessageID (otherId) => errorId == otherId
162
+ case MessagePattern (pattern) =>
163
+ cond(filter):
164
+ case MessagePattern (otherPattern) => pattern.toString == otherPattern.toString
165
+ case SourcePattern (pattern) =>
166
+ cond(filter):
167
+ case SourcePattern (otherPattern) => pattern.toString == otherPattern.toString
168
+ case Origin (pattern) =>
169
+ cond(filter):
170
+ case Origin (otherPattern) => pattern.toString == otherPattern.toString
171
+ case x => x == filter // Any, Deprecated, Feature, Unchecked, None
147
172
148
173
override def toString = s " Suppress in ${annotPos.source} $start.. $end [ ${filters.mkString(" , " )}] "
174
+ end Suppression
0 commit comments