File tree 1 file changed +12
-12
lines changed
1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -8,22 +8,22 @@ use anyhow::Result;
8
8
use jsonc_parser:: CollectOptions ;
9
9
use jsonc_parser:: ParseOptions ;
10
10
11
+ const COLLECT_OPTIONS : CollectOptions = CollectOptions {
12
+ comments : false ,
13
+ tokens : false ,
14
+ } ;
15
+
16
+ const PARSE_OPTIONS : ParseOptions = ParseOptions {
17
+ allow_comments : true ,
18
+ allow_loose_object_property_names : true ,
19
+ allow_trailing_commas : true ,
20
+ } ;
21
+
11
22
pub fn format_text (
12
23
input_text : & str ,
13
24
format_with_host : impl FnMut ( & Path , String ) -> Result < Option < String > > ,
14
25
) -> Result < Option < String > > {
15
- let parse_result = jsonc_parser:: parse_to_ast (
16
- input_text,
17
- & CollectOptions {
18
- comments : false ,
19
- tokens : false ,
20
- } ,
21
- & ParseOptions {
22
- allow_comments : true ,
23
- allow_loose_object_property_names : true ,
24
- allow_trailing_commas : true ,
25
- } ,
26
- ) ?;
26
+ let parse_result = jsonc_parser:: parse_to_ast ( input_text, & COLLECT_OPTIONS , & PARSE_OPTIONS ) ?;
27
27
let Some ( root_value) = parse_result. value else {
28
28
return Ok ( None ) ;
29
29
} ;
You can’t perform that action at this time.
0 commit comments