Skip to content

Commit

Permalink
Don't add explanation twice
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Oct 28, 2023
1 parent 8046a8b commit c17d94c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ 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
16 changes: 4 additions & 12 deletions sbt-bridge/src/dotty/tools/xsbt/DelegatingReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,14 @@ 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());
StringBuilder messageBuilder = new StringBuilder(message.message());
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));
if (Diagnostic.shouldExplain(dia, ctx) && !message.explanation().isEmpty())
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, messageBuilder.toString(), severity, messageAndPos(dia, ctx), diagnosticCode, actions, lookupVirtualFileId);
delegate.log(problem);
}

public void reportBasicWarning(String message) {
Expand Down

0 comments on commit c17d94c

Please sign in to comment.