Skip to content

Commit b573b5f

Browse files
Don't add explanation twice (#18779)
Fixes #18774 The improvement was #14357
2 parents 18ada51 + 5b5e67e commit b573b5f

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

sbt-bridge/src/dotty/tools/xsbt/DelegatingReporter.java

+8-13
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,17 @@ public void printSummary(Context ctx) {
4848
public void doReport(Diagnostic dia, Context ctx) {
4949
Severity severity = severityOf(dia.level());
5050
Position position = positionOf(dia.pos().nonInlined());
51-
52-
StringBuilder rendered = new StringBuilder();
53-
rendered.append(messageAndPos(dia, ctx));
5451
Message message = dia.msg();
55-
StringBuilder messageBuilder = new StringBuilder();
56-
messageBuilder.append(message.message());
52+
String text;
53+
if (Diagnostic.shouldExplain(dia, ctx) && !message.explanation().isEmpty())
54+
text = message.message() + System.lineSeparator() + explanation(message, ctx);
55+
else
56+
text = message.message();
57+
String rendered = messageAndPos(dia, ctx);
5758
String diagnosticCode = String.valueOf(message.errorId().errorNumber());
58-
boolean shouldExplain = Diagnostic.shouldExplain(dia, ctx);
5959
List<CodeAction> actions = CollectionConverters.asJava(message.actions(ctx));
60-
if (shouldExplain && !message.explanation().isEmpty()) {
61-
rendered.append(explanation(message, ctx));
62-
messageBuilder.append(System.lineSeparator()).append(explanation(message, ctx));
63-
}
64-
65-
delegate.log(new Problem(position, messageBuilder.toString(), severity, rendered.toString(), diagnosticCode, actions,
66-
lookupVirtualFileId));
60+
Problem problem = new Problem(position, text, severity, rendered, diagnosticCode, actions, lookupVirtualFileId);
61+
delegate.log(problem);
6762
}
6863

6964
public void reportBasicWarning(String message) {

0 commit comments

Comments
 (0)