Skip to content

Commit

Permalink
Merge pull request #1108 from erlang-ls/1107-do-not-always-expect-params
Browse files Browse the repository at this point in the history
[#1107] Shutdown request does not include parameters
  • Loading branch information
robertoaloi committed Oct 4, 2021
2 parents 221f4c6 + ab4e526 commit cbc0f8d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions apps/els_core/src/els_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ handle_call({shutdown}, From, State) ->
#state{io_device = IoDevice} = State,
RequestId = State#state.request_id,
Method = <<"shutdown">>,
Params = #{},
Content = els_protocol:request(RequestId, Method, Params),
Content = els_protocol:request(RequestId, Method),
send(IoDevice, Content),
{noreply, State#state{ request_id = RequestId + 1
, pending = [{RequestId, From} | State#state.pending]
Expand Down
9 changes: 9 additions & 0 deletions apps/els_core/src/els_protocol.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
%%==============================================================================
%% Messaging API
-export([ notification/2
, request/2
, request/3
, response/2
, error/2
Expand All @@ -34,6 +35,14 @@ notification(Method, Params) ->
},
content(jsx:encode(Message)).

-spec request(number(), binary()) -> binary().
request(RequestId, Method) ->
Message = #{ jsonrpc => ?JSONRPC_VSN
, method => Method
, id => RequestId
},
content(jsx:encode(Message)).

-spec request(number(), binary(), any()) -> binary().
request(RequestId, Method, Params) ->
Message = #{ jsonrpc => ?JSONRPC_VSN
Expand Down
2 changes: 1 addition & 1 deletion apps/els_lsp/src/els_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ handle_request(#{ <<"method">> := _ReqMethod } = Request
, pending = Pending
} = State0) ->
Method = maps:get(<<"method">>, Request),
Params = maps:get(<<"params">>, Request),
Params = maps:get(<<"params">>, Request, #{}),
Type = case maps:is_key(<<"id">>, Request) of
true -> request;
false -> notification
Expand Down

0 comments on commit cbc0f8d

Please sign in to comment.