Skip to content

Commit b64ae7a

Browse files
committed
enable filtering warnings by their ErrorMessageID name
1 parent 8b466ca commit b64ae7a

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ private sealed trait WarningSettings:
152152
| - Message id: id=E129
153153
| The message id is printed with the warning.
154154
|
155+
| - Message name: name=PureExpressionInStatementPosition
156+
| The message name is printed with the warning in verbose warning mode.
157+
|
155158
|In verbose warning mode the compiler prints matching filters for warnings.
156159
|Verbose mode can be enabled globally using `-Wconf:any:verbose`, or locally
157160
|using the @nowarn annotation (example: `@nowarn("v") def test = try 1`).

compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ trait MessageRendering {
155155
sb.append(EOL).append("Matching filters for @nowarn or -Wconf:")
156156
if (hasId)
157157
sb.append(EOL).append(" - id=E").append(msg.errorId.errorNumber)
158+
sb.append(EOL).append(" - name=").append(msg.errorId.productPrefix.stripSuffix("ID"))
158159
if (category.nonEmpty)
159160
sb.append(EOL).append(" - cat=").append(category)
160161

compiler/src/dotty/tools/dotc/reporting/WConf.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ object WConf:
6969
Left(s"unknonw error message id: E$n")
7070
case _ =>
7171
Left(s"invalid error message id: $conf")
72+
case "name" =>
73+
try Right(MessageID(ErrorMessageID.valueOf(conf + "ID")))
74+
catch case _: IllegalArgumentException => Left(s"unknown error message name: $conf")
75+
7276
case "cat" => conf match
7377
case "deprecation" => Right(Deprecated)
7478
case "feature" => Right(Feature)

0 commit comments

Comments
 (0)