Skip to content

Commit

Permalink
Backport "Don't add explanation twice" to LTS (#20749)
Browse files Browse the repository at this point in the history
Backports #18779 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jun 23, 2024
2 parents 6c978b1 + a567054 commit d44cbd7
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions sbt-bridge/src/dotty/tools/xsbt/DelegatingReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,17 @@ public void printSummary(Context ctx) {
public void doReport(Diagnostic dia, Context ctx) {
Severity severity = severityOf(dia.level());
Position position = positionOf(dia.pos().nonInlined());

StringBuilder rendered = new StringBuilder();
rendered.append(messageAndPos(dia, ctx));
Message message = dia.msg();
StringBuilder messageBuilder = new StringBuilder();
messageBuilder.append(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());
boolean shouldExplain = Diagnostic.shouldExplain(dia, ctx);
List<CodeAction> actions = CollectionConverters.asJava(message.actions(ctx));
if (shouldExplain && !message.explanation().isEmpty()) {
rendered.append(explanation(message, ctx));
messageBuilder.append(System.lineSeparator()).append(explanation(message, ctx));
}

delegate.log(new Problem(position, messageBuilder.toString(), severity, rendered.toString(), diagnosticCode, actions,
lookupVirtualFileId));
Problem problem = new Problem(position, text, severity, rendered, diagnosticCode, actions, lookupVirtualFileId);
delegate.log(problem);
}

public void reportBasicWarning(String message) {
Expand Down

0 comments on commit d44cbd7

Please sign in to comment.