Skip to content

Commit

Permalink
Upgrade to OCamlformat 0.26.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Julow authored and rgrinberg committed Nov 27, 2023
1 parent 2ffaea0 commit 33dcbc4
Show file tree
Hide file tree
Showing 26 changed files with 194 additions and 196 deletions.
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
# add ocamlformat config `wrap-fun-args=false`

75504946eaa6f817550b649df508d61dde12bbda
# Upgrade to OCamlformat 0.26.0
ab49baa5873e7f0b9181dbed3ad89681f1e4bcee
# Upgrade to OCamlformat 0.26.1
1a6419bac3ce012deb9c6891e6b25e2486c33388
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.24.1
version=0.26.1
profile=conventional
ocaml-version=4.14.0
break-separators=before
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
buildInputs = (with pkgs;
[
# dev tools
ocamlformat_0_24_1
ocamlformat_0_26_1
yarn

ocamlPackages.ppx_expect
Expand Down
15 changes: 8 additions & 7 deletions lsp-fiber/src/rpc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ end

module Table = Stdlib.Hashtbl.Make (Jsonrpc.Id)

module Make (Initialize : sig
type t
end)
(Out_request : Request_intf)
(Out_notification : Notification_intf)
(In_request : Request_intf)
(In_notification : Notification_intf) =
module Make
(Initialize : sig
type t
end)
(Out_request : Request_intf)
(Out_notification : Notification_intf)
(In_request : Request_intf)
(In_notification : Notification_intf) =
struct
type 'a out_request = 'a Out_request.t

Expand Down
25 changes: 12 additions & 13 deletions lsp/bin/metamodel/metamodel.mli
Original file line number Diff line number Diff line change
Expand Up @@ -137,25 +137,24 @@ module Path : sig
| Property of property * t
end

class map :
object
method literal : Path.t -> literalType -> literalType
class map : object
method literal : Path.t -> literalType -> literalType

method property : Path.t -> property -> property
method property : Path.t -> property -> property

method or_ : Path.t -> type_ list -> type_
method or_ : Path.t -> type_ list -> type_

method type_ : Path.t -> type_ -> type_
method type_ : Path.t -> type_ -> type_

method t : t -> t
method t : t -> t

method request : request -> request
method request : request -> request

method structure : structure -> structure
method structure : structure -> structure

method notification : notification -> notification
method notification : notification -> notification

method typeAlias : typeAlias -> typeAlias
method typeAlias : typeAlias -> typeAlias

method enumeration : enumeration -> enumeration
end
method enumeration : enumeration -> enumeration
end
49 changes: 24 additions & 25 deletions lsp/bin/ocaml/ml.mli
Original file line number Diff line number Diff line change
Expand Up @@ -144,49 +144,48 @@ module Type : sig
['env] is a custom value threaded through the path. Parent nodes can use
this to give child nodes context *)
class virtual ['env, 'm] mapreduce :
object ('self)
method virtual empty : 'm
class virtual ['env, 'm] mapreduce : object ('self)
method virtual empty : 'm

method virtual plus : 'm -> 'm -> 'm
method virtual plus : 'm -> 'm -> 'm

(** doesn't really to be here, but putting it here avoids passing [empty]
and [plus] to a general purpose [fold_left_map]*)
method private fold_left_map :
'a. f:('a -> 'a * 'm) -> 'a list -> 'a list * 'm
(** doesn't really to be here, but putting it here avoids passing [empty]
and [plus] to a general purpose [fold_left_map]*)
method private fold_left_map :
'a. f:('a -> 'a * 'm) -> 'a list -> 'a list * 'm

method alias : 'env -> t -> decl * 'm
method alias : 'env -> t -> decl * 'm

method app : 'env -> t -> t list -> t * 'm
method app : 'env -> t -> t list -> t * 'm

method assoc : 'env -> t -> t -> t * 'm
method assoc : 'env -> t -> t -> t * 'm

method constr : 'env -> constr -> constr * 'm
method constr : 'env -> constr -> constr * 'm

method field : 'env -> field -> field * 'm
method field : 'env -> field -> field * 'm

method list : 'env -> t -> t * 'm
method list : 'env -> t -> t * 'm

method path : 'env -> Path.t -> t * 'm
method path : 'env -> Path.t -> t * 'm

method optional : 'env -> t -> t * 'm
method optional : 'env -> t -> t * 'm

method poly_variant : 'env -> constr list -> t * 'm
method poly_variant : 'env -> constr list -> t * 'm

method prim : 'env -> prim -> t * 'm
method prim : 'env -> prim -> t * 'm

method record : 'env -> field list -> decl * 'm
method record : 'env -> field list -> decl * 'm

method t : 'env -> t -> t * 'm
method t : 'env -> t -> t * 'm

method decl : 'env -> decl -> decl * 'm
method decl : 'env -> decl -> decl * 'm

method tuple : 'env -> t list -> t * 'm
method tuple : 'env -> t list -> t * 'm

method var : 'env -> string -> t * 'm
method var : 'env -> string -> t * 'm

method variant : 'env -> constr list -> decl * 'm
end
method variant : 'env -> constr list -> decl * 'm
end
end

module Expr : sig
Expand Down
30 changes: 14 additions & 16 deletions lsp/bin/typescript/ts_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,29 @@ module type S = sig

val dyn_of_field : field -> Dyn.t

class map :
object
method typ : typ -> typ
class map : object
method typ : typ -> typ

method sum : typ list -> typ
method sum : typ list -> typ

method interface : interface -> interface
method interface : interface -> interface

method enum_anon : Enum.t -> Enum.t
method enum_anon : Enum.t -> Enum.t

method field : field -> field
method field : field -> field

method t : t -> t
end
method t : t -> t
end

class ['a] fold :
object
method field : field -> init:'a -> 'a
class ['a] fold : object
method field : field -> init:'a -> 'a

method ident : ident -> init:'a -> 'a
method ident : ident -> init:'a -> 'a

method t : t -> init:'a -> 'a
method t : t -> init:'a -> 'a

method typ : typ -> init:'a -> 'a
end
method typ : typ -> init:'a -> 'a
end
end

module Make (Ident : sig
Expand Down
30 changes: 14 additions & 16 deletions lsp/bin/typescript/ts_types.mli
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,29 @@ module type S = sig

val dyn_of_field : field -> Dyn.t

class map :
object
method enum_anon : Enum.t -> Enum.t
class map : object
method enum_anon : Enum.t -> Enum.t

method field : field -> field
method field : field -> field

method interface : interface -> interface
method interface : interface -> interface

method sum : typ list -> typ
method sum : typ list -> typ

method t : t -> t
method t : t -> t

method typ : typ -> typ
end
method typ : typ -> typ
end

class ['a] fold :
object
method field : field -> init:'a -> 'a
class ['a] fold : object
method field : field -> init:'a -> 'a

method ident : ident -> init:'a -> 'a
method ident : ident -> init:'a -> 'a

method t : t -> init:'a -> 'a
method t : t -> init:'a -> 'a

method typ : typ -> init:'a -> 'a
end
method typ : typ -> init:'a -> 'a
end
end

module Unresolved : sig
Expand Down
5 changes: 3 additions & 2 deletions lsp/src/diff.ml
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ let edit ~from:orig ~to_:formatted : TextEdit.t list =
text_edit
~line
(if prev_deleted_lines > 0 then
Replace { deleted = prev_deleted_lines; added = added_lines }
else Insert added_lines)
Replace
{ deleted = prev_deleted_lines; added = added_lines }
else Insert added_lines)
in
(line + prev_deleted_lines, 0, edit :: edits_rev)
| Equal { lines } ->
Expand Down
10 changes: 5 additions & 5 deletions lsp/src/string_zipper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ let cons sub list = if Substring.length sub = 0 then list else sub :: list
let is_end t =
let res = Substring.length t.current = t.rel_pos in
(if res then
match t.right with
| [] -> ()
| _ :: _ ->
invalid_arg
(sprintf "invalid state: current = %S" (Substring.to_string t.current)));
match t.right with
| [] -> ()
| _ :: _ ->
invalid_arg
(sprintf "invalid state: current = %S" (Substring.to_string t.current)));
res

let is_begin t =
Expand Down
74 changes: 37 additions & 37 deletions lsp/src/uri0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ let to_path { path; authority; scheme } =
else
let buff = Buffer.create 64 in
(if (not (String.is_empty authority)) && len > 1 && scheme = "file" then (
Buffer.add_string buff "//";
Buffer.add_string buff authority;
Buffer.add_string buff path)
else if len < 3 then Buffer.add_string buff path
else
let c0 = path.[0] in
let c1 = path.[1] in
let c2 = path.[2] in
if
c0 = '/'
&& ((c1 >= 'A' && c1 <= 'Z') || (c1 >= 'a' && c1 <= 'z'))
&& c2 = ':'
then (
Buffer.add_char buff (Char.lowercase_ascii c1);
Buffer.add_substring buff path 2 (String.length path - 2))
else Buffer.add_string buff path);
Buffer.add_string buff "//";
Buffer.add_string buff authority;
Buffer.add_string buff path)
else if len < 3 then Buffer.add_string buff path
else
let c0 = path.[0] in
let c1 = path.[1] in
let c2 = path.[2] in
if
c0 = '/'
&& ((c1 >= 'A' && c1 <= 'Z') || (c1 >= 'a' && c1 <= 'z'))
&& c2 = ':'
then (
Buffer.add_char buff (Char.lowercase_ascii c1);
Buffer.add_substring buff path 2 (String.length path - 2))
else Buffer.add_string buff path);
Buffer.contents buff
in
if !Private.win32 then slash_to_backslash path else path
Expand Down Expand Up @@ -102,29 +102,29 @@ let to_string { scheme; authority; path } =
(*TODO: implement full logic:
https://github.com/microsoft/vscode-uri/blob/96acdc0be5f9d5f2640e1c1f6733bbf51ec95177/src/uri.ts#L605 *)
(if not (String.is_empty authority) then
let s = String.lowercase_ascii authority in
Buffer.add_string buff (encode s));
let s = String.lowercase_ascii authority in
Buffer.add_string buff (encode s));

(if not (String.is_empty path) then
let encode = encode ~allow_slash:true in
let encoded_colon = "%3A" in
let len = String.length path in
if len >= 3 && path.[0] = '/' && path.[2] = ':' then (
let drive_letter = Char.lowercase_ascii path.[1] in
if drive_letter >= 'a' && drive_letter <= 'z' then (
Buffer.add_char buff '/';
Buffer.add_char buff drive_letter;
Buffer.add_string buff encoded_colon;
let s = String.sub path ~pos:3 ~len:(len - 3) in
Buffer.add_string buff (encode s)))
else if len >= 2 && path.[1] = ':' then (
let drive_letter = Char.lowercase_ascii path.[0] in
if drive_letter >= 'a' && drive_letter <= 'z' then (
Buffer.add_char buff drive_letter;
Buffer.add_string buff encoded_colon;
let s = String.sub path ~pos:2 ~len:(len - 2) in
Buffer.add_string buff (encode s)))
else Buffer.add_string buff (encode path));
let encode = encode ~allow_slash:true in
let encoded_colon = "%3A" in
let len = String.length path in
if len >= 3 && path.[0] = '/' && path.[2] = ':' then (
let drive_letter = Char.lowercase_ascii path.[1] in
if drive_letter >= 'a' && drive_letter <= 'z' then (
Buffer.add_char buff '/';
Buffer.add_char buff drive_letter;
Buffer.add_string buff encoded_colon;
let s = String.sub path ~pos:3 ~len:(len - 3) in
Buffer.add_string buff (encode s)))
else if len >= 2 && path.[1] = ':' then (
let drive_letter = Char.lowercase_ascii path.[0] in
if drive_letter >= 'a' && drive_letter <= 'z' then (
Buffer.add_char buff drive_letter;
Buffer.add_string buff encoded_colon;
let s = String.sub path ~pos:2 ~len:(len - 2) in
Buffer.add_string buff (encode s)))
else Buffer.add_string buff (encode path));

Buffer.contents buff

Expand Down
4 changes: 2 additions & 2 deletions ocaml-lsp-server/src/code_actions/action_open_related.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ let command_run server (params : ExecuteCommandParams.t) =
Server.request server (Server_request.ShowDocumentRequest req)
in
(if not success then
let uri = Uri.to_string uri in
Format.eprintf "failed to open %s@." uri);
let uri = Uri.to_string uri in
Format.eprintf "failed to open %s@." uri);
`Null

let available (capabilities : ShowDocumentClientCapabilities.t option) =
Expand Down
4 changes: 2 additions & 2 deletions ocaml-lsp-server/src/compl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ let complete (state : State.t)
Option.value
~default:false
(let open Option.O in
let* item = completion_item_capability in
item.deprecatedSupport)
let* item = completion_item_capability in
item.deprecatedSupport)
in
if not (Typed_hole.can_be_hole prefix) then
Complete_by_prefix.complete merlin prefix pos ~resolve ~deprecated
Expand Down
2 changes: 1 addition & 1 deletion ocaml-lsp-server/src/custom_requests/custom_request.mli
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type 't req_params_spec =
{ params_schema : Jsonrpc.Structured.t
(** used to document the structure of the params; example:
[`Assoc \[ "uri" , `String "<Uri>" \]]; *)
[`Assoc [ "uri" , `String "<Uri>" ]]; *)
; of_jsonrpc_params : Jsonrpc.Structured.t -> 't option
(** parses given structured JSON if it's of the expected schema;
otherwise, return [None] *)
Expand Down
Loading

0 comments on commit 33dcbc4

Please sign in to comment.