mirror of https://github.com/sbt/sbt.git
Merge pull request #6874 from ckipp01/problem
feat: update Problem to account for related information and code
This commit is contained in:
commit
543e8318b0
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* sbt
|
||||
* Copyright 2011 - 2018, Lightbend, Inc.
|
||||
* Copyright 2008 - 2010, Mark Harrah
|
||||
* Licensed under Apache License 2.0 (see LICENSE)
|
||||
*/
|
||||
|
||||
package xsbti;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A DiagnosticCode is a unique identifier that the compiler can associate with a diagnostic. This
|
||||
* is useful for tools to be able to quickly identify what diagnostic is being reported without
|
||||
* having to rely on parsing the actual diagnostic message, which might not be stable.
|
||||
*/
|
||||
public interface DiagnosticCode {
|
||||
/** The unique code. This is typically in the format of E000 */
|
||||
String code();
|
||||
|
||||
/** Possible explanation to explain the meaning of the code */
|
||||
Optional<String> explanation();
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* sbt
|
||||
* Copyright 2011 - 2018, Lightbend, Inc.
|
||||
* Copyright 2008 - 2010, Mark Harrah
|
||||
* Licensed under Apache License 2.0 (see LICENSE)
|
||||
*/
|
||||
|
||||
package xsbti;
|
||||
|
||||
/**
|
||||
* Related information for a given diagnostic. At times this can be another place in your code
|
||||
* contributing to the diagnostic or just relevant code relating to the diagnostic.
|
||||
*/
|
||||
public interface DiagnosticRelatedInformation {
|
||||
/** Position of the related information */
|
||||
Position position();
|
||||
|
||||
/** Message indicating why this related information is attached to the diagnostic. */
|
||||
String message();
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
package xsbti;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface Problem {
|
||||
|
|
@ -26,4 +28,24 @@ public interface Problem {
|
|||
default Optional<String> rendered() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* The unique code attached to the diagnostic being reported.
|
||||
*
|
||||
* <p>NOTE: To avoid breaking compatibility we provide a default to account for older Scala
|
||||
* versions that do not have codes.
|
||||
*/
|
||||
default Optional<DiagnosticCode> diagnosticCode() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* The possible releated information for the diagnostic being reported.
|
||||
*
|
||||
* <p>NOTE: To avoid breaking compatibility we provide a default to account for older Scala
|
||||
* versions that do not have the concept of "related information".
|
||||
*/
|
||||
default List<DiagnosticRelatedInformation> diagnosticRelatedInforamation() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue