···3939 report ~errors ~and_then:Eval_all
4040 | Expand uri -> begin
4141 Option.fold forest.={uri} ~none:(assert false) ~some:begin fun tree ->
4242- match Tree.to_code tree with
4242+ match Tree.code tree with
4343 | None -> assert false
4444 | Some code ->
4545 let result, errors = Phases.expand forest code in
+2-2
lib/compiler/Expand.ml
···10851085let expand_tree_inner ~forest (code : Tree.(parsed tree)) : Tree.(expanded tree)
10861086 =
10871087 let@ () = Sc.section [] in
10881088- let nodes = expand_eff ~forest Tree.(nodes code) in
10881088+ let nodes = expand_eff ~forest Tree.Parsed.(nodes code) in
10891089 let units = Sc.get_export () in
10901090- let tree : Tree.expanded = {nodes; code = Tree.nodes code; units} in
10901090+ let tree : Tree.expanded = {nodes; code = Tree.Parsed.nodes code; units} in
10911091 let source = Tree.Parsed.source code in
10921092 Tree.Expanded.create ?source tree
10931093
+18-14
lib/compiler/Imports.ml
···5050 result in some errors.*)
5151 assert (List.is_empty errors);
5252 match Forest.find_opt forest.index uri with
5353- | Some tree -> begin
5454- match Tree.to_code tree with None -> assert false | Some code -> ok code
5555- end
5656- | None -> begin
5757- match URI.Tbl.find_opt forest.resolver uri with
5353+ | Some tree ->
5454+ begin match Tree.code tree with
5555+ | None -> assert false
5656+ | Some code -> ok code
5757+ end
5858+ | None ->
5959+ begin match URI.Tbl.find_opt forest.resolver uri with
5860 | Some path ->
5961 let doc = load_tree Eio.Path.(forest.env#fs / path) in
6062 Result.map_error (Error.parse_error >>> List.singleton)
6163 @@ Parse.parse_document doc.tree
6262- | None -> begin
6363- match Dir_scanner.find_tree dirs uri with
6464+ | None ->
6565+ begin match Dir_scanner.find_tree dirs uri with
6466 | Some path ->
6567 let native = Eio.Path.native_exn path in
6668 URI.Tbl.add forest.resolver uri native;
···6870 Result.map_error (Error.parse_error >>> List.singleton)
6971 @@ Parse.parse_document doc.tree
7072 | None -> assert false
7373+ end
7174 end
7272- end
73757476let rec analyse_tree ~env ~uri code =
7577 let@ root = Option.iter @~ uri in
···8890 let target = T.Uri_vertex root in
8991 Forest_graph.add_vertex env.graph dependency;
9092 assert (Result.is_ok @@ add_edge env.graph dependency target);
9191- if env.follow then begin
9292- match resolve_uri_to_code ~forest:env.forest dep_uri with
9393- | Ok code -> analyse_tree ~env ~uri:(Some dep_uri) Tree.(nodes code)
9393+ if env.follow then
9494+ begin match resolve_uri_to_code ~forest:env.forest dep_uri with
9595+ | Ok code ->
9696+ analyse_tree ~env ~uri:(Some dep_uri) Tree.Parsed.(nodes code)
9497 | Error error -> env.errors <- List.append error env.errors
9595- end
9898+ end
9699 | Subtree (addr, nodes) ->
97100 let uri = Option.map (URI.named_uri ~base:config.url) addr in
98101 analyse_tree ~env ~uri nodes
···145148 let new_deps =
146149 let env = {forest; follow = false; graph; errors = []} in
147150 begin
148148- analyse_tree ~env ~uri:(Some uri) Tree.(nodes tree);
151151+ analyse_tree ~env ~uri:(Some uri) Tree.Parsed.(nodes tree);
149152 Vertex_set.of_list
150153 @@ Forest_graph.immediate_dependencies env.graph this_vertex
151154 end
···182185 {forest; follow = false; graph = Forest_graph.create (); errors = []}
183186 in
184187 State.get_all_code ~forest:env.forest
185185- |> Seq.iter (fun (uri, code) -> analyse_tree ~uri:(Some uri) ~env code);
188188+ |> List.iter (fun (uri, code) ->
189189+ analyse_tree ~uri:(Some uri) ~env Tree.Parsed.(nodes code));
186190 (env.errors, env.graph)
+2-2
lib/compiler/Phases.ml
···39394040let parse (forest : State.t) uri =
4141 let open Action in
4242- Option.bind forest.={uri} Tree.to_doc
4242+ Option.bind forest.={uri} Tree.document
4343 |> Option.fold
4444 ~some:begin fun tree ->
4545 match Parse.parse_document tree with
···9898 match forest.={uri} with
9999 | None -> ()
100100 | Some tree -> (
101101- match Tree.to_code tree with
101101+ match Tree.code tree with
102102 | Some tree ->
103103 let expanded, errors = Expand.expand_tree ~forest tree in
104104 diagnostics := errors @ !diagnostics;
+26-52
lib/compiler/State.ml
···8585 (* URI.Tbl.replace state.index uri item *)
86868787 (* / for units*)
8888- let ( ./{} ) state uri =
8989- Option.bind (URI.Tbl.find_opt state.index uri) Tree.get_units
8888+ let ( ./{} ) state uri = Option.bind state.={uri} Tree.units
90899190 (* @ for article/resource *)
9292- let ( .@{} ) state uri =
9393- Option.bind (URI.Tbl.find_opt state.index uri) Tree.to_resource
9191+ let ( .@{} ) state uri = Option.bind state.={uri} Tree.resource
9492end
9595-9696-open Syntax
97939894let update_history ~forest action =
9995 {forest with history = action :: forest.history}
10096101101-let find_opt state uri = URI.Tbl.find_opt state.index uri
10297let to_seq state = URI.Tbl.to_seq state.index
10398104104-let get_all_unparsed ~forest =
9999+let get_all ~forest f =
105100 forest.index |> URI.Tbl.to_seq
106106- |> Seq.filter_map (fun (uri, tree) ->
107107- match Tree.to_doc tree with Some doc -> Some (uri, doc) | _ -> None)
101101+ |> Seq.filter_map (fun (uri, t) ->
102102+ match f t with Some tree -> Some (uri, tree) | _ -> None)
108103 |> List.of_seq
109104110110-let get_all_code ~forest =
111111- forest.index |> URI.Tbl.to_seq
112112- |> Seq.filter_map (fun (uri, code) ->
113113- match to_code code with
114114- | None -> None
115115- | Some code -> Some (uri, nodes code))
116116-117117-let get_all_unexpanded ~forest =
118118- forest.index |> URI.Tbl.to_seq_values |> Seq.filter is_unexpanded
119119-120120-let get_all_expanded ~forest =
105105+let filter ~forest f =
121106 forest.index |> URI.Tbl.to_seq
122107 |> Seq.filter_map (fun (uri, tree) ->
123123- match to_syn tree with None -> None | Some tree -> Some (uri, tree))
108108+ if f tree then Some (uri, tree) else None)
124109 |> List.of_seq
125110126126-let get_all_unevaluated ~forest =
127127- forest.index |> URI.Tbl.to_seq
128128- |> Seq.filter_map (fun (uri, tree) ->
129129- if is_unevaluated tree then Some (uri, tree) else None)
130130-131131-let get_all_articles ~forest =
132132- forest.index |> URI.Tbl.to_seq_values |> Seq.filter_map to_article
133133-134134-let get_all_evaluated ~forest =
135135- forest.index |> URI.Tbl.to_seq_values |> Seq.filter_map to_evaluated
136136-137137-let get_all_resources : t -> T.content T.resource Seq.t =
138138- fun state -> state.index |> URI.Tbl.to_seq_values |> Seq.filter_map to_resource
111111+let get_all_unparsed = get_all Tree.document
112112+let get_all_code = get_all Tree.code
113113+let get_all_expanded = get_all Tree.syn
114114+let get_all_articles = get_all Tree.article
115115+let get_all_evaluated = get_all Tree.evaluated
116116+let get_all_resources = get_all Tree.resource
139117140140-let get_resource state uri =
141141- match state.={uri} with None -> None | Some tree -> to_resource tree
118118+let get_all_unevaluated = filter Tree.is_unevaluated
119119+let get_all_unexpanded = filter Tree.is_unexpanded
142120143143-let get_code state uri =
144144- match state.={uri} with None -> None | Some tree -> to_code tree
121121+open Syntax
145122146146-let get_article : forest:t -> URI.t -> T.content T.article option =
147147- fun ~forest uri ->
148148- match URI.Tbl.find_opt forest.index uri with
149149- | None -> None
150150- | Some tree -> Tree.to_article tree
151151-123123+let get_resource ~forest uri = Option.bind forest.={uri} Tree.resource
124124+let get_code ~forest uri = Option.bind forest.={uri} Tree.code
125125+let get_article ~forest uri = Option.bind forest.={uri} Tree.article
152126let resolve ~forest ~uri = URI.Tbl.find_opt forest.resolver uri
153127154128let section_symbol = "§"
···158132 let short_title =
159133 match frontmatter.title with
160134 | Some content -> content
161161- | None when not flags.empty_when_untitled -> begin
162162- match frontmatter.uri with
135135+ | None when not flags.empty_when_untitled ->
136136+ begin match frontmatter.uri with
163137 | Some uri -> T.Content [T.Uri uri]
164138 | _ -> T.Content [T.Text "Untitled"]
165165- end
139139+ end
166140 | _ -> T.Content []
167141 in
168142 Option.value ~default:short_title
···221195let get_title_or_content_of_vertex ?(not_found = fun _ -> None) vertex forest =
222196 match vertex with
223197 | T.Content_vertex content -> Some content
224224- | T.Uri_vertex uri -> begin
225225- match get_article ~forest uri with
198198+ | T.Uri_vertex uri ->
199199+ begin match get_article ~forest uri with
226200 | Some article -> article.frontmatter.title
227201 | None -> not_found uri
228228- end
202202+ end
229203230204(* A list of mistakes that a user might make when typing a given URI. For
231205 example, they might type "https://www.forester-notes.com/005P" instead of
···281255 let tree =
282256 Option.fold forest.={uri}
283257 ~some:begin fun tree ->
284284- let expanded = Tree.to_expanded tree in
258258+ let expanded = Tree.syn tree in
285259 let source = Tree.source tree in
286260 Tree.Evaluated.create ?source ~route_locally ~include_in_manifest
287261 ?expanded resource
+3-3
lib/compiler/test/Test_compiler.ml
···5151 (List.length (State.get_all_unparsed ~forest));
5252 Alcotest.(check @@ int)
5353 "no tree is unexpanded" 0
5454- (Seq.length (State.get_all_unexpanded ~forest));
5454+ (List.length (State.get_all_unexpanded ~forest));
5555 Alcotest.(check @@ int)
5656 "no tree is unevaluated" 0
5757- (Seq.length (State.get_all_unevaluated ~forest));
5757+ (List.length (State.get_all_unevaluated ~forest));
5858 Alcotest.(check @@ int)
5959 "has correct number of articles" 8
6060- (Seq.length (State.get_all_articles ~forest))
6060+ (List.length (State.get_all_articles ~forest))
61616262let test_includes_paths ~env () =
6363 let config = Config.default () in
+14-8
lib/core/Tree.ml
···4747 let create : ?source:source -> parsed -> t =
4848 fun ?source tree -> {tree; phase = Parsed; source}
4949 let source {source; _} = source
5050+ let nodes ({tree; _} : t) = tree
5051end
51525253module Expanded = struct
···6162 type t = evaluated tree
6263 let create ~route_locally ~include_in_manifest ?expanded ?source
6364 (resource : _ T.resource) =
6464- let tree = {resource; route_locally; include_in_manifest; expanded} in
6565+ let tree =
6666+ let expanded =
6767+ match expanded with Some expanded -> Some expanded.tree | None -> None
6868+ in
6969+ {resource; route_locally; include_in_manifest; expanded}
7070+ in
6571 {tree; phase = Evaluated; source}
66726773 let source {source; _} = source
···105111 end
106112 end
107113108108-let to_doc : t -> loaded option = function
114114+let document : t -> loaded option = function
109115 | Tree {phase; tree; _} -> begin
110116 match phase with Loaded -> Some tree | _ -> None
111117 end
···133139 end
134140 | _ -> None
135141136136-let to_resource : t -> T.content T.resource option = function
142142+let resource : t -> T.content T.resource option = function
137143 | Tree {phase; tree; _} -> begin
138144 match phase with
139145 | Loaded -> None
···150156 | _ -> None
151157 end
152158153153-let to_evaluated : t -> evaluated option = function
159159+let evaluated : t -> evaluated option = function
154160 | Tree {phase; tree; _} -> begin
155161 match phase with
156162 | Loaded | Parsed | Expanded -> None
157163 | Evaluated -> Some tree
158164 end
159165160160-let to_article : t -> T.content T.article option = function
166166+let article : t -> T.content T.article option = function
161167 | Tree {phase; tree; _} -> begin
162168 match phase with
163169 | Loaded | Parsed | Expanded -> None
···177183 | _ -> None
178184 end
179185180180-let to_code : t -> Code.t tree option = function
186186+let code : t -> Code.t tree option = function
181187 | Tree ({phase; tree; source} as t) -> begin
182188 match phase with
183189 | Loaded -> None
···192198193199let nodes : Code.t tree -> Code.t = function {tree; _} -> tree
194200195195-let to_syn : t -> expanded tree option = function
201201+let syn : t -> expanded tree option = function
196202 | Tree {phase; tree; source} -> begin
197203 match phase with
198204 | Loaded -> None
···204210 | None -> None)
205211 end
206212207207-let get_units : t -> exports option = function
213213+let units : t -> exports option = function
208214 | Tree {phase; tree; _} -> (
209215 match phase with
210216 | Loaded -> None
+8-11
lib/frontend/Forester.ml
···54545555let complete ~(forest : State.t) prefix : (string * string) List.t =
5656 let config = forest.config in
5757- let@ article =
5858- List.filter_map @~ List.of_seq @@ State.get_all_articles ~forest
5959- in
6060- let@ uri = Option.bind article.frontmatter.uri in
5757+ let@ uri, article = List.filter_map @~ State.get_all_articles ~forest in
6158 let short_uri = URI.display_path_string ~base:config.url uri in
6259 let@ title = Option.bind article.frontmatter.title in
6360 let title = Plain_text_client.string_of_content ~forest title in
···8885 let render = Json_manifest_client.render_tree ~forest in
8986 let articles =
9087 let@ tree = Seq.filter_map @~ Forest.to_seq_values forest.index in
9191- let@ evaluated = Option.bind @@ Tree.to_evaluated tree in
9292- if evaluated.include_in_manifest then Tree.to_article tree else None
8888+ let@ evaluated = Option.bind @@ Tree.evaluated tree in
8989+ if evaluated.include_in_manifest then Tree.article tree else None
9390 in
9491 articles |> List.of_seq
9592 |> List.sort (Forest_util.compare_article ~forest)
···134131 let@ vertex = List.filter_map @~ Vertex_set.elements vertices in
135132 match vertex with
136133 | Content_vertex _ -> None
137137- | Uri_vertex uri -> State.get_resource forest uri
134134+ | Uri_vertex uri -> State.get_resource ~forest uri
138135 in
139136 let json_content =
140137 Repr.to_json_string ~minify:true (T.forest_t T.content_t) resources
···173170let render_forest ~dev ~emit_legacy_xml ~(forest : State.t) : unit =
174171 let cwd = Eio.Stdenv.cwd forest.env in
175172 let all_resources = State.get_all_evaluated ~forest in
176176- Logs.debug (fun m -> m "Rendering %i resources" (Seq.length all_resources));
173173+ Logs.debug (fun m -> m "Rendering %i resources" (List.length all_resources));
177174 begin
178175 let json_string = json_manifest ~dev ~forest in
179176 let json_path = EP.(output_path ~cwd ~forest / "forest.json") in
···188185 ~path:(uri_to_local_path ~forest forest.config.home)
189186 in
190187 let errors, jobs =
191191- all_resources |> List.of_seq
192192- |> Eio.Fiber.List.map ~max_fibers:40
193193- (outputs_for_resource ~forest ~emit_legacy_xml)
188188+ all_resources
189189+ |> Eio.Fiber.List.map ~max_fibers:40 (fun (_, tree) ->
190190+ outputs_for_resource ~forest ~emit_legacy_xml tree)
194191 |> List.partition_map (function Ok v -> Right v | Error e -> Left e)
195192 in
196193 (errors, List.cons [(home_route, home_content)] jobs)
+1-1
lib/frontend/Legacy_xml_client.ml
···2929 match forest.={uri} with
3030 | None -> uri
3131 | Some tree -> begin
3232- match Tree.to_evaluated tree with
3232+ match Tree.evaluated tree with
3333 | Some evaluated when evaluated.route_locally ->
3434 let path = "" :: local_path_components forest.config uri in
3535 URI.make ~path ()
+12-12
lib/language_server/Analysis.ml
···111111 | None -> None
112112 | Some ({value; range} as node) -> (
113113 match value with
114114- | Code.Group (delim, t) -> begin
115115- match go ~position t with
114114+ | Code.Group (delim, t) ->
115115+ begin match go ~position t with
116116 | None -> Some Range.{value = (delim, t); range}
117117 | Some t -> Some t
118118- end
118118+ end
119119 | _ -> (go ~position) (Code.children node))
120120 in
121121- match Tree.to_code tree with
121121+ match Tree.code tree with
122122 | None -> None
123123- | Some code -> go ~position @@ Tree.nodes code
123123+ | Some code -> go ~position @@ Tree.Parsed.nodes code
124124125125let get_enclosing_syn_group ~position tree =
126126 let rec go ~position nodes =
···130130 | None -> None
131131 | Some ({value; range} as node) -> (
132132 match value with
133133- | Syn.Group (delim, children) -> begin
134134- match go ~position children with
133133+ | Syn.Group (delim, children) ->
134134+ begin match go ~position children with
135135 | None -> Some Range.{value = (delim, children); range}
136136 | Some t -> Some t
137137- end
137137+ end
138138 | _ -> go ~position (Syn.children node))
139139 in
140140- match Tree.to_syn tree with
140140+ match Tree.syn tree with
141141 | None -> None
142142 | Some syn -> go ~position syn.tree.nodes
143143···172172 let go ~position ~children nodes =
173173 match find_with_prev ~position nodes with
174174 | None -> None
175175- | Some (None, node) -> begin
176176- match (node_at ~position ~children) (children node) with
175175+ | Some (None, node) ->
176176+ begin match (node_at ~position ~children) (children node) with
177177 | Some inner ->
178178 (* go ~position ~children (children inner) *)
179179 Some (Context.Top inner)
180180 | None -> Some (Top node)
181181- end
181181+ end
182182 | Some (Some prev, node) -> (
183183 match (node_at ~position ~children) (children node) with
184184 | None -> Some (Prev (prev, node))
+1-1
lib/language_server/Call_hierarchy.ml
···8383 | Error _ -> None
8484 | Ok tree ->
8585 let item =
8686- match Analysis.node_at_code ~position (Tree.nodes tree) with
8686+ match Analysis.node_at_code ~position (Tree.Parsed.nodes tree) with
8787 | None -> None
8888 | Some {range = _; value} -> (
8989 match value with
+7-8
lib/language_server/Completion.ml
···125125 date_completion;
126126 ]
127127 in
128128- let code_opt = Tree.to_code t in
129129- let syn_opt = Tree.to_syn t in
130130- let doc_opt = Tree.to_doc t in
128128+ let code_opt = Tree.code t in
129129+ let syn_opt = Tree.syn t in
130130+ let doc_opt = Tree.document t in
131131 let text_context = Option.bind doc_opt @@ Analysis.word_before ~position in
132132 Logs.debug (fun m ->
133133 m "Text_context: %a" Format.(pp_print_option pp_print_string) text_context);
···137137 Option.bind @@ Analysis.enclosing_group_start ~enclosing_group ~position t
138138 in
139139 let@ code = Option.bind code_opt in
140140- Analysis.parent_or_prev_at_code ~position @@ Tree.nodes code
140140+ Analysis.parent_or_prev_at_code ~position @@ Tree.Parsed.nodes code
141141 in
142142 let syn_context =
143143 let enclosing_group = Analysis.get_enclosing_syn_group in
···280280 L.CompletionItem.create ~insertText ~label ()
281281282282let addr_completions ~(forest : State.t) : L.CompletionItem.t list =
283283- let articles = List.of_seq @@ State.get_all_articles ~forest in
284284- let@ article = List.filter_map @~ articles in
283283+ let@ uri, article = List.filter_map @~ State.get_all_articles ~forest in
285284 let frontmatter = article.frontmatter in
286285 let@ _ = Option.bind frontmatter.title in
287286 let title = State.get_expanded_title frontmatter forest in
···340339 let base = config.url in
341340 let uri = URI.of_lsp_uri ~base uri in
342341 let* tree = forest.={uri} in
343343- let* code = Tree.to_code tree in
342342+ let* code = Tree.code tree in
344343 let completion_types = completion_types ~position tree in
345344 let items =
346345 let@ completion = List.concat_map @~ S.to_list completion_types in
···348347 | Addrs -> addr_completions ~forest
349348 | New_addr -> new_addr_completions ~forest
350349 | Assets -> asset_completions ~config
351351- | Visible -> visible_completions ~forest ~position @@ Tree.nodes code
350350+ | Visible -> visible_completions ~forest ~position @@ Tree.Parsed.nodes code
352351 | Date -> date_completions ()
353352 in
354353 Logs.debug (fun m -> m "items: %d" (List.length items));
+1-1
lib/language_server/Definitions.ml
···1818 let Lsp_state.{forest; _} = Lsp_state.get () in
1919 let uri = URI.of_lsp_uri ~base:forest.config.url params.textDocument.uri in
2020 let@ tree = Option.bind forest.={uri} in
2121- let@ nodes = Option.bind Tree.(Option.map nodes @@ to_code tree) in
2121+ let@ nodes = Option.bind Tree.(Option.map Parsed.nodes @@ code tree) in
2222 let@ {value = str; _} =
2323 Option.bind @@ Analysis.addr_at ~position:params.position nodes
2424 in
+1-1
lib/language_server/Did_change.ml
···1919 let lsp_uri = params.textDocument.uri in
2020 let uri = URI.of_lsp_uri ~base:forest.config.url lsp_uri in
2121 let@ tree = Option.iter @~ forest.={uri} in
2222- match Tree.to_doc tree with
2222+ match Tree.document tree with
2323 | None -> assert false
2424 | Some doc ->
2525 let updated =
+2-2
lib/language_server/Document_link.ml
···2525 let Lsp_state.{forest; _} = Lsp_state.get () in
2626 let links =
2727 let uri = URI.of_lsp_uri ~base:config.url params.textDocument.uri in
2828- match Option.bind forest.={uri} Tree.to_code with
2828+ match Option.bind forest.={uri} Tree.code with
2929 | None -> []
3030 | Some tree -> (
3131- let@ Range.{range; value} = List.filter_map @~ Tree.nodes tree in
3131+ let@ Range.{range; value} = List.filter_map @~ Tree.Parsed.nodes tree in
3232 match value with
3333 | Code.Group (Squares, [{value = Text addr; _}])
3434 | Code.Group (Parens, [{value = Text addr; _}])
+3-3
lib/language_server/Document_symbols.ml
···1515 let ( let* ) = Option.bind
1616end
17171818-let compute (params : L.DocumentSymbolParams.t) :
1818+let compute ({textDocument = {uri; _}; _} : L.DocumentSymbolParams.t) :
1919 [> `DocumentSymbol of L.DocumentSymbol.t list] option =
2020- let uri = params.textDocument.uri in
2120 let Lsp_state.{forest; _} = Lsp_state.get () in
2222- match State.get_code forest @@ URI.of_lsp_uri ~base:forest.config.url uri with
2121+ let uri = URI.of_lsp_uri ~base:forest.config.url uri in
2222+ match State.get_code ~forest uri with
2323 | None -> assert false
2424 | Some {tree; _} ->
2525 let symbols : L.DocumentSymbol.t list =
+2-2
lib/language_server/Highlight.ml
···1616let compute (params : L.DocumentHighlightParams.t) =
1717 let Lsp_state.{forest; _} = Lsp_state.get () in
1818 let uri = URI.of_lsp_uri ~base:forest.config.url params.textDocument.uri in
1919- let@ tree = Option.map @~ State.get_code forest uri in
2020- let@ Range.{range; value} = List.filter_map @~ Tree.nodes tree in
1919+ let@ tree = Option.map @~ State.get_code ~forest uri in
2020+ let@ Range.{range; value} = List.filter_map @~ Tree.Parsed.nodes tree in
2121 let@ range = Option.map @~ range in
2222 let range = Lsp_shims.lsp_range_of_range range in
2323 let kind =
+3-8
lib/language_server/Hover.ml
···2626 Option.map
2727 @~
2828 match forest.={uri} with
2929- | None ->
3030- assert false
3131- (*error
3232- @@ Diagnostic.createf Error ~code:Internal_error "%a is not in the index"
3333- URI.pp uri
3434- *)
2929+ | None -> assert false
3530 | Some tree -> (
3636- let* nodes = Tree.(Option.map nodes @@ to_code tree) in
3131+ let* nodes = Option.map Tree.Parsed.nodes Tree.(code tree) in
3732 let* node = Analysis.node_at_code ~position nodes in
3833 let tree_under_cursor =
3934 let* {value = addr; _} = Analysis.extract_addr node in
···4338 match tree_under_cursor with
4439 | Some article -> Some (render article.mainmatter)
4540 | None ->
4646- let* doc = Tree.to_doc tree in
4141+ let* doc = Tree.document tree in
4742 let* search_term = Analysis.word_at ~position doc in
4843 let results =
4944 List.map snd @@ Index.search forest.search_index search_term
+1-1
lib/language_server/Inlay_hint.ml
···5151 let config = forest.config in
5252 let uri = URI.of_lsp_uri ~base:config.url params.textDocument.uri in
5353 let@ {tree = {nodes; _}; _} =
5454- Option.map @~ Option.bind forest.={uri} Tree.to_syn
5454+ Option.map @~ Option.bind forest.={uri} Tree.syn
5555 in
5656 extract_inlayable_hints ~config ~forest nodes
+2-3
lib/language_server/Publish.ml
···7788open Forester_core
99open Forester_compiler
1010+open State.Syntax
10111112open struct
1213 module L = Lsp.Types
···3940 let source =
4041 let Lsp_state.{forest; _} = Lsp_state.get () in
4142 let uri = URI.of_lsp_uri ~base:forest.config.url uri in
4242- let@ doc =
4343- Option.map @~ Option.bind (State.find_opt forest uri) Tree.to_doc
4444- in
4343+ let@ doc = Option.map @~ Option.bind forest.={uri} Tree.document in
4544 Lsp.Text_document.text doc
4645 in
4746 let message = Format.asprintf "%a" Diagnostic.Message.pp diag.message in
+2-2
lib/language_server/Semantic_tokens.ml
···271271 Result.to_option
272272 @@
273273 let@ tree = Result.map @~ Imports.resolve_uri_to_code ~forest uri in
274274- let tokens = tokens @@ Tree.nodes tree in
274274+ let tokens = tokens @@ Tree.Parsed.nodes tree in
275275 Format.(
276276 Eio.traceln "%a"
277277 (pp_print_list ~pp_sep:(fun out () -> fprintf out "; ") pp_token)
···287287 Result.to_option
288288 @@
289289 let@ tree = Result.map @~ Imports.resolve_uri_to_code ~forest uri in
290290- semantic_tokens_delta @@ Tree.nodes tree
290290+ semantic_tokens_delta @@ Tree.Parsed.nodes tree
291291292292let on_full_request (params : L.SemanticTokensParams.t) :
293293 L.SemanticTokens.t option =
+1-1
lib/language_server/Workspace_symbols.ml
···100100 @@
101101 let@ uri, item = List.concat_map @~ List.of_seq @@ State.to_seq forest in
102102 let@ {frontmatter; _} =
103103- List.concat_map @~ Option.to_list (Tree.to_article item)
103103+ List.concat_map @~ Option.to_list (Tree.article item)
104104 in
105105 let title = render @@ State.get_expanded_title frontmatter forest in
106106 let@ () =
+2-2
lib/search/Search_engine.ml
···6464 in
6565 let dev = true in
6666 let forest = Driver.batch_run ~env ~dev ~config ~config_path:"forest.toml" in
6767- let articles = List.of_seq @@ State.get_all_articles ~forest in
6868- let index = Index.create articles in
6767+ let articles = State.get_all_articles ~forest in
6868+ let index = Index.create List.(map snd articles) in
6969 let size = Obj.reachable_words @@ Obj.repr index in
7070 Format.printf "index size: %i@." size;
7171 let forest = {forest with search_index = index} in