-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: Bring over additional types from Onivim 2 #22
Open
bryphe
wants to merge
4
commits into
master
Choose a base branch
from
refactor/additional-onivim-types
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Key: { | ||
type t = | ||
pri { | ||
hash: int, | ||
name: string, | ||
}; | ||
let compare: (t, t) => int; | ||
let create: string => t; | ||
} = { | ||
type t = { | ||
hash: int, | ||
name: string, | ||
}; | ||
|
||
let compare = (a, b) => | ||
a.hash == b.hash ? compare(a.name, b.name) : compare(a.hash, b.hash); | ||
|
||
let create = name => {hash: Hashtbl.hash(name), name}; | ||
}; | ||
|
||
include Map.Make(Key); | ||
|
||
let key = Key.create; | ||
let keyName = (key: key) => key.name; |
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,39 @@ | ||
type key; | ||
let key: string => key; | ||
let keyName: key => string; | ||
|
||
type t(+'a); | ||
|
||
let empty: t('a); | ||
let is_empty: t('a) => bool; | ||
|
||
let mem: (key, t('a)) => bool; | ||
let add: (key, 'a, t('a)) => t('a); | ||
let update: (key, option('a) => option('a), t('a)) => t('a); | ||
let remove: (key, t('a)) => t('a); | ||
let merge: | ||
((key, option('a), option('b)) => option('c), t('a), t('b)) => t('c); | ||
let union: ((key, 'a, 'a) => option('a), t('a), t('a)) => t('a); | ||
|
||
let compare: (('a, 'a) => int, t('a), t('a)) => int; | ||
let equal: (('a, 'a) => bool, t('a), t('a)) => bool; | ||
|
||
let iter: ((key, 'a) => unit, t('a)) => unit; | ||
let fold: ((key, 'a, 'b) => 'b, t('a), 'b) => 'b; | ||
|
||
let for_all: ((key, 'a) => bool, t('a)) => bool; | ||
let exists: ((key, 'a) => bool, t('a)) => bool; | ||
|
||
let filter: ((key, 'a) => bool, t('a)) => t('a); | ||
let partition: ((key, 'a) => bool, t('a)) => (t('a), t('a)); | ||
|
||
let find_opt: (key, t('a)) => option('a); | ||
let find_first_opt: (key => bool, t('a)) => option((key, 'a)); | ||
let find_last_opt: (key => bool, t('a)) => option((key, 'a)); | ||
|
||
let map: ('a => 'b, t('a)) => t('b); | ||
let mapi: ((key, 'a) => 'b, t('a)) => t('b); | ||
|
||
let to_seq: t('a) => Seq.t((key, 'a)); | ||
let add_seq: (Seq.t((key, 'a)), t('a)) => t('a); | ||
let of_seq: Seq.t((key, 'a)) => t('a); |
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,6 @@ | ||
(library | ||
(name Core) | ||
(public_name vscode-exthost.core) | ||
(library_flags (-linkall)) | ||
(libraries luv yojson decoders-yojson) | ||
(preprocess (pps ppx_deriving.show ppx_deriving_yojson))) | ||
Comment on lines
+1
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like this should have been removed entirely? |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
(library | ||
(name Extension) | ||
(public_name vscode-exthost.extension) | ||
(libraries Rench luv re timber yojson decoders-yojson vscode-exthost.types) | ||
(libraries Rench luv re timber yojson decoders-yojson vscode-exthost.whenexpr vscode-exthost.types) | ||
(preprocess (pps ppx_deriving.show ppx_deriving_yojson))) |
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,59 @@ | ||
module Log = (val Timber.Log.withNamespace("Oni2.Core.Command")); | ||
|
||
[@deriving show] | ||
type t('msg) = { | ||
id: string, | ||
title: option(string), | ||
category: option(string), | ||
icon: option([@opaque] IconTheme.IconDefinition.t), | ||
isEnabledWhen: WhenExpr.t, | ||
msg: [ | `Arg0('msg) | `Arg1(Json.t => 'msg)], | ||
}; | ||
|
||
let map = (f, command) => { | ||
...command, | ||
msg: | ||
switch (command.msg) { | ||
| `Arg0(msg) => `Arg0(f(msg)) | ||
| `Arg1(msgf) => `Arg1(arg => f(msgf(arg))) | ||
}, | ||
}; | ||
|
||
module Lookup = { | ||
type command('msg) = t('msg); | ||
type t('msg) = KeyedStringMap.t(command('msg)); | ||
|
||
let fromList = commands => | ||
commands | ||
|> List.to_seq | ||
|> Seq.map(command => (KeyedStringMap.key(command.id), command)) | ||
|> KeyedStringMap.of_seq; | ||
|
||
let get = (key, lookup) => | ||
KeyedStringMap.find_opt(KeyedStringMap.key(key), lookup); | ||
|
||
let add = (key, command, lookup) => | ||
KeyedStringMap.add(KeyedStringMap.key(key), command, lookup); | ||
|
||
let union = (xs, ys) => | ||
KeyedStringMap.union( | ||
(key, _x, y) => { | ||
Log.warnf(m => | ||
m("Encountered duplicate command: %s", KeyedStringMap.keyName(key)) | ||
); | ||
Some(y); | ||
}, | ||
xs, | ||
ys, | ||
); | ||
|
||
let unionMany = lookups => | ||
List.fold_left(union, KeyedStringMap.empty, lookups); | ||
|
||
let map = (f, lookup) => KeyedStringMap.map(map(f), lookup); | ||
|
||
let toList = lookup => | ||
KeyedStringMap.to_seq(lookup) | ||
|> Seq.map(((_key, definition)) => definition) | ||
|> List.of_seq; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, and the interface, seems to be duplicated in
Types
.