4.09: Replace TypedtreeIter with Tast_iterator
This commit is contained in:
parent
d8248687a3
commit
a4896483bd
|
@ -1564,11 +1564,7 @@ let interact ?(search_path=[]) ?(build_dir="_build") ~unit ~loc:(fname, lnum, cn
|
||||||
Printf.ksprintf failwith "%s.cmt not found in search path!" unit
|
Printf.ksprintf failwith "%s.cmt not found in search path!" unit
|
||||||
in
|
in
|
||||||
let cmt_infos = Cmt_format.read_cmt cmt_fname in
|
let cmt_infos = Cmt_format.read_cmt cmt_fname in
|
||||||
let module Search =
|
let expr next (e : Typedtree.expression) =
|
||||||
TypedtreeIter.MakeIterator(struct
|
|
||||||
include TypedtreeIter.DefaultIteratorArgument
|
|
||||||
|
|
||||||
let enter_expression (e : Typedtree.expression) =
|
|
||||||
match e.exp_desc with
|
match e.exp_desc with
|
||||||
| Texp_apply (_, args) -> begin
|
| Texp_apply (_, args) -> begin
|
||||||
try
|
try
|
||||||
|
@ -1581,14 +1577,28 @@ let interact ?(search_path=[]) ?(build_dir="_build") ~unit ~loc:(fname, lnum, cn
|
||||||
pos.pos_lnum = lnum &&
|
pos.pos_lnum = lnum &&
|
||||||
pos.pos_cnum - pos.pos_bol = cnum then
|
pos.pos_cnum - pos.pos_bol = cnum then
|
||||||
raise (Found v.exp_env)
|
raise (Found v.exp_env)
|
||||||
| _ -> ()
|
| _ -> next e
|
||||||
with Not_found -> ()
|
with Not_found -> next e
|
||||||
end
|
end
|
||||||
| _ -> ()
|
| _ -> next e
|
||||||
|
in
|
||||||
|
#if OCAML_VERSION >= (4,09,0)
|
||||||
|
let next iterator e = Tast_iterator.default_iterator.expr iterator e in
|
||||||
|
let expr iterator = expr (next iterator) in
|
||||||
|
let iter = { Tast_iterator.default_iterator with expr } in
|
||||||
|
let search = iter.structure iter in
|
||||||
|
#else
|
||||||
|
let module Search =
|
||||||
|
TypedtreeIter.MakeIterator(struct
|
||||||
|
include TypedtreeIter.DefaultIteratorArgument
|
||||||
|
|
||||||
|
let enter_expression = expr ignore
|
||||||
end) in
|
end) in
|
||||||
|
let search = Search.iter_structure in
|
||||||
|
#endif
|
||||||
try
|
try
|
||||||
begin match cmt_infos.cmt_annots with
|
begin match cmt_infos.cmt_annots with
|
||||||
| Implementation st -> Search.iter_structure st
|
| Implementation st -> search st
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
end;
|
end;
|
||||||
failwith "Couldn't find location in cmt file"
|
failwith "Couldn't find location in cmt file"
|
||||||
|
|
Loading…
Reference in New Issue