ocaml
0
fork

Configure Feed

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

URI_scheme.name: return string option

+13 -12
+2 -1
lib/compiler/Dir_scanner.ml
··· 59 59 let matches = 60 60 let@ () = S.run in 61 61 let@ fp = List.iter @~ dirs in 62 - process_dir (matching_basename (URI_scheme.name uri)) fp 62 + let@ name = Option.iter @~ URI_scheme.name uri in 63 + process_dir (matching_basename name) fp 63 64 in 64 65 try 65 66 let first_match = List.hd @@ List.of_seq matches in
+3 -3
lib/core/URI_scheme.ml
··· 19 19 |> List.rev 20 20 |> List.hd 21 21 22 - let name (uri : URI.t) : string = 22 + let name (uri : URI.t) : string option = 23 23 uri 24 24 |> URI.path_components 25 25 |> List.filter (fun x -> not (x = "")) 26 26 |> List.rev 27 - |> List.hd 27 + |> (List.nth_opt @~ 0) 28 28 29 29 let split_addr (uri : URI.t) : (string option * int) option = 30 - let name = name uri in 30 + let@ name = Option.bind @@ name uri in 31 31 (* primitively check for address of form YYYY-MM-DD *) 32 32 let date_regex = Str.regexp {|^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$|} in 33 33 if Str.string_match date_regex name 0 then None
+1 -1
lib/core/URI_scheme.mli
··· 24 24 URI.t 25 25 26 26 val last_segment : string -> string 27 - val name : URI.t -> string 27 + val name : URI.t -> string option
+7 -7
lib/language_server/Completion.ml
··· 248 248 249 249 let make (path, (data, _): Yuujinchou.Trie.path * (Resolver.P.data * Asai.Range.t option)) = 250 250 match data with 251 - | Term syn -> 251 + | Term [] -> None 252 + | Term (node :: _) -> 252 253 (* NOTE: Eventually we want to analyse the syntax so that, for example, 253 254 you can tab through the snippet for a function of arity n*) 254 - let kind = kind (List.hd syn).value in 255 + let kind = kind node.value in 255 256 let insertText = insert_text path in 256 257 Some 257 258 ( ··· 330 331 Some (`String content) 331 332 in 332 333 let@ uri = Option.bind @@ frontmatter.uri in 333 - let insertText = URI_scheme.name uri in 334 + let@ uri_name = Option.bind @@ URI_scheme.name uri in 334 335 let title_text = render title in 335 - let filterText = insertText ^ " " ^ title_text in 336 336 Option.some @@ 337 337 L.CompletionItem.create 338 338 ?documentation 339 - ~label: (Format.(asprintf "%a (%s)" pp_print_string title_text (URI_scheme.name uri))) 340 - ~insertText 341 - ~filterText 339 + ~label: (Format.(asprintf "%a (%s)" pp_print_string title_text uri_name)) 340 + ~insertText: uri_name 341 + ~filterText: (uri_name ^ " " ^ title_text) 342 342 () 343 343 344 344 let new_addr_completions ~(forest : State.t) : L.CompletionItem.t list =