File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ let syntax_repr = " _"
2+ let can_be_hole s = String. equal syntax_repr s
3+
4+ (* the pattern matching below is taken and modified (minimally, to adapt the
5+ return type) from [Query_commands.dispatch]'s [Construct] branch;
6+
7+ If we directly dispatched [Construct] command to merlin, we'd be doing
8+ useless computations: we need info whether the expression at the cursor is a
9+ hole, we don't need constructed expressions yet.
10+
11+ Ideally, merlin should return a callback [option], which is [Some] when the
12+ context is applicable. *)
13+ let is_a_hole = function
14+ | (_, Browse_raw. Module_expr { mod_desc = Tmod_typed_hole ; _ }) :: (_, _) :: _
15+ | (_ , Browse_raw. Expression { exp_desc = Texp_typed_hole ; _ } ) :: _ -> true
16+ | [] | (_ , _ ) :: _ -> false
17+ ;;
Original file line number Diff line number Diff line change 1+ (* * This module should be used to work with typed holes. The main goal is to
2+ hide syntactic representation of a typed hole, which may change in future *)
3+
4+ (* * checks whether the current string matches the syntax representation of a
5+ typed hole *)
6+ val can_be_hole : string -> bool
7+
8+ (* * [is_a_hole nodes] checks whether the leaf node [1] is a typed hole
9+
10+ Note: this function is extracted from merlin sources handling [Construct]
11+ command in [merlin/src/frontend/query_commands.ml]
12+
13+ [1] leaf node is the head of the list, as
14+ [Mbrowse.t = (Env.t * Browse_raw.node) list]*)
15+ val is_a_hole : Mbrowse .t -> bool
You can’t perform that action at this time.
0 commit comments