@@ -17,15 +17,15 @@ import Phases.{unfusedPhases, Phase}
17
17
import sbt .interfaces .ProgressCallback
18
18
19
19
import util .*
20
- import reporting .{Suppression , Action , Profile , ActiveProfile , NoProfile }
21
- import reporting .Diagnostic
22
- import reporting .Diagnostic .Warning
20
+ import reporting .{Suppression , Action , Profile , ActiveProfile , MessageFilter , NoProfile , WConf }
21
+ import reporting .Diagnostic , Diagnostic .Warning
23
22
import rewrites .Rewrites
24
23
import profile .Profiler
25
24
import printing .XprintMode
26
25
import typer .ImplicitRunInfo
27
26
import config .Feature
28
27
import StdNames .nme
28
+ import Spans .Span
29
29
30
30
import java .io .{BufferedWriter , OutputStreamWriter }
31
31
import java .nio .charset .StandardCharsets
@@ -37,6 +37,8 @@ import scala.io.Codec
37
37
import Run .Progress
38
38
import scala .compiletime .uninitialized
39
39
import dotty .tools .dotc .transform .MegaPhase
40
+ import dotty .tools .dotc .util .chaining .*
41
+ import java .util .{Timer , TimerTask }
40
42
41
43
/** A compiler run. Exports various methods to compile source files */
42
44
class Run (comp : Compiler , ictx : Context ) extends ImplicitRunInfo with ConstraintRunInfo {
@@ -97,6 +99,26 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
97
99
Action .Warning
98
100
}
99
101
102
+ def registerNowarn (annotPos : SourcePosition , range : Span )(conf : String , pos : SrcPos )(using Context ): Unit =
103
+ var verbose = false
104
+ val filters = conf match
105
+ case " " =>
106
+ List (MessageFilter .Any )
107
+ case " none" =>
108
+ List (MessageFilter .None )
109
+ case " verbose" | " v" =>
110
+ verbose = true
111
+ List (MessageFilter .Any )
112
+ case conf =>
113
+ WConf .parseFilters(conf).left.map: parseErrors =>
114
+ report.warning(s " Invalid message filter \n ${parseErrors.mkString(" \n " )}" , pos)
115
+ List (MessageFilter .None )
116
+ .merge
117
+ addSuppression :
118
+ Suppression (annotPos, filters, range.start, range.end, verbose)
119
+ .tap: sup =>
120
+ if filters == List (MessageFilter .None ) then sup.markUsed() // invalid suppressions, don't report as unused
121
+
100
122
def addSuppression (sup : Suppression ): Unit =
101
123
val suppressions = mySuppressions.getOrElseUpdate(sup.annotPos.source, ListBuffer .empty)
102
124
if sup.start != sup.end && suppressions.forall(x => x.start != sup.start || x.end != sup.end) then
0 commit comments