Declarative JSON data manipulation for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

loc,json,csv,sexp,toml,xml,opam,rego,sbom: rename Meta.textloc to Meta.loc

Follow up to the loc/json reorg: the [textloc] field of [Meta] is
renamed to [loc] across every text-codec consumer. Pure mechanical
rename, no behaviour change.

+27 -27
+25 -25
lib/json.ml
··· 1853 1853 1854 1854 (* Decoder errors *) 1855 1855 1856 - let[@inline] textloc_of_pos d ~first_byte ~last_byte ~first_line_num 1856 + let[@inline] loc_of_pos d ~first_byte ~last_byte ~first_line_num 1857 1857 ~first_line_byte ~last_line_num ~last_line_byte = 1858 1858 Loc.make ~file:d.file ~first_byte ~last_byte ~first_line_num ~first_line_byte 1859 1859 ~last_line_num ~last_line_byte ··· 1862 1862 let first_byte = last_byte_of d in 1863 1863 let first_line_num = d.line and first_line_byte = d.line_start in 1864 1864 Meta.make 1865 - @@ textloc_of_pos d ~first_byte ~last_byte:first_byte ~first_line_num 1865 + @@ loc_of_pos d ~first_byte ~last_byte:first_byte ~first_line_num 1866 1866 ~first_line_byte ~last_line_num:first_line_num 1867 1867 ~last_line_byte:first_line_byte 1868 1868 ··· 1870 1870 let last_byte = last_byte_of d in 1871 1871 let last_line_num = d.line and last_line_byte = d.line_start in 1872 1872 Meta.make 1873 - @@ textloc_of_pos d ~first_byte ~last_byte ~first_line_num ~first_line_byte 1873 + @@ loc_of_pos d ~first_byte ~last_byte ~first_line_num ~first_line_byte 1874 1874 ~last_line_num ~last_line_byte 1875 1875 1876 1876 let err_here d fmt = Error.failf (error_meta d) fmt ··· 2106 2106 tokbuf_clear d.ws; 2107 2107 t 2108 2108 2109 - let textloc_to_current ~first_byte ~first_line_num ~first_line_byte d = 2109 + let loc_to_current ~first_byte ~first_line_num ~first_line_byte d = 2110 2110 if not d.locs then Loc.none 2111 2111 else 2112 2112 let last_byte = last_byte_of d in 2113 2113 let last_line_num = d.line and last_line_byte = d.line_start in 2114 - textloc_of_pos d ~first_byte ~last_byte ~first_line_num ~first_line_byte 2114 + loc_of_pos d ~first_byte ~last_byte ~first_line_num ~first_line_byte 2115 2115 ~last_line_num ~last_line_byte 2116 2116 2117 - let textloc_prev_ascii_char ~first_byte ~first_line_num ~first_line_byte d = 2117 + let loc_prev_ascii_char ~first_byte ~first_line_num ~first_line_byte d = 2118 2118 (* N.B. when we call that the line doesn't move and the char was on 2119 2119 a single byte *) 2120 2120 if not d.locs then Loc.none 2121 2121 else 2122 2122 let last_byte = last_byte_of d - 1 in 2123 2123 let last_line_num = d.line and last_line_byte = d.line_start in 2124 - textloc_of_pos d ~first_byte ~last_byte ~first_line_num ~first_line_byte 2124 + loc_of_pos d ~first_byte ~last_byte ~first_line_num ~first_line_byte 2125 2125 ~last_line_num ~last_line_byte 2126 2126 2127 - let meta_make d ?ws_before ?ws_after textloc = 2127 + let meta_make d ?ws_before ?ws_after loc = 2128 2128 if (not d.locs) && not d.layout then d.meta_none 2129 - else Meta.make ?ws_before ?ws_after textloc 2129 + else Meta.make ?ws_before ?ws_after loc 2130 2130 2131 2131 (* Decoding *) 2132 2132 ··· 2161 2161 err_exp_in_const ~first_byte ~first_line_num ~first_line_byte d ~exp:c 2162 2162 ~fnd:d.u ~const:(ascii_str const) 2163 2163 done; 2164 - let textloc = 2165 - textloc_to_current d ~first_byte ~first_line_num ~first_line_byte 2164 + let loc = 2165 + loc_to_current d ~first_byte ~first_line_num ~first_line_byte 2166 2166 in 2167 2167 let ws_after = 2168 2168 nextc d; 2169 2169 read_ws d; 2170 2170 ws_pop d 2171 2171 in 2172 - meta_make d ~ws_before ~ws_after textloc 2172 + meta_make d ~ws_before ~ws_after loc 2173 2173 2174 2174 let[@inline] read_json_false d = read_json_const d false_uchars 2175 2175 let[@inline] read_json_true d = read_json_const d true_uchars ··· 2218 2218 read_int d; 2219 2219 read_opt_frac d; 2220 2220 read_opt_exp d; 2221 - let textloc = 2222 - textloc_prev_ascii_char d ~first_byte ~first_line_num ~first_line_byte 2221 + let loc = 2222 + loc_prev_ascii_char d ~first_byte ~first_line_num ~first_line_byte 2223 2223 in 2224 2224 let ws_after = 2225 2225 read_ws d; 2226 2226 ws_pop d 2227 2227 in 2228 - meta_make d ~ws_before ~ws_after textloc 2228 + meta_make d ~ws_before ~ws_after loc 2229 2229 2230 2230 let read_json_string d = 2231 2231 (* d.u is 0x0022 *) ··· 2305 2305 nextc d; 2306 2306 token_clear d; 2307 2307 loop d; 2308 - let textloc = 2309 - textloc_to_current d ~first_byte ~first_line_num ~first_line_byte 2308 + let loc = 2309 + loc_to_current d ~first_byte ~first_line_num ~first_line_byte 2310 2310 in 2311 2311 let ws_after = 2312 2312 nextc d; 2313 2313 read_ws d; 2314 2314 ws_pop d 2315 2315 in 2316 - meta_make d ~ws_before ~ws_after textloc 2316 + meta_make d ~ws_before ~ws_after loc 2317 2317 2318 2318 let read_json_name d = 2319 2319 let meta = read_json_string d in ··· 2537 2537 with Error e -> 2538 2538 Error.adjust_context ~first_byte ~first_line_num ~first_line_byte e) 2539 2539 in 2540 - let textloc = 2541 - textloc_to_current d ~first_byte ~first_line_num ~first_line_byte 2540 + let loc = 2541 + loc_to_current d ~first_byte ~first_line_num ~first_line_byte 2542 2542 in 2543 2543 let ws_after = 2544 2544 nextc d; 2545 2545 read_ws d; 2546 2546 ws_pop d 2547 2547 in 2548 - let meta = meta_make d ~ws_before ~ws_after textloc in 2548 + let meta = meta_make d ~ws_before ~ws_after loc in 2549 2549 map.dec_finish meta len b 2550 2550 2551 2551 and decode_object : type a. decoder -> (a, a) object_map -> a = ··· 2563 2563 | Error { ctx; meta; kind } when Loc.Context.is_empty ctx -> 2564 2564 let meta = 2565 2565 (* This is for when Codec.finish_object_decode raises. *) 2566 - if Loc.is_none (Meta.textloc meta) then 2566 + if Loc.is_none (Meta.loc meta) then 2567 2567 error_meta_to_current d ~first_byte ~first_line_num ~first_line_byte 2568 2568 else meta 2569 2569 in ··· 2571 2571 | Error e -> 2572 2572 Error.adjust_context ~first_byte ~first_line_num ~first_line_byte e 2573 2573 in 2574 - let textloc = 2575 - textloc_to_current d ~first_byte ~first_line_num ~first_line_byte 2574 + let loc = 2575 + loc_to_current d ~first_byte ~first_line_num ~first_line_byte 2576 2576 in 2577 2577 let ws_after = 2578 2578 nextc d; 2579 2579 read_ws d; 2580 2580 ws_pop d 2581 2581 in 2582 - let meta = meta_make d ~ws_before ~ws_after textloc in 2582 + let meta = meta_make d ~ws_before ~ws_after loc in 2583 2583 let dict = Dict.add Codec.object_meta_arg meta dict in 2584 2584 Codec.apply_dict map.dec dict 2585 2585
+1 -1
test/codecs/jsont_tool.ml
··· 142 142 let pp_locs_outline ppf v = 143 143 let indent = 2 in 144 144 let loc label ppf m = 145 - pf ppf "@[<v>%s:@,%a@]@," label Loc.pp_ocaml (Json.Meta.textloc m) 145 + pf ppf "@[<v>%s:@,%a@]@," label Loc.pp_ocaml (Json.Meta.loc m) 146 146 in 147 147 let rec value ppf = function 148 148 | Json.Null ((), m) ->
+1 -1
test/codecs/test_jsont_tool.ml
··· 14 14 let cmd = Cmd.(cmd %% path (src_in ~cwd src)) in 15 15 Snap.stdout ~cwd ~trim:false cmd !@Fpath.(src -+ ext) ~__POS__ 16 16 17 - let test_textlocs = 17 + let test_locs = 18 18 Test.test' args "locs" @@ fun (finit, cwd, (_i, valid_srcs)) -> 19 19 let cmd = Cmd.(finit % "locs") and ext = ".locs" in 20 20 List.iter (snap_stdout ~cwd cmd ~ext) valid_srcs;