@@ -6,7 +6,6 @@ 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
10
9
import scala .collection .mutable .ListBuffer
11
10
import scala .util .matching .Regex
12
11
@@ -31,7 +30,7 @@ final case class WConf(confs: List[(List[MessageFilter], Action)]):
31
30
case (filters, action) if filters.forall(_.matches(message)) => action
32
31
}.getOrElse(Action .Warning )
33
32
34
- @ sharable object WConf :
33
+ object WConf :
35
34
import Action ._
36
35
import MessageFilter ._
37
36
@@ -49,38 +48,34 @@ final case class WConf(confs: List[(List[MessageFilter], Action)]):
49
48
try Right (s.r)
50
49
catch { case e : PatternSyntaxException => Left (s " invalid pattern ` $s`: ${e.getMessage}" ) }
51
50
52
- val splitter = raw " ([^=]+)=(.+) " .r
53
-
54
- def parseFilter (s : String ): Either [String , MessageFilter ] = s match {
55
- case " any" => Right (Any )
56
- case splitter(filter, conf) => filter match {
57
- case " msg" => regex(conf).map(MessagePattern .apply)
58
- case " cat" =>
59
- conf match {
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
60
58
case " deprecation" => Right (Deprecated )
61
59
case " feature" => Right (Feature )
62
60
case _ => Left (s " unknown category: $conf" )
63
- }
64
- case _ => Left (s " unknown filter: $filter" )
65
- }
66
- case _ => Left (s " unknown filter: $s" )
67
- }
61
+ case _ => Left (s " unknown filter: $filter" )
62
+ case _ => Left (s " unknown filter: $s" )
68
63
69
- private var parsedCache : (List [String ], WConf ) = null
70
64
def parsed (using Context ): WConf =
71
65
val setting = ctx.settings.Wconf .value
72
- if parsedCache == null || parsedCache._1 != setting then
66
+ def cached = ctx.base.wConfCache
67
+ if cached == null || cached._1 != setting then
73
68
val conf = fromSettings(setting)
74
- parsedCache = (setting, conf.getOrElse(WConf (Nil )))
69
+ ctx.base.wConfCache = (setting, conf.getOrElse(WConf (Nil )))
75
70
conf.swap.foreach(msgs =>
76
71
val multiHelp =
77
- if ( setting.sizeIs > 1 )
72
+ if setting.sizeIs > 1 then
78
73
"""
79
74
|Note: for multiple filters, use `-Wconf:filter1:action1,filter2:action2`
80
75
| or alternatively `-Wconf:filter1:action1 -Wconf:filter2:action2`""" .stripMargin
81
76
else " "
82
77
report.warning(s " Failed to parse `-Wconf` configuration: ${ctx.settings.Wconf .value.mkString(" ," )}\n ${msgs.mkString(" \n " )}$multiHelp" ))
83
- parsedCache ._2
78
+ cached ._2
84
79
85
80
def fromSettings (settings : List [String ]): Either [List [String ], WConf ] =
86
81
if (settings.isEmpty) Right (WConf (Nil ))
0 commit comments