Skip to content

Commit

Permalink
Remove extra space before external type definition
Browse files Browse the repository at this point in the history
This is a follow-up to reasonml#1966, this time removing the extra space before type
definitions for external declarations.
  • Loading branch information
anmonteiro committed May 28, 2018
1 parent f262af7 commit 733f823
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22 deletions.
27 changes: 13 additions & 14 deletions formatTest/typeCheckedTests/expected_output/attributes.re
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ let myFun =
/* Bucklescript FFI item attributes */

[@bs.val]
external imul : (int, int) => int = "Math.imul";
external imul: (int, int) => int = "Math.imul";

module Js = {
type t('a);
Expand Down Expand Up @@ -391,13 +391,13 @@ type reactClass;

/* "react-dom" shouldn't spread the attribute over multiple lines */
[@bs.val] [@bs.module "react-dom"]
external render : (reactElement, element) => unit =
external render: (reactElement, element) => unit =
"render";

[@bs.module "f"] external f : int => int = "f";
[@bs.module "f"] external f: int => int = "f";

[@bs.val] [@bs.module "react"] [@bs.splice]
external createCompositeElementInternalHack :
external createCompositeElementInternalHack:
(
reactClass,
{.. "reasonProps": 'props},
Expand All @@ -406,18 +406,18 @@ external createCompositeElementInternalHack :
reactElement =
"createElement";

external add_nat : (int, int) => int =
external add_nat: (int, int) => int =
"add_nat_bytecode" "add_nat_native";

[@bs.module "Bar"]
[@ocaml.deprecated
"Use bar instead. It's a much cooler function. This string needs to be a little long"
]
external foo : bool => bool = "";
external foo: bool => bool = "";

/* Attributes on an entire polymorphic variant leaf */
[@bs.module "fs"]
external readFileSync :
external readFileSync:
(
~name: string,
[@bs.string] [
Expand All @@ -429,7 +429,7 @@ external readFileSync :
"";

[@bs.module "fs"]
external readFileSync2 :
external readFileSync2:
(
~name: string,
[@bs.string] [
Expand All @@ -444,20 +444,19 @@ external readFileSync2 :
[@test [@attr]
[%%extension]];

external debounce :
(int, [@bs.meth] unit) => unit =
external debounce: (int, [@bs.meth] unit) => unit =
"";

external debounce :
external debounce:
int => [@bs.meth] (unit => unit) =
"";

external debounce :
external debounce:
(int, [@bs.meth] (unit => unit)) =>
[@bs.meth] (unit => unit) =
"";

external debounce :
external debounce:
(
int,
[@bs.meth] (unit => unit),
Expand All @@ -466,7 +465,7 @@ external debounce :
[@bs.meth] (unit => unit) =
"";

external debounce :
external debounce:
(
int,
[@bs.meth] (unit => unit),
Expand Down
8 changes: 4 additions & 4 deletions formatTest/typeCheckedTests/expected_output/attributes.rei
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ type reactClass;
type reactElement;

[@bs.val] [@bs.module "React"]
external createClassInternalHack :
external createClassInternalHack:
t('classSpec) => reactClass =
"createClass";

[@bs.send.pipe: array('a)]
external map : (. ('a => 'b)) => array('b) = "";
external map: (. ('a => 'b)) => array('b) = "";

[@bs.val] [@bs.module "react"]
external createClassInternalHack :
external createClassInternalHack:
t('classSpec) => reactClass =
"createClass";

[@bs.val] [@bs.module "react"] [@bs.splice]
external createCompositeElementInternalHack :
external createCompositeElementInternalHack:
(
reactClass,
t({.. reasonProps: 'props}),
Expand Down
2 changes: 1 addition & 1 deletion formatTest/unit_tests/expected_output/syntax.re
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ let A | B | C = X;
/** External function declaration
*
*/
external f : int => int = "foo";
external f: int => int = "foo";

let x = {contents: 0};

Expand Down
2 changes: 1 addition & 1 deletion formatTest/unit_tests/expected_output/uncurried.re
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ add(. 2, [@bs] 3);
type timerId;

[@bs.val]
external setTimeout :
external setTimeout:
((. unit) => unit, int) => timerId =
"setTimeout";

Expand Down
7 changes: 5 additions & 2 deletions src/reason-parser/reason_pprint_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5839,8 +5839,11 @@ let printer = object(self:'self)
*)
method primitive_declaration vd =
let lblBefore =
label ~space:true
(makeList ~postSpace:true [atom "external"; protectIdentifier vd.pval_name.txt; atom ":"])
label
~space:true
(makeList
~sepLeft:false
[(makeList ~postSpace:true [atom "external"; protectIdentifier vd.pval_name.txt]); (atom ":")])
(self#core_type vd.pval_type)
in
let frstHalf = makeList ~postSpace:true [lblBefore; atom "="] in
Expand Down

0 comments on commit 733f823

Please sign in to comment.