Class to handle json serialization and deserialization of messages.
Reads json objects of the form:
{
"kind":"ERROR",
"text":"errorText",
"original":"unparsed error text: Error in some intermediate file",
"sources": [{
"file":"/path/to/source.java",
"position":{
"startLine":1,
"startColumn":2,
"startOffset":3,
"endLine":4,
"endColumn":5,
"endOffset":6
}
}]
}
All fields, other than text, may be omitted. They have the following defaults:
Property | Default | Notes |
kind (ERROR, WARNING,
INFO, UNKNOWN) | UNKNOWN | |
text | Empty String | Should not be omitted. |
file (Absolute) | {} [unknown] | See SourceFileJsonTypeAdapter |
position | UNKNOWN | |
startLine,
startColumn,
startOffset | -1 [unknown] | 0-based |
endLine,
endColumn,
endOffset | startLine, startColumn,
startOffset |
Notes
- Offset need not be included, if needed by the consumer of the message it can
be derived from the file, line and column.
- If line is included and column is not the message will be considered to apply
to the whole line.
- A message can have multiple sources.
It also can read legacy serialized objects of the form:
{
"kind":"ERROR",
"text":"errorText",
"sourcePath": "/path/to/source.java",
"position":{
"startLine":1,
"startColumn":2,
"startOffset":3,
"endLine":4,
"endColumn":5,
"endOffset":6
}
}
These serializers are implemented using the lower-level TypeAdapter gson API which gives much
more control and allow changes to be made without breaking backward compatibility.