@@ -16,6 +16,49 @@ 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+
1962let addParens doc =
2063 Doc. group (
2164 Doc. concat [
@@ -1985,11 +2028,7 @@ and printPackageConstraint i cmtTbl (longidentLoc, typ) =
19852028 ]
19862029
19872030and printExtension ~atModuleLvl (stringLoc , payload ) cmtTbl =
1988- let txt = match stringLoc.Location. txt with
1989- | "bs.raw" -> " raw"
1990- | "bs.obj" -> " obj"
1991- | txt -> txt
1992- in
2031+ let txt = convertBsExtension stringLoc.Location. txt in
19932032 let extName =
19942033 let doc = Doc. concat [
19952034 Doc. text " %" ;
@@ -4808,34 +4847,10 @@ and printPayload (payload : Parsetree.payload) cmtTbl =
48084847 ]
48094848
48104849and printAttribute ((id , payload ) : Parsetree. attribute ) cmtTbl =
4811- let contents = match id.txt with
4812- | "bs.val" -> " val"
4813- | "bs.module" -> " module"
4814- | "bs.scope" -> " scope"
4815- | "bs.splice" | "bs.variadic" -> " variadic"
4816- | "bs.set" -> " set"
4817- | "bs.set_index" -> " set_index"
4818- | "bs.get" -> " get"
4819- | "bs.get_index" -> " get_index"
4820- | "bs.new" -> " new"
4821- | "bs.obj" -> " obj"
4822- | "bs.return" -> " return"
4823- | "bs.uncurry" -> " uncurry"
4824- | "bs.this" -> " this"
4825- | "bs.meth" -> " meth"
4826- | "bs.deriving" -> " deriving"
4827- | "bs.string" -> " string"
4828- | "bs.int" -> " int"
4829- | "bs.ignore" -> " ignore"
4830- | "bs.unwrap" -> " unwrap"
4831- | "bs.as" -> " as"
4832- | "bs.optional" -> " optional"
4833- | txt -> txt
4834- in
48354850 Doc. group (
48364851 Doc. concat [
48374852 Doc. text " @" ;
4838- Doc. text contents ;
4853+ Doc. text (convertBsExternalAttribute id.txt) ;
48394854 printPayload payload cmtTbl
48404855 ]
48414856 )
0 commit comments