Something went wrong. Try again.
ocaml
Something went wrong. Try again.
1.5 kB · 51 lines
OCaml
at pp-ast
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152(* * SPDX-FileCopyrightText: 2024 The Forester Project Contributors * SPDX-FileCopyrightText: 2026 The Forester Project Contributors * * SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later OR Apache-2.0 WITH LLVM-exception *)
open Forester_coreopen Forester_compiler
open struct module L = Lsp.Types module T = Typesend
let compute (params : L.DocumentHighlightParams.t) = let Lsp_state.{forest; _} = Lsp_state.get () in let uri = URI.of_lsp_uri ~base:forest.config.url params.textDocument.uri in let@ tree = Option.map @~ Forest.get_code ~forest uri in let@ Range.{range; value} = List.filter_map @~ Tree.Parsed.nodes tree in let range = Lsp_shims.lsp_range_of_range range in let kind = match value with | Code.Text _ | Code.Verbatim _ | Code.Group (_, _) | Code.Math (_, _) | Code.Ident _ | Code.Hash_ident _ | Code.Xml_ident (_, _) | Code.Subtree (_, _) | Code.Let (_, _, _) | Code.Open _ | Code.Scope _ | Code.Put (_, _) | Code.Default (_, _) | Code.Get _ | Code.Fun (_, _) | Code.Object _ | Code.Patch _ | Code.Call (_, _) | Code.Import (_, _) | Code.Def (_, _, _) | Code.Decl_xmlns (_, _) | Code.Alloc _ | Code.Namespace (_, _) | Code.Dx_sequent (_, _) | Code.Dx_query (_, _, _) | Code.Dx_prop (_, _) | Code.Dx_var _ | Code.Dx_const_content _ | Code.Dx_const_uri _ | Code.Comment _ | Code.Error _ -> None in Some (L.DocumentHighlight.create ~range ?kind ())