-
Notifications
You must be signed in to change notification settings - Fork 93
Remove HoverContentsEmpty
from HoverContents
#162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm sorry for missing the issue. instance FromJSON HoverContents where
parseJSON v@(A.String _) = HoverContentsMS . singleton <$> parseJSON v -- PlainString
parseJSON v@(A.Array _) = HoverContentsMS <$> parseJSON v -- [MarkedString]
parseJSON v@(A.Object _) = HoverContents <$> parseJSON v -- MarkupContent
<|> HoverContentsMS . singleton <$> parseJSON v -- CodeString
parseJSON _ = mempty where |
Well, according to the spec, a Response message has /**
* The result of a request. This member is REQUIRED on success.
* This member MUST NOT exist if there was an error invoking the method.
*/
result?: string | number | boolean | object | null; So we encode That said, the change came about from a request for a student project, so perhaps the clients in the wild do not support this. But I am loathe to remove something that is actually specified to be like this. By my interpretation of the spec. @bubba ? |
I think the type HoverRequest = RequestMessage ClientMethod TextDocumentPositionParams (Maybe Hover)
type HoverResponse = ResponseMessage (Maybe Hover) In other words, what is the difference between the following result1, result2 :: Maybe Hover
result1 = Nothing
result2 = Just (Hover HoverContentsEmpty Nothing) |
The lspOptions = defaultOptions { omitNothingFields = True, fieldLabelModifier = drop 1 } so setting the response to This is different from explicitly encoding it as |
No, it isn't. Because data ResponseMessage a =
ResponseMessage
{ _jsonrpc :: Text
, _id :: LspIdRsp
, _result :: Maybe a
, _error :: Maybe ResponseError
} deriving (Read,Show,Eq)
deriveJSON lspOptions ''ResponseMessage
type HoverResponse
= ResponseMessage
{ _jsonrpc :: Text
, _id :: LspIdRsp
, _result :: Maybe (Maybe Hover)
, _error :: Maybe ResponseError
} So, ResponseMessage
{ _jsonrpc = "2.0"
, _id = 1
, _result = Just Nothing
, _error = Nothing
} and encoded into the following json {"jsonrpc":"2.0","id":1,"result":null} Indeed, hie has sent above message until this commit. By the way, |
Yes, it was a typo, I meant result. I will sort this out soon, I am in the midst of another PR, don't want to do two things in one. |
But keep the `Monoid` instance because it allows `mconcat` Closes #162
HoverContentsEmpty
, a constructor added in this commit, does not exist in original Language Server Protocol.This results in hie sending an invalid message to the client.
Isn't it better to remove this constructor?
Semigroup
would be enough if we want to combine results from multiple sources.The text was updated successfully, but these errors were encountered: