Skip to content

Commit

Permalink
Leverage string concat, blue explain is not deprecated
Browse files Browse the repository at this point in the history
[Cherry-picked 5b5e67e]
  • Loading branch information
som-snytt authored and WojciechMazur committed Jun 23, 2024
1 parent dd0bfac commit 6892e70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ trait MessageRendering {
end posStr

/** Explanation rendered under "Explanation" header */
@deprecated("Explanations are rendered with the message text", since="3.4")
def explanation(m: Message)(using Context): String = {
val sb = new StringBuilder(
s"""|
Expand Down
11 changes: 7 additions & 4 deletions sbt-bridge/src/dotty/tools/xsbt/DelegatingReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ public void doReport(Diagnostic dia, Context ctx) {
Severity severity = severityOf(dia.level());
Position position = positionOf(dia.pos().nonInlined());
Message message = dia.msg();
StringBuilder messageBuilder = new StringBuilder(message.message());
String text;
if (Diagnostic.shouldExplain(dia, ctx) && !message.explanation().isEmpty())
text = message.message() + System.lineSeparator() + explanation(message, ctx);
else
text = message.message();
String rendered = messageAndPos(dia, ctx);
String diagnosticCode = String.valueOf(message.errorId().errorNumber());
List<CodeAction> actions = CollectionConverters.asJava(message.actions(ctx));
if (Diagnostic.shouldExplain(dia, ctx) && !message.explanation().isEmpty())
messageBuilder.append(System.lineSeparator()).append(explanation(message, ctx));
Problem problem = new Problem(position, messageBuilder.toString(), severity, messageAndPos(dia, ctx), diagnosticCode, actions, lookupVirtualFileId);
Problem problem = new Problem(position, text, severity, rendered, diagnosticCode, actions, lookupVirtualFileId);
delegate.log(problem);
}

Expand Down

0 comments on commit 6892e70

Please sign in to comment.