Closed pisv closed 2 years ago
Unfortunately, the fix didn't work properly when testing the snapshot build in my local setting. JsonParseException: Ambiguous Either type: token BEGIN_OBJECT matches both alternatives
is still thrown when reading a response to textDocument/diagnostic
or workspace/diagnostic
requests.
The reason is that EitherTypeAdapter
, which is registered in MessageJsonHandler.getDefaultGsonBuilder()
, take precedence over DocumentDiagnosticReportTypeAdapter
and WorkspaceDocumentDiagnosticReportTypeAdapter
registered via @JsonAdapter
annotation. As stated in the annotation contract, "Field annotations take precedence over GsonBuilder
-registered type adapters, which in turn take precedence over annotated types."
I have changed the DocumentDiagnosticReportTypeAdapterTest
and WorkspaceDocumentDiagnosticReportTypeAdapterTest
to use the Gson
instance obtained from MessageJsonHandler
rather than a default Gson
instance. Now they started to fail with the same error as observed in my local setting.
I'm going to try a different approach, which is based on using @ResponseJsonAdapter
annotation on the corresponding request methods instead of @JsonAdapter
on the corresponding types. Hopefully, this can be done soon.
I have verified that the current fix works fine in my local setup. All tests are now green too. The PR is ready for review.
Adds type adapters for
DocumentDiagnosticReport
andWorkspaceDocumentDiagnosticReport
.Fixes #668.