Skip to content

Commit 2b87171

Browse files
som-snytttgodzik
authored andcommitted
Filter help renders box border
[Cherry-picked e1bdfad]
1 parent 174b497 commit 2b87171

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,21 @@ trait MessageRendering {
209209
sb.toString
210210
}
211211

212-
private def appendFilterHelp(dia: Diagnostic, sb: StringBuilder): Unit =
212+
private def appendFilterHelp(dia: Diagnostic, sb: StringBuilder)(using Context, Level, Offset): Unit =
213+
extension (sb: StringBuilder) def nl: sb.type = sb.append(EOL).append(offsetBox)
213214
import dia.msg
214215
val hasId = msg.errorId.errorNumber >= 0
215216
val (category, origin) = dia match
216-
case _: UncheckedWarning => ("unchecked", "")
217+
case _: UncheckedWarning => ("unchecked", "")
217218
case w: DeprecationWarning => ("deprecation", w.origin)
218-
case _: FeatureWarning => ("feature", "")
219-
case _ => ("", "")
219+
case _: FeatureWarning => ("feature", "")
220+
case _ => ("", "")
220221
var entitled = false
221222
def addHelp(what: String)(value: String): Unit =
222223
if !entitled then
223-
sb.append(EOL).append("Matching filters for @nowarn or -Wconf:")
224+
sb.nl.append("Matching filters for @nowarn or -Wconf:")
224225
entitled = true
225-
sb.append(EOL).append(" - ").append(what).append(value)
226+
sb.nl.append(" - ").append(what).append(value)
226227
if hasId then
227228
addHelp("id=E")(msg.errorId.errorNumber.toString)
228229
addHelp("name=")(msg.errorId.productPrefix.stripSuffix("ID"))

tests/neg/nowarn.check

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
| ^^^^^
2525
| A try without catch or finally is equivalent to putting
2626
| its body in a block; no exceptions are handled.
27-
Matching filters for @nowarn or -Wconf:
28-
- id=E2
29-
- name=EmptyCatchAndFinallyBlock
27+
|Matching filters for @nowarn or -Wconf:
28+
| - id=E2
29+
| - name=EmptyCatchAndFinallyBlock
3030
|
3131
| longer explanation available when compiling with `-explain`
3232
-- [E129] Potential Issue Warning: tests/neg/nowarn.scala:15:11 --------------------------------------------------------

tests/warn/deprecated-origin-verbose.check

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
12 | class D extends C // warn
33
| ^
44
| class C in package p is deprecated since 1.0: Old style
5-
Matching filters for @nowarn or -Wconf:
6-
- cat=deprecation
7-
- origin=p.C
5+
|Matching filters for @nowarn or -Wconf:
6+
| - cat=deprecation
7+
| - origin=p.C
88
-- Deprecation Warning: tests/warn/deprecated-origin-verbose.scala:13:20 -----------------------------------------------
99
13 | class Oil extends Crude // warn
1010
| ^^^^^
1111
| class Crude in package p is deprecated since 1.0: Bad style
12-
Matching filters for @nowarn or -Wconf:
13-
- cat=deprecation
14-
- origin=p.Crude
12+
|Matching filters for @nowarn or -Wconf:
13+
| - cat=deprecation
14+
| - origin=p.Crude

tests/warn/i22412.check

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- [E002] Syntax Warning: tests/warn/i22412.scala:3:34 -----------------------------------------------------------------
2+
3 | @annotation.nowarn("v") def f = try 1 // warn
3+
| ^^^^^
4+
| A try without catch or finally is equivalent to putting
5+
| its body in a block; no exceptions are handled.
6+
|Matching filters for @nowarn or -Wconf:
7+
| - id=E2
8+
| - name=EmptyCatchAndFinallyBlock
9+
|
10+
| longer explanation available when compiling with `-explain`

tests/warn/i22412.scala

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
class C:
3+
@annotation.nowarn("v") def f = try 1 // warn

0 commit comments

Comments
 (0)