Skip to content
This repository has been archived by the owner. It is now read-only.

Commit cddea89

Browse files
committed
Add Problem#rendered to customize how problems are shown
Dotty has its own logic for displaying problems with the proper file path, position, and caret, but if we store this information in Problem#message we end up with duplicated information in the output since Zinc will prepend/append similar things (see sbt.internal.inc.ProblemStringFormats). So far, we worked around this in Dotty by using an empty position in the sbt bridge reporter, but this means that crucial semantic information that could be used by a Build Server Protocol implementation and other tools is lost. This commit allows us to avoid by adding an optional `rendered` field to `Problem`: when this field is set, its value controls what the user sees, otherwise we fallback to the default behavior (the logic to do this will be added to Zinc after this PR is merged and a new release of sbt-util is made).
1 parent caeca9f commit cddea89

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/main/java/xsbti/Problem.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@
33
*/
44
package xsbti;
55

6+
import java.util.Optional;
7+
68
public interface Problem
79
{
810
String category();
911
Severity severity();
1012
String message();
1113
Position position();
12-
}
14+
15+
// Default value to avoid breaking binary compatibility
16+
/**
17+
* If present, the string shown to the user when displaying this Problem.
18+
* Otherwise, the Problem will be shown in an implementation-defined way
19+
* based on the values of its other fields.
20+
*/
21+
default Optional<String> rendered() { return Optional.empty(); }
22+
}

0 commit comments

Comments
 (0)