ocaml
0
fork

Configure Feed

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

add code to correctly find the source path of a tree

+16 -11
+16
lib/compiler/State.ml
··· 319 319 (* | _ -> () *) 320 320 () 321 321 ) 322 + 323 + 324 + let rec source_path_of_uri (uri : URI.t) (forest : t) : string option = 325 + let@ tree = Option.bind @@ find_opt forest uri in 326 + source_path_of_origin (Tree.origin tree) forest 327 + 328 + and source_path_of_origin (origin : origin) (forest : t) : string option = 329 + match origin with 330 + | Physical document -> 331 + Option.some @@ Lsp.Uri.to_path @@ Lsp.Text_document.documentUri document 332 + | Subtree {parent} -> source_path_of_identity parent forest 333 + | Undefined -> None 334 + 335 + and source_path_of_identity (identity : identity) (forest : t) : string option = 336 + let@ uri = Option.bind @@ identity_to_uri identity in 337 + source_path_of_uri uri forest
-11
lib/core/Tree.ml
··· 58 58 | Expanded _ -> "expanded" 59 59 | Resource _ -> "resource" 60 60 61 - let get_source_path ~base tree = 62 - match tree with 63 - | Document doc -> Some (Lsp.Uri.to_path (Lsp.Text_document.documentUri doc)) 64 - | Resource {resource; _} -> 65 - begin 66 - match resource with 67 - | T.Article article -> article.frontmatter.source_path 68 - | _ -> None 69 - end 70 - | Expanded {identity; _} | Parsed {identity; _} -> None 71 - 72 61 (* let get_uri ~base = fun t -> 73 62 let of_lsp_uri doc = Some (URI_scheme.lsp_uri_to_uri ~base (Lsp.Text_document.documentUri doc)) in 74 63 let uri_opt =