Class TestDiagnostic
java.lang.Object
org.checkerframework.framework.test.diagnostics.TestDiagnostic
- Direct Known Subclasses:
DetailedTestDiagnostic
Represents an expected error/warning message in a Java test file or an error/warning reported by
the Java compiler. By contrast,
TestDiagnosticLine
represents a set of TestDiagnostics,
all of which were read from the same line of a file. Subclass DetailedTestDiagnostic
is
used when the Checker Framework is invoked with the -Adetailedmsgtext
flag.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Path
The path to the test file.protected final String
The base file name of the test file.protected final boolean
Whether this diagnostic should no longer be reported after whole program inference.protected final DiagnosticKind
The diagnostic kind of the output.protected final long
The line number of the diagnostic output.protected final String
The full diagnostic message.protected final String
The message key that usually appears between parentheses in diagnostic messages.protected final boolean
Whether the message key had parentheses around it. -
Constructor Summary
ConstructorsConstructorDescriptionTestDiagnostic
(Path file, long lineNumber, DiagnosticKind kind, String message, boolean isFixable) Basic constructor that sets the immutable fields of this diagnostic.TestDiagnostic
(Path file, long lineNumber, DiagnosticKind kind, String messageKey, String message, boolean isFixable) Basic constructor that sets the immutable fields of this diagnostic. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Equality is compared based the file name, not the full path, on the messageKey, not the full message, and without considering isFixable and messageKeyParens.getFile()
The path to the test file.The base file name of the test file.getKind()
The diagnostic kind of the output.long
The line number of the diagnostic output.The full diagnostic message.The message key, without surrounding parentheses.int
hashCode()
boolean
Whether WPI can fix the test.static boolean
keepFullMessage
(String message) Determine whether the full diagnostic message should be used as message key.repr()
Returns the internal representation of this, formatted.toString()
Returns a representation of this diagnostic as if it appeared in a diagnostics file.
-
Field Details
-
file
The path to the test file. -
filename
The base file name of the test file. -
lineNumber
protected final long lineNumberThe line number of the diagnostic output. -
kind
The diagnostic kind of the output. -
message
The full diagnostic message. -
messageKey
The message key that usually appears between parentheses in diagnostic messages. Parentheses are removed and field messageKeyParens indicates whether they were present. -
messageKeyParens
protected final boolean messageKeyParensWhether the message key had parentheses around it. -
isFixable
protected final boolean isFixableWhether this diagnostic should no longer be reported after whole program inference.
-
-
Constructor Details
-
TestDiagnostic
public TestDiagnostic(Path file, long lineNumber, DiagnosticKind kind, String messageKey, String message, boolean isFixable) Basic constructor that sets the immutable fields of this diagnostic.- Parameters:
file
- the path to the test filelineNumber
- the line number of the diagnostic outputkind
- the diagnostic kind of the outputmessageKey
- the message keymessage
- the full diagnostic messageisFixable
- whether WPI can fix the test
-
TestDiagnostic
public TestDiagnostic(Path file, long lineNumber, DiagnosticKind kind, String message, boolean isFixable) Basic constructor that sets the immutable fields of this diagnostic.- Parameters:
file
- the path to the test filelineNumber
- the line number of the diagnostic outputkind
- the diagnostic kind of the outputmessage
- the full diagnostic messageisFixable
- whether WPI can fix the test
-
-
Method Details
-
keepFullMessage
Determine whether the full diagnostic message should be used as message key. This is useful to ensure e.g. stack traces are fully shown.- Parameters:
message
- the full message- Returns:
- whether the full diagnostic message should be used
-
getFile
The path to the test file.- Returns:
- the path to the test file
-
getFilename
The base file name of the test file.- Returns:
- the base file name of the test file
-
getLineNumber
public long getLineNumber()The line number of the diagnostic output.- Returns:
- the line number of the diagnostic output
-
getKind
The diagnostic kind of the output.- Returns:
- the diagnostic kind of the output
-
getMessageKey
The message key, without surrounding parentheses.- Returns:
- the message key
-
getMessage
The full diagnostic message.- Returns:
- the full diagnostic message
-
isFixable
public boolean isFixable()Whether WPI can fix the test.- Returns:
- whether WPI can fix the test
-
equals
Equality is compared based the file name, not the full path, on the messageKey, not the full message, and without considering isFixable and messageKeyParens. -
hashCode
public int hashCode() -
toString
Returns a representation of this diagnostic as if it appeared in a diagnostics file. This uses only the base file name, not the full path, and only the message key, not the full message. FieldmessageKeyParens
influences whether the message key is output in parentheses. -
repr
Returns the internal representation of this, formatted.- Returns:
- the internal representation of this, formatted
-