Skip to content

Commit e87d247

Browse files
committed
Cleanup
1 parent 359cc8c commit e87d247

File tree

5 files changed

+7
-71
lines changed

5 files changed

+7
-71
lines changed

jscomp/frontend/ast_attributes.ml

+1-2
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ let rs_externals (attrs : t) pval_prim =
148148
prims_to_be_encoded pval_prim
149149
| _, _ ->
150150
Ext_list.exists_fst attrs (fun ({txt} : string Asttypes.loc) ->
151-
Ext_string.starts_with txt "bs."
152-
|| Ext_array.exists external_attrs (fun (x : string) -> txt = x))
151+
Ext_array.exists external_attrs (fun (x : string) -> txt = x))
153152
|| prims_to_be_encoded pval_prim
154153

155154
let is_inline : attr -> bool = fun ({txt}, _) -> txt = "inline"

jscomp/frontend/bs_ast_invariant.ml

+4-9
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,10 @@
2828
*)
2929
let is_bs_attribute txt =
3030
match txt with
31-
(* TODO: Issue 6636 *)
32-
| "string" | "uncurry" -> true
33-
| _ ->
34-
let len = String.length txt in
35-
len >= 2
36-
(*TODO: check the stringing padding rule, this preciate may not be needed *)
37-
&& String.unsafe_get txt 0 = 'b'
38-
&& String.unsafe_get txt 1 = 's'
39-
&& (len = 2 || String.unsafe_get txt 2 = '.')
31+
| "bs" | "config" | "ignore" | "int" | "optional" | "string" | "uncurry"
32+
| "unwrap" ->
33+
true
34+
| _ -> false
4035

4136
let used_attributes : string Asttypes.loc Hash_set_poly.t =
4237
Hash_set_poly.create 16

jscomp/syntax/src/res_ast_conversion.ml

-12
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,6 @@ let normalize =
274274
let open Ast_mapper in
275275
{
276276
default_mapper with
277-
extension =
278-
(fun mapper ext ->
279-
match ext with
280-
| id, payload ->
281-
( {id with txt = Res_printer.convertBsExtension id.txt},
282-
default_mapper.payload mapper payload ));
283-
attribute =
284-
(fun mapper attr ->
285-
match attr with
286-
| id, payload ->
287-
( {id with txt = Res_printer.convertBsExternalAttribute id.txt},
288-
default_mapper.payload mapper payload ));
289277
attributes =
290278
(fun mapper attrs ->
291279
attrs

jscomp/syntax/src/res_printer.ml

+2-45
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,6 @@ type callbackStyle =
1616
*)
1717
| ArgumentsFitOnOneLine
1818

19-
(* Since compiler version 8.3, the bs. prefix is no longer needed *)
20-
(* Synced from
21-
https://github.com/rescript-lang/rescript-compiler/blob/29174de1a5fde3b16cf05d10f5ac109cfac5c4ca/jscomp/frontend/ast_external_process.ml#L291-L367 *)
22-
let convertBsExternalAttribute = function
23-
| "bs.as" -> "as"
24-
| "bs.deriving" -> "deriving"
25-
| "bs.get" -> "get"
26-
| "bs.get_index" -> "get_index"
27-
| "bs.ignore" -> "ignore"
28-
| "bs.inline" -> "inline"
29-
| "bs.int" -> "int"
30-
| "bs.meth" -> "meth"
31-
| "bs.module" -> "module"
32-
| "bs.new" -> "new"
33-
| "bs.obj" -> "obj"
34-
| "bs.optional" -> "optional"
35-
| "bs.return" -> "return"
36-
| "bs.send" -> "send"
37-
| "bs.scope" -> "scope"
38-
| "bs.set" -> "set"
39-
| "bs.set_index" -> "set_index"
40-
| "bs.splice" | "bs.variadic" -> "variadic"
41-
| "bs.string" -> "string"
42-
| "bs.this" -> "this"
43-
| "bs.uncurry" -> "uncurry"
44-
| "bs.unwrap" -> "unwrap"
45-
| "bs.val" -> "val"
46-
(* bs.send.pipe shouldn't be transformed *)
47-
| txt -> txt
48-
49-
(* These haven't been needed for a long time now *)
50-
(* Synced from
51-
https://github.com/rescript-lang/rescript-compiler/blob/29174de1a5fde3b16cf05d10f5ac109cfac5c4ca/jscomp/frontend/ast_exp_extension.ml *)
52-
let convertBsExtension = function
53-
| "bs.debugger" -> "debugger"
54-
| "bs.external" -> "raw"
55-
(* We should never see this one since we use the sugared object form, but still *)
56-
| "bs.obj" -> "obj"
57-
| "bs.raw" -> "raw"
58-
| "bs.re" -> "re"
59-
(* TODO: what about bs.time and bs.node? *)
60-
| txt -> txt
61-
6219
let addParens doc =
6320
Doc.group
6421
(Doc.concat
@@ -2154,7 +2111,7 @@ and printPackageConstraint ~state i cmtTbl (longidentLoc, typ) =
21542111
]
21552112

21562113
and printExtension ~state ~atModuleLvl (stringLoc, payload) cmtTbl =
2157-
let txt = convertBsExtension stringLoc.Location.txt in
2114+
let txt = stringLoc.Location.txt in
21582115
let extName =
21592116
let doc =
21602117
Doc.concat
@@ -5466,7 +5423,7 @@ and printAttribute ?(standalone = false) ~state
54665423
(Doc.concat
54675424
[
54685425
Doc.text (if standalone then "@@" else "@");
5469-
Doc.text (convertBsExternalAttribute id.txt);
5426+
Doc.text id.txt;
54705427
printPayload ~state payload cmtTbl;
54715428
]),
54725429
Doc.line )

jscomp/syntax/src/res_printer.mli

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
val convertBsExternalAttribute : string -> string
2-
val convertBsExtension : string -> string
3-
41
val printTypeParams :
52
(Parsetree.core_type * Asttypes.variance) list ->
63
Res_comments_table.t ->

0 commit comments

Comments
 (0)