Skip to content

Commit

Permalink
feat(Scope): add get_visible (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia authored Oct 15, 2023
1 parent 907caa4 commit 719dac7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Scope.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ struct
let ns = Mod.modify ?context:context_modifier ~prefix:Emp modifier ns in
{ s with visible = Trie.union_subtree ~prefix:Emp (Mod.Perform.shadow context_visible) s.visible (path, ns) }

let get_visible () =
M.exclusively @@ fun () -> (S.get()).visible

let get_export () =
M.exclusively @@ fun () -> (S.get()).export

Expand Down
7 changes: 7 additions & 0 deletions src/ScopeSigs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ sig
@param context_modifier The context of modifier effects when applying the modifier [m].
@param context_export The context of modifier effects when merging the subtree into the export namespace. *)

val get_visible : unit -> (data, tag) Trie.t
(** [get_visible ()] returns the visible namespace of the current scope.
This is useful for obtaining all visible names for auto-completion. It can also be used for checking whether a shadowed definition is still visible under another name. (However, scanning the entire visible namespace is expensive and should probably be avoided.)
@since 5.2.0 *)

val get_export : unit -> (data, tag) Trie.t
(** [get_export ()] returns the export namespace of the current scope.
Expand Down

0 comments on commit 719dac7

Please sign in to comment.