Skip to content

Commit

Permalink
Overwrite Problem#rendered with None when source mapping occurs.
Browse files Browse the repository at this point in the history
This commit is to improve Twirl's error message with Scala3.
playframework/twirl#498

This pull request makes sbt ignore `Problem#rendered` passed from the compiler  if source mapping is actually performed.
Sbt will display the error message based on the `Position` transformed by source mapping.
When the source mapping is not performed, the message in `Problem#rendered` is displayed as before.
  • Loading branch information
tototoshi committed Apr 1, 2022
1 parent e383c44 commit 7ea103a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ class LoggedReporter(
(problem0.category, problem0.position, problem0.message, problem0.severity, problem0.rendered)
// Note: positions in reported errors can be fixed with `sourcePositionMapper`.
val transformedPos: Position = sourcePositionMapper(position)
val transformed = transformedPos.sourceFile != position.sourceFile
val problem = InterfaceUtil.problem(
category,
transformedPos,
message,
severity,
InterfaceUtil.jo2o(rendered)
// When the source mapping is performed,
// the information based on the `transformedPos` should be displayed
// even if the `rendered` is defined.
if (transformed) None else InterfaceUtil.jo2o(rendered)
)
allProblems += problem0
severity match {
Expand Down

0 comments on commit 7ea103a

Please sign in to comment.