forked from onivim/oni2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(exthost): MainThreadProgress shape (onivim#2129)
* Typing for Progress module * Add types for MainThreadProgress
- Loading branch information
Showing
5 changed files
with
184 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
open Oni_Core; | ||
|
||
module Location = { | ||
[@deriving show] | ||
type t = | ||
| Explorer | ||
| SCM | ||
| Extensions | ||
| Window | ||
| Notification | ||
| Dialog | ||
| Other(string); | ||
|
||
let ofInt = | ||
fun | ||
| 1 => Some(Explorer) | ||
| 3 => Some(SCM) | ||
| 5 => Some(Extensions) | ||
| 10 => Some(Window) | ||
| 15 => Some(Notification) | ||
| 20 => Some(Dialog) | ||
| _ => None; | ||
|
||
module Decode = { | ||
open Json.Decode; | ||
let int = | ||
int | ||
|> map(ofInt) | ||
|> and_then( | ||
fun | ||
| None => fail("Unrecognized location") | ||
| Some(location) => succeed(location), | ||
); | ||
|
||
let string = string |> map(str => Other(str)); | ||
}; | ||
|
||
let decode = | ||
Json.Decode.one_of([("int", Decode.int), ("string", Decode.string)]); | ||
}; | ||
|
||
module Options = { | ||
[@deriving show] | ||
type t = { | ||
location: Location.t, | ||
title: option(string), | ||
source: option(string), | ||
total: option(int), | ||
cancellable: bool, | ||
buttons: list(string), | ||
}; | ||
|
||
let decode = | ||
Json.Decode.( | ||
obj(({field, _}) => | ||
{ | ||
location: field.required("location", Location.decode), | ||
title: field.optional("title", string), | ||
source: field.optional("source", string), | ||
total: field.optional("total", int), | ||
cancellable: field.withDefault("cancellable", false, bool), | ||
buttons: field.withDefault("buttons", [], list(string)), | ||
} | ||
) | ||
); | ||
}; | ||
|
||
module Step = { | ||
[@deriving show] | ||
type t = { | ||
message: option(string), | ||
increment: option(int), | ||
total: option(int), | ||
}; | ||
|
||
let decode = | ||
Json.Decode.( | ||
obj(({field, _}) => | ||
{ | ||
message: field.optional("title", string), | ||
increment: field.optional("increment", int), | ||
total: field.optional("total", int), | ||
} | ||
) | ||
); | ||
}; |