Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter help renders box border #22434

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,21 @@ trait MessageRendering {
sb.toString
}

private def appendFilterHelp(dia: Diagnostic, sb: StringBuilder): Unit =
private def appendFilterHelp(dia: Diagnostic, sb: StringBuilder)(using Context, Level, Offset): Unit =
extension (sb: StringBuilder) def nl: sb.type = sb.append(EOL).append(offsetBox)
import dia.msg
val hasId = msg.errorId.errorNumber >= 0
val (category, origin) = dia match
case _: UncheckedWarning => ("unchecked", "")
case _: UncheckedWarning => ("unchecked", "")
case w: DeprecationWarning => ("deprecation", w.origin)
case _: FeatureWarning => ("feature", "")
case _ => ("", "")
case _: FeatureWarning => ("feature", "")
case _ => ("", "")
var entitled = false
def addHelp(what: String)(value: String): Unit =
if !entitled then
sb.append(EOL).append("Matching filters for @nowarn or -Wconf:")
sb.nl.append("Matching filters for @nowarn or -Wconf:")
entitled = true
sb.append(EOL).append(" - ").append(what).append(value)
sb.nl.append(" - ").append(what).append(value)
if hasId then
addHelp("id=E")(msg.errorId.errorNumber.toString)
addHelp("name=")(msg.errorId.productPrefix.stripSuffix("ID"))
Expand Down
6 changes: 3 additions & 3 deletions tests/neg/nowarn.check
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
| ^^^^^
| A try without catch or finally is equivalent to putting
| its body in a block; no exceptions are handled.
Matching filters for @nowarn or -Wconf:
- id=E2
- name=EmptyCatchAndFinallyBlock
|Matching filters for @nowarn or -Wconf:
| - id=E2
| - name=EmptyCatchAndFinallyBlock
|
| longer explanation available when compiling with `-explain`
-- [E129] Potential Issue Warning: tests/neg/nowarn.scala:15:11 --------------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions tests/warn/deprecated-origin-verbose.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
12 | class D extends C // warn
| ^
| class C in package p is deprecated since 1.0: Old style
Matching filters for @nowarn or -Wconf:
- cat=deprecation
- origin=p.C
|Matching filters for @nowarn or -Wconf:
| - cat=deprecation
| - origin=p.C
-- Deprecation Warning: tests/warn/deprecated-origin-verbose.scala:13:20 -----------------------------------------------
13 | class Oil extends Crude // warn
| ^^^^^
| class Crude in package p is deprecated since 1.0: Bad style
Matching filters for @nowarn or -Wconf:
- cat=deprecation
- origin=p.Crude
|Matching filters for @nowarn or -Wconf:
| - cat=deprecation
| - origin=p.Crude
10 changes: 10 additions & 0 deletions tests/warn/i22412.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- [E002] Syntax Warning: tests/warn/i22412.scala:3:34 -----------------------------------------------------------------
3 | @annotation.nowarn("v") def f = try 1 // warn
| ^^^^^
| A try without catch or finally is equivalent to putting
| its body in a block; no exceptions are handled.
|Matching filters for @nowarn or -Wconf:
| - id=E2
| - name=EmptyCatchAndFinallyBlock
|
| longer explanation available when compiling with `-explain`
3 changes: 3 additions & 0 deletions tests/warn/i22412.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

class C:
@annotation.nowarn("v") def f = try 1 // warn
Loading