@@ -17,15 +17,15 @@ import Phases.{unfusedPhases, Phase}
1717import sbt .interfaces .ProgressCallback
1818
1919import 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
2322import rewrites .Rewrites
2423import profile .Profiler
2524import printing .XprintMode
2625import typer .ImplicitRunInfo
2726import config .Feature
2827import StdNames .nme
28+ import Spans .Span
2929
3030import java .io .{BufferedWriter , OutputStreamWriter }
3131import java .nio .charset .StandardCharsets
@@ -37,6 +37,8 @@ import scala.io.Codec
3737import Run .Progress
3838import scala .compiletime .uninitialized
3939import dotty .tools .dotc .transform .MegaPhase
40+ import dotty .tools .dotc .util .chaining .*
41+ import java .util .{Timer , TimerTask }
4042
4143/** A compiler run. Exports various methods to compile source files */
4244class Run (comp : Compiler , ictx : Context ) extends ImplicitRunInfo with ConstraintRunInfo {
@@ -97,6 +99,26 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
9799 Action .Warning
98100 }
99101
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+
100122 def addSuppression (sup : Suppression ): Unit =
101123 val suppressions = mySuppressions.getOrElseUpdate(sup.annotPos.source, ListBuffer .empty)
102124 if sup.start != sup.end && suppressions.forall(x => x.start != sup.start || x.end != sup.end) then
0 commit comments