Skip to content

Commit 613c7cd

Browse files
committed
warning for redundant chrome.debugger
1 parent 8df77da commit 613c7cd

File tree

5 files changed

+113
-2
lines changed

5 files changed

+113
-2
lines changed

jscomp/common/js_config.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,8 @@ let js_stdout = ref true
111111

112112
let all_module_aliases = ref false
113113

114-
let no_stdlib = ref false
114+
let no_stdlib = ref false
115+
116+
let no_export = ref false
117+
118+
let record_as_js_object = ref false (* otherwise has an attribute *)

jscomp/common/js_config.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,6 @@ val js_stdout : bool ref
108108

109109
val all_module_aliases : bool ref
110110

111-
val no_stdlib: bool ref
111+
val no_stdlib: bool ref
112+
val no_export: bool ref
113+
val record_as_js_object : bool ref

jscomp/syntax/ast_config.ml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
(* Copyright (C) 2020 Authors of BuckleScript
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU Lesser General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* In addition to the permissions granted to you by the LGPL, you may combine
9+
* or link a "work that uses the Library" with a publicly distributed version
10+
* of this file to produce a combined library or application, then distribute
11+
* that combined work under the terms of your choosing, with no requirement
12+
* to comply with the obligations normally placed on you by section 4 of the
13+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
14+
* should you choose to use a later version).
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Lesser General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Lesser General Public License
22+
* along with this program; if not, write to the Free Software
23+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24+
25+
26+
type action_table =
27+
(Parsetree.expression option -> unit) Map_string.t
28+
(** global configurations below *)
29+
let common_actions_table :
30+
(string * (Parsetree.expression option -> unit)) list =
31+
[
32+
]
33+
34+
35+
let structural_config_table : action_table =
36+
Map_string.of_list
37+
(( "no_export" ,
38+
(fun x ->
39+
Js_config.no_export := (
40+
match x with
41+
|Some e -> Ast_payload.assert_bool_lit e
42+
| None -> true)
43+
))
44+
:: common_actions_table)
45+
46+
let signature_config_table : action_table =
47+
Map_string.of_list common_actions_table
48+
49+
50+
let rec iter_on_bs_config_stru (x :Parsetree.structure) =
51+
match x with
52+
| [] -> ()
53+
| {pstr_desc = Pstr_attribute (({txt = "bs.config"; loc}, payload) as attr)}::_ ->
54+
Bs_ast_invariant.mark_used_bs_attribute attr;
55+
Ext_list.iter (Ast_payload.ident_or_record_as_config loc payload)
56+
(Ast_payload.table_dispatch structural_config_table)
57+
| {pstr_desc = Pstr_attribute _} :: rest ->
58+
iter_on_bs_config_stru rest
59+
| non_attr :: _ -> ()
60+
61+
let rec iter_on_bs_config_sigi (x :Parsetree.signature) =
62+
match x with
63+
| [] -> ()
64+
| {psig_desc = Psig_attribute (({txt = "bs.config"; loc}, payload) as attr)}::_ ->
65+
Bs_ast_invariant.mark_used_bs_attribute attr;
66+
Ext_list.iter (Ast_payload.ident_or_record_as_config loc payload)
67+
(Ast_payload.table_dispatch signature_config_table)
68+
| {psig_desc = Psig_attribute _} :: rest ->
69+
iter_on_bs_config_sigi rest
70+
| non_attr :: _ -> ()

jscomp/syntax/ast_config.mli

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(* Copyright (C) 2020 Authors of BuckleScript
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU Lesser General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* In addition to the permissions granted to you by the LGPL, you may combine
9+
* or link a "work that uses the Library" with a publicly distributed version
10+
* of this file to produce a combined library or application, then distribute
11+
* that combined work under the terms of your choosing, with no requirement
12+
* to comply with the obligations normally placed on you by section 4 of the
13+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
14+
* should you choose to use a later version).
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Lesser General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Lesser General Public License
22+
* along with this program; if not, write to the Free Software
23+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24+
25+
26+
27+
28+
val iter_on_bs_config_stru :
29+
Parsetree.structure ->
30+
unit
31+
32+
val iter_on_bs_config_sigi :
33+
Parsetree.signature ->
34+
unit

jscomp/syntax/bs_builtin_ppx.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ let structure_item_mapper (self : mapper) (str : Parsetree.structure_item) =
283283
Ast_exp_handle_external.handle_raw_structure loc payload
284284
| Pstr_extension (({txt = ("bs.debugger.chrome" | "debugger.chrome") ;loc}, payload),_)
285285
->
286+
Location.prerr_warning loc (Preprocessor "this extension can be safely removed");
286287
Ast_structure.dummy_item loc
287288
| Pstr_type (
288289
_rf,

0 commit comments

Comments
 (0)