Skip to content

Commit

Permalink
semantic tokens use an array for encoding tokens
Browse files Browse the repository at this point in the history
instead of a list -- computing array difference for
`semanticTokens/full/delta` is more efficient with arrays
  • Loading branch information
Ulugbek authored and ulugbekna committed Jul 29, 2022
1 parent db554a6 commit b25effb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions lsp/src/types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34257,7 +34257,7 @@ module SemanticTokens = struct
type t =
{ resultId : string Json.Nullable_option.t
[@default None] [@yojson_drop_default ( = )]
; data : int list
; data : int array
}
[@@deriving_inline yojson] [@@yojson.allow_extra_fields]

Expand Down Expand Up @@ -34286,7 +34286,7 @@ module SemanticTokens = struct
| "data" -> (
match Ppx_yojson_conv_lib.( ! ) data_field with
| Ppx_yojson_conv_lib.Option.None ->
let fvalue = list_of_yojson int_of_yojson _field_yojson in
let fvalue = array_of_yojson int_of_yojson _field_yojson in
data_field := Ppx_yojson_conv_lib.Option.Some fvalue
| Ppx_yojson_conv_lib.Option.Some _ ->
duplicates := field_name :: Ppx_yojson_conv_lib.( ! ) duplicates)
Expand Down Expand Up @@ -34338,7 +34338,7 @@ module SemanticTokens = struct
| { resultId = v_resultId; data = v_data } ->
let bnds : (string * Ppx_yojson_conv_lib.Yojson.Safe.t) list = [] in
let bnds =
let arg = yojson_of_list yojson_of_int v_data in
let arg = yojson_of_array yojson_of_int v_data in
("data", arg) :: bnds
in
let bnds =
Expand All @@ -34357,15 +34357,15 @@ module SemanticTokens = struct

[@@@end]

let create ?(resultId : string option) ~(data : int list) (() : unit) : t =
let create ?(resultId : string option) ~(data : int array) (() : unit) : t =
{ resultId; data }
end

module SemanticTokensEdit = struct
type t =
{ start : int
; deleteCount : int
; data : int list Json.Nullable_option.t
; data : int array Json.Nullable_option.t
[@default None] [@yojson_drop_default ( = )]
}
[@@deriving_inline yojson] [@@yojson.allow_extra_fields]
Expand Down Expand Up @@ -34403,7 +34403,7 @@ module SemanticTokensEdit = struct
| Ppx_yojson_conv_lib.Option.None ->
let fvalue =
Json.Nullable_option.t_of_yojson
(list_of_yojson int_of_yojson)
(array_of_yojson int_of_yojson)
_field_yojson
in
data_field := Ppx_yojson_conv_lib.Option.Some fvalue
Expand Down Expand Up @@ -34468,7 +34468,7 @@ module SemanticTokensEdit = struct
if None = v_data then bnds
else
let arg =
(Json.Nullable_option.yojson_of_t (yojson_of_list yojson_of_int))
(Json.Nullable_option.yojson_of_t (yojson_of_array yojson_of_int))
v_data
in
let bnd = ("data", arg) in
Expand All @@ -34489,7 +34489,7 @@ module SemanticTokensEdit = struct

[@@@end]

let create ~(start : int) ~(deleteCount : int) ?(data : int list option)
let create ~(start : int) ~(deleteCount : int) ?(data : int array option)
(() : unit) : t =
{ start; deleteCount; data }
end
Expand Down
8 changes: 4 additions & 4 deletions lsp/src/types.mli
Original file line number Diff line number Diff line change
Expand Up @@ -3749,10 +3749,10 @@ end
module SemanticTokens : sig
type t =
{ resultId : string option
; data : int list
; data : int array
}

val create : ?resultId:string -> data:int list -> unit -> t
val create : ?resultId:string -> data:int array -> unit -> t

include Json.Jsonable.S with type t := t
end
Expand All @@ -3761,10 +3761,10 @@ module SemanticTokensEdit : sig
type t =
{ start : int
; deleteCount : int
; data : int list option
; data : int array option
}

val create : start:int -> deleteCount:int -> ?data:int list -> unit -> t
val create : start:int -> deleteCount:int -> ?data:int array -> unit -> t

include Json.Jsonable.S with type t := t
end
Expand Down

0 comments on commit b25effb

Please sign in to comment.