Skip to content

Commit eb2f68d

Browse files
committed
Add DiagnosticRelatedInformation to compiler's interface
1 parent c4d63cc commit eb2f68d

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import dotty.tools.dotc.core.Contexts._
99
import dotty.tools.dotc.interfaces.Diagnostic.{ERROR, INFO, WARNING}
1010
import dotty.tools.dotc.util.SourcePosition
1111

12-
import java.util.Optional
12+
import java.util.{Collections, Optional, List => JList}
1313
import scala.util.chaining._
1414
import core.Decorators.toMessage
1515

@@ -100,6 +100,8 @@ class Diagnostic(
100100
if (pos.exists && pos.source.exists) Optional.of(pos) else Optional.empty()
101101
override def message: String =
102102
msg.message.replaceAll("\u001B\\[[;\\d]*m", "")
103+
override def diagnosticRelatedInformation: JList[interfaces.DiagnosticRelatedInformation] =
104+
Collections.emptyList()
103105

104106
override def toString: String = s"$getClass at $pos: $message"
105107
override def getMessage(): String = message

interfaces/src/dotty/tools/dotc/interfaces/Diagnostic.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dotty.tools.dotc.interfaces;
22

33
import java.util.Optional;
4+
import java.util.List;
45

56
/** A diagnostic is a message emitted during the compilation process.
67
*
@@ -23,4 +24,7 @@ public interface Diagnostic {
2324
/** @return The position in a source file of the code that caused this diagnostic
2425
* to be emitted. */
2526
Optional<SourcePosition> position();
27+
28+
/** @return A list of additional messages together with their code positions */
29+
List<DiagnosticRelatedInformation> diagnosticRelatedInformation();
2630
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package dotty.tools.dotc.interfaces;
2+
3+
public interface DiagnosticRelatedInformation {
4+
SourcePosition position();
5+
String message();
6+
}

0 commit comments

Comments
 (0)