Skip to content
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

Alt+I to toggle between .mli/.ml .rei/.re #78

Merged
merged 1 commit into from May 21, 2017
Merged

Alt+I to toggle between .mli/.ml .rei/.re #78

merged 1 commit into from May 21, 2017

Conversation

ghost
Copy link

@ghost ghost commented May 20, 2017

Hi, as promised I added this feature to reason-tools, please let me know what you think of it! Thanks!

CC @chenglou

@@ -37,6 +42,7 @@ module Tabs = {
/* TODO: could use bs.ginore here? */

external sendMessage : tabId => 'a => ('b => unit) = "chrome.tabs.sendMessage" [@@bs.val];
external query: Js.t {. active: Js.boolean, currentWindow: Js.boolean} => (array (Js.t {. url: string, id:int}) => unit) => unit = "chrome.tabs.query" [@@bs.val];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument here might as well just be Js.t {..}, right?


Chrome.Commands.addListener (
fun command => {
Js.log command;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A rogue Js.log

Js.log command;
if(command == "toggle_between_interface_and_implementation") {
Chrome.Tabs.query {"active": Js.true_, "currentWindow": Js.true_} {fun activeTab => {
let currentTab = activeTab.(0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

activeTab, a singular, isn't a very good name for an array. The chrome API docs call it result. You could also just destructure it directly: fun [currentTab] => ...

| "rei" => "re"
| ext => ext
};
let getNewURL url =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getNewURL is a bit vague for a function at toplevel. How about swapExtension instead (it doesn't really matter whether it's a url or file path here either)

@@ -72,6 +72,35 @@ Chrome.ContextMenus.create {
"onclick": fun _ tab => toggleConversion tab##id
};

let convertExt ext => switch ext {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be shortened to let convertExt = fun | "ml" => "mli" | ...

Also, how about the names mapExtension or correspondingExtension instead?

@glennsl
Copy link
Collaborator

glennsl commented May 20, 2017

Could you also either run npm run build:prod, which will take a while, or exclude Popup.bundle.js?

@ghost
Copy link
Author

ghost commented May 21, 2017

@glennsl built with npm run build:prod. I moved the functions into my event handler as I figured no other place would be using them.

Copy link
Collaborator

@glennsl glennsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, this looks good to me now.

@glennsl glennsl requested a review from rickyvetter May 21, 2017 09:51
@ghost
Copy link
Author

ghost commented May 21, 2017

Ping @chenglou to merge it in 😄

@rickyvetter
Copy link
Collaborator

This is awesome! Thanks so much :)

@rickyvetter rickyvetter merged commit 132449c into reasonml:master May 21, 2017
@chenglou
Copy link
Member

This is exactly the kind of integration we need to highlight the utility of interface files. Thanks!

@rickyvetter we should put this in the readme

@rickyvetter
Copy link
Collaborator

Added a description to the readme. Will also be sure to include in release notes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants