this repo has no description
0
fork

Configure Feed

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

Minor fixes

+216 -20
+13 -4
lib/impl.ml
··· 763 763 764 764 let failed_cells = ref StringSet.empty 765 765 766 - let complete_prefix _id _deps is_toplevel source position = 766 + let complete_prefix id deps is_toplevel source position = 767 767 try 768 - let line1, src = mangle_toplevel is_toplevel source [] in 769 - let src = line1 ^ src in 770 - Logs.info (fun m -> m "line1: '%s' (length: %d)" line1 (String.length line1)); 768 + Logs.info (fun m -> m "completing for id: %s" (match id with Some x -> x | None -> "(none)")); 771 769 770 + let line1, src = mangle_toplevel is_toplevel source deps in 771 + Logs.info (fun m -> m "line1: '%s' (length: %d)" line1 (String.length line1)); 772 + Logs.info (fun m -> m "src: '%s' (length: %d)" src (String.length src)); 773 + let src = line1 ^ src in 772 774 let source = Merlin_kernel.Msource.make src in 773 775 let map_kind : 774 776 [ `Value ··· 798 800 | Logical (x, y) -> `Logical (x + 1, y) 799 801 | End -> `End 800 802 in 803 + 804 + (match position with 805 + | `Offset x -> 806 + let first_char = String.sub src (x-1) 1 in 807 + Logs.info (fun m -> m "complete after offset: %s" first_char) 808 + | _ -> ()); 809 + 801 810 match Completion.at_pos source position with 802 811 | Some (from, to_, compl) -> 803 812 let entries =
+110 -6
test/node/node_test.expected
··· 46 46 node_test.js: [INFO] file_exists: /static/cmis/cell__c2.cmi = true 47 47 node_test.js: [INFO] Number of errors1: 1 (should be 1) 48 48 node_test.js: [INFO] Number of errors2: 0 (should be 0) 49 - node_test.js: [ERROR] xx Warning, ignoring toplevel block without a leading '# '. 50 - 49 + node_test.js: [INFO] completing for id: c_comp1 51 50 node_test.js: [INFO] line1: '' (length: 0) 51 + node_test.js: [INFO] src: 'let _ = List.leng' (length: 17) 52 + node_test.js: [INFO] complete after offset: g 52 53 node_test.js: [INFO] Fetching stdlib__List.cmi 53 54 54 55 node_test.js: [INFO] sync_get: _opam/lib/ocaml/stdlib__List.cmi 55 56 node_test.js: [INFO] Completions for 'List.leng': 1 entries 56 57 node_test.js: [INFO] - length (Value): 'a list -> int 58 + node_test.js: [INFO] completing for id: c_comp2 57 59 node_test.js: [INFO] line1: '' (length: 0) 58 - node_test.js: [INFO] Completions for 'List.': 2 entries 59 - node_test.js: [INFO] - List (Module): 60 - node_test.js: [INFO] - ListLabels (Module): 60 + node_test.js: [INFO] src: ' let _ = List.' (length: 15) 61 + node_test.js: [INFO] complete after offset: . 62 + node_test.js: [INFO] Completions for 'List.': 68 entries 63 + node_test.js: [INFO] - (::) (Constructor): 'a * 'a list -> 'a List.t 64 + node_test.js: [INFO] - ([]) (Constructor): 'a List.t 65 + node_test.js: [INFO] - append (Value): 'a list -> 'a list -> 'a list 66 + node_test.js: [INFO] - assoc (Value): 'a -> ('a * 'b) list -> 'b 67 + node_test.js: [INFO] - assoc_opt (Value): 'a -> ('a * 'b) list -> 'b option 68 + node_test.js: [INFO] - assq (Value): 'a -> ('a * 'b) list -> 'b 69 + node_test.js: [INFO] - assq_opt (Value): 'a -> ('a * 'b) list -> 'b option 70 + node_test.js: [INFO] - combine (Value): 'a list -> 'b list -> ('a * 'b) list 71 + node_test.js: [INFO] - compare (Value): ('a -> 'a -> int) -> 'a list -> 'a list -> int 72 + node_test.js: [INFO] - compare_length_with (Value): 'a list -> int -> int 73 + node_test.js: [INFO] - compare_lengths (Value): 'a list -> 'b list -> int 74 + node_test.js: [INFO] - concat (Value): 'a list list -> 'a list 75 + node_test.js: [INFO] - concat_map (Value): ('a -> 'b list) -> 'a list -> 'b list 76 + node_test.js: [INFO] - cons (Value): 'a -> 'a list -> 'a list 77 + node_test.js: [INFO] - equal (Value): ('a -> 'a -> bool) -> 'a list -> 'a list -> bool 78 + node_test.js: [INFO] - exists (Value): ('a -> bool) -> 'a list -> bool 79 + node_test.js: [INFO] - exists2 (Value): ('a -> 'b -> bool) -> 'a list -> 'b list -> bool 80 + node_test.js: [INFO] - fast_sort (Value): ('a -> 'a -> int) -> 'a list -> 'a list 81 + node_test.js: [INFO] - filter (Value): ('a -> bool) -> 'a list -> 'a list 82 + node_test.js: [INFO] - filter_map (Value): ('a -> 'b option) -> 'a list -> 'b list 83 + node_test.js: [INFO] - filteri (Value): (int -> 'a -> bool) -> 'a list -> 'a list 84 + node_test.js: [INFO] - find (Value): ('a -> bool) -> 'a list -> 'a 85 + node_test.js: [INFO] - find_all (Value): ('a -> bool) -> 'a list -> 'a list 86 + node_test.js: [INFO] - find_index (Value): ('a -> bool) -> 'a list -> int option 87 + node_test.js: [INFO] - find_map (Value): ('a -> 'b option) -> 'a list -> 'b option 88 + node_test.js: [INFO] - find_mapi (Value): (int -> 'a -> 'b option) -> 'a list -> 'b option 89 + node_test.js: [INFO] - find_opt (Value): ('a -> bool) -> 'a list -> 'a option 90 + node_test.js: [INFO] - flatten (Value): 'a list list -> 'a list 91 + node_test.js: [INFO] - fold_left (Value): ('acc -> 'a -> 'acc) -> 'acc -> 'a list -> 'acc 92 + node_test.js: [INFO] - fold_left2 (Value): ('acc -> 'a -> 'b -> 'acc) -> 'acc -> 'a list -> 'b list -> 'acc 93 + node_test.js: [INFO] - fold_left_map (Value): ('acc -> 'a -> 'acc * 'b) -> 'acc -> 'a list -> 'acc * 'b list 94 + node_test.js: [INFO] - fold_right (Value): ('a -> 'acc -> 'acc) -> 'a list -> 'acc -> 'acc 95 + node_test.js: [INFO] - fold_right2 (Value): ('a -> 'b -> 'acc -> 'acc) -> 'a list -> 'b list -> 'acc -> 'acc 96 + node_test.js: [INFO] - for_all (Value): ('a -> bool) -> 'a list -> bool 97 + node_test.js: [INFO] - for_all2 (Value): ('a -> 'b -> bool) -> 'a list -> 'b list -> bool 98 + node_test.js: [INFO] - hd (Value): 'a list -> 'a 99 + node_test.js: [INFO] - init (Value): int -> (int -> 'a) -> 'a list 100 + node_test.js: [INFO] - is_empty (Value): 'a list -> bool 101 + node_test.js: [INFO] - iter (Value): ('a -> unit) -> 'a list -> unit 102 + node_test.js: [INFO] - iter2 (Value): ('a -> 'b -> unit) -> 'a list -> 'b list -> unit 103 + node_test.js: [INFO] - iteri (Value): (int -> 'a -> unit) -> 'a list -> unit 104 + node_test.js: [INFO] - length (Value): 'a list -> int 105 + node_test.js: [INFO] - map (Value): ('a -> 'b) -> 'a list -> 'b list 106 + node_test.js: [INFO] - map2 (Value): ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list 107 + node_test.js: [INFO] - mapi (Value): (int -> 'a -> 'b) -> 'a list -> 'b list 108 + node_test.js: [INFO] - mem (Value): 'a -> 'a list -> bool 109 + node_test.js: [INFO] - mem_assoc (Value): 'a -> ('a * 'b) list -> bool 110 + node_test.js: [INFO] - mem_assq (Value): 'a -> ('a * 'b) list -> bool 111 + node_test.js: [INFO] - memq (Value): 'a -> 'a list -> bool 112 + node_test.js: [INFO] - merge (Value): ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list 113 + node_test.js: [INFO] - nth (Value): 'a list -> int -> 'a 114 + node_test.js: [INFO] - nth_opt (Value): 'a list -> int -> 'a option 115 + node_test.js: [INFO] - of_seq (Value): 'a Seq.t -> 'a list 116 + node_test.js: [INFO] - partition (Value): ('a -> bool) -> 'a list -> 'a list * 'a list 117 + node_test.js: [INFO] - partition_map (Value): ('a -> ('b, 'c) Either.t) -> 'a list -> 'b list * 'c list 118 + node_test.js: [INFO] - remove_assoc (Value): 'a -> ('a * 'b) list -> ('a * 'b) list 119 + node_test.js: [INFO] - remove_assq (Value): 'a -> ('a * 'b) list -> ('a * 'b) list 120 + node_test.js: [INFO] - rev (Value): 'a list -> 'a list 121 + node_test.js: [INFO] - rev_append (Value): 'a list -> 'a list -> 'a list 122 + node_test.js: [INFO] - rev_map (Value): ('a -> 'b) -> 'a list -> 'b list 123 + node_test.js: [INFO] - rev_map2 (Value): ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list 124 + node_test.js: [INFO] - sort (Value): ('a -> 'a -> int) -> 'a list -> 'a list 125 + node_test.js: [INFO] - sort_uniq (Value): ('a -> 'a -> int) -> 'a list -> 'a list 126 + node_test.js: [INFO] - split (Value): ('a * 'b) list -> 'a list * 'b list 127 + node_test.js: [INFO] - stable_sort (Value): ('a -> 'a -> int) -> 'a list -> 'a list 128 + node_test.js: [INFO] - tl (Value): 'a list -> 'a list 129 + node_test.js: [INFO] - to_seq (Value): 'a list -> 'a Seq.t 130 + node_test.js: [INFO] - t (Type): type 'a t = 'a list = [] | (::) of 'a * 'a list 131 + node_test.js: [INFO] completing for id: c_comp3 61 132 node_test.js: [INFO] line1: '' (length: 0) 62 - node_test.js: [INFO] Completions for 'ma': 0 entries 133 + node_test.js: [INFO] src: ' let _ = ma' (length: 12) 134 + node_test.js: [INFO] complete after offset: a 135 + node_test.js: [INFO] Completions for 'ma': 3 entries 136 + node_test.js: [INFO] - max (Value): 'a -> 'a -> 'a 137 + node_test.js: [INFO] - max_float (Value): float 138 + node_test.js: [INFO] - max_int (Value): int 139 + node_test.js: [INFO] completing for id: c_comp4 63 140 node_test.js: [INFO] line1: '' (length: 0) 141 + node_test.js: [INFO] src: 'let _ = List.leng' (length: 17) 142 + node_test.js: [INFO] complete after offset: g 64 143 node_test.js: [INFO] Completions for 'List.leng' (non-toplevel): 1 entries 65 144 node_test.js: [INFO] - length (Value): 'a list -> int 145 + node_test.js: [INFO] completing for id: c_comp5 66 146 node_test.js: [INFO] line1: '' (length: 0) 147 + node_test.js: [INFO] src: ' let _ = List.leng 148 + let foo=1.0;;' (length: 36) 67 149 node_test.js: [INFO] Completions for 'List.leng' (Logical position): 0 entries 150 + node_test.js: [INFO] completing for id: c_comp6 151 + node_test.js: [INFO] line1: '' (length: 0) 152 + node_test.js: [INFO] src: ' let my_var = 42;; 153 + let x = 1 + my_v' (length: 38) 154 + node_test.js: [INFO] complete after offset: v 155 + node_test.js: [INFO] Completions for 'my_v' (toplevel variable): 1 entries 156 + node_test.js: [INFO] - my_var (Value): int 157 + node_test.js: [INFO] completing for id: c_comp7 158 + node_test.js: [INFO] line1: '' (length: 0) 159 + node_test.js: [INFO] src: ' let rec factorial n = if n <= 1 then 1 else n * facto' (length: 55) 160 + node_test.js: [INFO] complete after offset: o 161 + node_test.js: [INFO] Completions for 'facto' (recursive function): 1 entries 162 + node_test.js: [INFO] - factorial (Value): int -> int 163 + node_test.js: [INFO] completing for id: c_comp8 164 + node_test.js: [INFO] line1: '' (length: 0) 165 + node_test.js: [INFO] src: ' String.lengt' (length: 14) 166 + node_test.js: [INFO] complete after offset: t 167 + node_test.js: [INFO] Fetching stdlib__String.cmi 168 + 169 + node_test.js: [INFO] sync_get: _opam/lib/ocaml/stdlib__String.cmi 170 + node_test.js: [INFO] Completions for 'String.lengt' (module path): 1 entries 171 + node_test.js: [INFO] - length (Value): string -> int 68 172 node_test.js: [INFO] Success
+93 -10
test/node/node_test.ml
··· 117 117 118 118 (* Test completion for List.leng *) 119 119 let* completions1 = 120 - Client.complete_prefix rpc (Some "c_comp1") [] true "let _ = List.leng" 121 - (Offset 16) 120 + let text = "let _ = List.leng" in 121 + Client.complete_prefix rpc (Some "c_comp1") [] false text 122 + (Offset (String.length text)) 122 123 in 123 124 Logs.info (fun m -> 124 125 m "Completions for 'List.leng': %d entries" ··· 142 143 143 144 (* Test completion for List. (should show all List module functions) *) 144 145 let* completions2 = 145 - Client.complete_prefix rpc (Some "c_comp2") [] true "# let _ = List." 146 - (Offset 12) 146 + let text = "# let _ = List." in 147 + Client.complete_prefix rpc (Some "c_comp2") [] true text 148 + (Offset (String.length text)) 147 149 in 148 150 Logs.info (fun m -> 149 151 m "Completions for 'List.': %d entries" ··· 167 169 168 170 (* Test completion for partial identifier *) 169 171 let* completions3 = 170 - Client.complete_prefix rpc (Some "c_comp3") [] true "# let _ = ma" 171 - (Offset 10) 172 + let text = "# let _ = ma" in 173 + Client.complete_prefix rpc (Some "c_comp3") [] true text 174 + (Offset (String.length text)) 172 175 in 173 176 Logs.info (fun m -> 174 177 m "Completions for 'ma': %d entries" (List.length completions3.entries)); ··· 191 194 192 195 (* Test completion in non-toplevel context *) 193 196 let* completions4 = 194 - Client.complete_prefix rpc (Some "c_comp4") [] false "let _ = List.leng" 195 - (Offset 16) 197 + let text = "let _ = List.leng" in 198 + Client.complete_prefix rpc (Some "c_comp4") [] false text 199 + (Offset (String.length text)) 196 200 in 197 201 Logs.info (fun m -> 198 202 m "Completions for 'List.leng' (non-toplevel): %d entries" ··· 216 220 217 221 (* Test completion using Logical position constructor *) 218 222 let* completions5 = 219 - Client.complete_prefix rpc (Some "c_comp5") [] true 220 - "# let _ = List.leng\n let foo=1.0;;" 223 + let text = "# let _ = List.leng\n let foo=1.0;;" in 224 + Client.complete_prefix rpc (Some "c_comp5") [] true text 221 225 (Logical (1, 16)) 222 226 in 223 227 Logs.info (fun m -> ··· 239 243 | Variant -> "Variant") 240 244 entry.desc)) 241 245 completions5.entries; 246 + 247 + (* Test toplevel completion with variable binding *) 248 + let* completions6 = 249 + let s = "# let my_var = 42;;\n# let x = 1 + my_v" in 250 + Client.complete_prefix rpc (Some "c_comp6") [] true 251 + s 252 + (Offset (String.length s)) 253 + in 254 + Logs.info (fun m -> 255 + m "Completions for 'my_v' (toplevel variable): %d entries" 256 + (List.length completions6.entries)); 257 + List.iter 258 + (fun entry -> 259 + Logs.info (fun m -> 260 + m " - %s (%s): %s" entry.name 261 + (match entry.kind with 262 + | Constructor -> "Constructor" 263 + | Keyword -> "Keyword" 264 + | Label -> "Label" 265 + | MethodCall -> "MethodCall" 266 + | Modtype -> "Modtype" 267 + | Module -> "Module" 268 + | Type -> "Type" 269 + | Value -> "Value" 270 + | Variant -> "Variant") 271 + entry.desc)) 272 + completions6.entries; 273 + 274 + (* Test toplevel completion with function definition *) 275 + let* completions7 = 276 + Client.complete_prefix rpc (Some "c_comp7") [] true 277 + "# let rec factorial n = if n <= 1 then 1 else n * facto" 278 + (Offset 55) 279 + in 280 + Logs.info (fun m -> 281 + m "Completions for 'facto' (recursive function): %d entries" 282 + (List.length completions7.entries)); 283 + List.iter 284 + (fun entry -> 285 + Logs.info (fun m -> 286 + m " - %s (%s): %s" entry.name 287 + (match entry.kind with 288 + | Constructor -> "Constructor" 289 + | Keyword -> "Keyword" 290 + | Label -> "Label" 291 + | MethodCall -> "MethodCall" 292 + | Modtype -> "Modtype" 293 + | Module -> "Module" 294 + | Type -> "Type" 295 + | Value -> "Value" 296 + | Variant -> "Variant") 297 + entry.desc)) 298 + completions7.entries; 299 + 300 + (* Test toplevel completion with module paths *) 301 + let* completions8 = 302 + Client.complete_prefix rpc (Some "c_comp8") [] true 303 + "# String.lengt" 304 + (Offset 14) 305 + in 306 + Logs.info (fun m -> 307 + m "Completions for 'String.lengt' (module path): %d entries" 308 + (List.length completions8.entries)); 309 + List.iter 310 + (fun entry -> 311 + Logs.info (fun m -> 312 + m " - %s (%s): %s" entry.name 313 + (match entry.kind with 314 + | Constructor -> "Constructor" 315 + | Keyword -> "Keyword" 316 + | Label -> "Label" 317 + | MethodCall -> "MethodCall" 318 + | Modtype -> "Modtype" 319 + | Module -> "Module" 320 + | Type -> "Type" 321 + | Value -> "Value" 322 + | Variant -> "Variant") 323 + entry.desc)) 324 + completions8.entries; 242 325 243 326 (* let* o3 = 244 327 Client.exec_toplevel rpc