Skip to content

Commit

Permalink
generic id param
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredly committed Jun 7, 2018
1 parent 14dc286 commit bb15188
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ static/codemirror-5.36.0
_old
tmp
*.vsix
client/bin.native
2 changes: 1 addition & 1 deletion src/lsp/MessageHandlers.re
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let extend = (obj, items) => Json.obj(obj) |?>> current => Json.Object(current @
let log = Log.log;

let maybeHash = (h, k) => if (Hashtbl.mem(h, k)) { Some(Hashtbl.find(h, k)) } else { None };
type handler = Handler(string, Json.t => result('a, string), (state, 'a) => result((state, Json.t), string)) : handler;
/* type handler = Handler(string, Json.t => result('a, string), (state, 'a) => result((state, Json.t), string)) : handler; */

let handlers: list((string, (state, Json.t) => result((state, Json.t), string))) = [
("textDocument/definition", (state, params) => {
Expand Down
8 changes: 4 additions & 4 deletions src/lsp/Rpc.re
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module J = {

open Infix;

type jsonrpc = Message(float, string, Json.t) | Notification(string, Json.t);
type jsonrpc = Message(Json.t, string, Json.t) | Notification(string, Json.t);

let readMessage = (log, input) => {
let clength = input_line(input);
Expand All @@ -30,7 +30,7 @@ let readMessage = (log, input) => {
let json = try (Json.parse(raw)) {
| Failure(message) => failwith("Unable to parse message " ++ raw ++ " as json: " ++ message)
};
let id = Json.get("id", json) |?> Json.number;
let id = Json.get("id", json);
let method = Json.get("method", json) |?> Json.string |! "method required";
let params = Json.get("params", json) |! "params required";
switch id {
Expand All @@ -52,7 +52,7 @@ let sendMessage = (log, output, id, result) => {
open Json;
open J;
let content = Json.stringify(o([
("id", Number(id)),
("id", id),
("jsonrpc", s("2.0")),
("result", result)]));
log("Sending response " ++ content);
Expand All @@ -63,7 +63,7 @@ let sendError = (log, output, id, error) => {
open Json;
open J;
let content = Json.stringify(o([
("id", Number(id)),
("id", id),
("jsonrpc", s("2.0")),
("error", error)]));
log("Sending response " ++ content);
Expand Down

0 comments on commit bb15188

Please sign in to comment.