package lsp

  1. Overview
  2. Docs
LSP protocol implementation in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

jsonrpc-1.4.0.tbz
sha256=fd138e6c4fcff32c6d15eb66cc9391b7e1183717a6d1a47c688c7f6d320a159f
sha512=567a73b3c10bb59c5a4d4e8291d1aeefdfd34438a95313fba8a485638294ca5fb8034334719631243c304d3328c27afa90dfd564fdb1e7390507a06db3a4ad03

doc/lsp.stdune/Stdune/Path/index.html

Module Stdune.PathSource

Representation of paths

The aim of this module is to provide a solid basis to reason about file and directory paths inside the Dune code base. What it is not is a complete API for paths management that handles all the aspects of file system paths. It simply exposes a high-level and portable API that covers the needs of Dune.

Model of the file system

Local paths

Dune sees the file system as two parts. The first part is composed of the source tree and the build directory. In this part, Dune doesn't know about symlinks and has a fully expanded view of the file system. This means that if the user has a symlink `src/foo` pointing to `bar`, then `src/foo/x` and `bar/x` are seen as two different paths.

A path in this world is called a local path and is simply a sequence of path components. A path component being a string other than "." or ".." and not containing the path separator character ('/').

Such a path can be rooted at the source tree root, the build directory or an unspecified root. All these paths are represented by values of type 'a Path.Local_gen.t where 'a denotes the root of the path.

External paths

The second part is the "external world". It is all the paths that live outside of the workspace and build directory. To be on the safe side Dune makes no assumption does nothing clever with these paths.

External paths are presented as Path.External.t values.contents

The Path.t type

The Path.t type represents all possible paths, i.e. both local and extenral paths.

Sourcemodule Local_gen : sig ... end

Relative path relative to the root tracked by the type system.

Sourcemodule Unspecified : sig ... end
Sourcemodule Local : sig ... end

Relative path with unspecified root.

Sourcemodule Source : sig ... end

In the source section of the current workspace.

Sourcemodule External : sig ... end
Sourcemodule Build : sig ... end
Sourcetype t = private
  1. | External of External.t
  2. | In_source_tree of Source.t
  3. | In_build_dir of Build.t
Sourceval to_string : t -> string
Sourceval of_string : string -> t
Sourceval parse_string_exn : loc:Stdune__.Loc0.t -> string -> t

a directory is smaller than its descendants

include Comparator.S with type t := t
Sourceval compare : t -> t -> Ordering.t
include Comparator.OPS with type t := t
Sourceval equal : t -> t -> bool
Sourceval (=) : t -> t -> bool
Sourceval (>=) : t -> t -> bool
Sourceval (>) : t -> t -> bool
Sourceval (<=) : t -> t -> bool
Sourceval (<) : t -> t -> bool
Sourceval (<>) : t -> t -> bool
Sourceval to_dyn : t -> Dyn.t
Sourceval extension : t -> string
Sourceval set_extension : t -> ext:string -> t

set_extension path ~ext replaces extension of path by ext

Sourceval split_extension : t -> t * string
Sourceval basename : t -> string
Sourceval basename_opt : t -> string option
Sourcemodule Set : sig ... end
Sourcemodule Map : Map.S with type key = t
Sourcemodule Table : Hashtbl.S with type key = t
Sourceval parent_exn : t -> t
Sourceval parent : t -> t option
Sourceval hash : t -> int
Sourceval to_string_maybe_quoted : t -> string

to_string_maybe_quoted t is maybe_quoted (to_string t)

Sourceval root : t
Sourceval external_ : External.t -> t
Sourceval is_root : t -> bool
Sourceval is_managed : t -> bool
Sourceval relative : ?error_loc:Stdune__.Loc0.t -> t -> string -> t
Sourceval of_filename_relative_to_initial_cwd : string -> t

Create an external path. If the argument is relative, assume it is relative to the initial directory dune was launched in.

Sourceval to_absolute_filename : t -> string

Convert a path to an absolute filename. Must be called after the workspace root has been set. root is the root directory of local paths

Sourceval reach : t -> from:t -> string

Reach a given path from a directory. For example, let p be a path to the file some/dir/file and d be a path to the directory some/another/dir. Then reach p ~from:d evaluates to ../../dir/file.

Sourceval reach_for_running : ?from:t -> t -> string

from defaults to Path.root

Sourceval descendant : t -> of_:t -> t option
Sourceval is_descendant : t -> of_:t -> bool
Sourceval append_local : t -> Local.t -> t
Sourceval append_source : t -> Source.t -> t
Sourceval extend_basename : t -> suffix:string -> t
Sourceval extract_build_context : t -> (string * Source.t) option

Extract the build context from a path. For instance, representing paths as strings:

 extract_build_context "_build/blah/foo/bar" = Some ("blah", "foo/bar") 

It doesn't work correctly (doesn't return a sensible source path) for build directories that are not build contexts, e.g. "_build/install" and "_build/.aliases".

Sourceval extract_build_context_exn : t -> string * Source.t
Sourceval extract_build_dir_first_component : t -> (string * Local.t) option
Sourceval extract_build_context_dir : t -> (t * Source.t) option

Same as extract_build_context but return the build context as a path:

  extract_build_context "_build/blah/foo/bar"
  = Some ("_build/blah", "foo/bar")
Sourceval extract_build_context_dir_maybe_sandboxed : t -> (t * Source.t) option
Sourceval extract_build_context_dir_exn : t -> t * Source.t
Sourceval drop_build_context : t -> Source.t option

Drop the "_build/blah" prefix

Sourceval drop_build_context_exn : t -> Source.t
Sourceval drop_optional_build_context : t -> t

Drop the "_build/blah" prefix if present, return t otherwise

Sourceval drop_optional_build_context_maybe_sandboxed : t -> t
Sourceval drop_optional_sandbox_root : t -> t
Sourceval drop_optional_build_context_src_exn : t -> Source.t

Drop the "_build/blah" prefix if present, return t if it's a source file, otherwise fail.

Sourceval explode : t -> string list option
Sourceval explode_exn : t -> string list
Sourceval build_dir : t

The build directory

Sourceval is_in_build_dir : t -> bool

is_in_build_dir t = is_descendant t ~of:build_dir

Sourceval is_in_source_tree : t -> bool

is_in_source_tree t = is_managed t && not (is_in_build_dir t)

Sourceval as_in_source_tree : t -> Source.t option
Sourceval as_in_source_tree_exn : t -> Source.t
Sourceval as_in_build_dir : t -> Build.t option
Sourceval as_in_build_dir_exn : t -> Build.t
Sourceval is_strict_descendant_of_build_dir : t -> bool

is_strict_descendant_of_build_dir t = is_in_build_dir t && t <> build_dir

Sourceval split_first_component : t -> (string * t) option

Split after the first component if t is local

Sourceval insert_after_build_dir_exn : t -> string -> t
Sourceval exists : t -> bool
Sourceval readdir_unsorted : t -> (string list, Unix.error) Result.t
Sourceval is_dir_sep : char -> bool
Sourceval is_directory : t -> bool
Sourceval is_directory_with_error : t -> (bool, string) Result.t
Sourceval is_file : t -> bool
Sourceval rmdir : t -> unit
Sourceval rm_rf : ?allow_external:bool -> t -> unit
Sourceval mkdir_p : ?perms:int -> t -> unit
Sourceval touch : ?create:bool -> t -> unit
Sourceval build_dir_exists : unit -> bool
Sourceval ensure_build_dir_exists : unit -> unit
Sourceval source : Source.t -> t
Sourceval build : Build.t -> t
Sourceval in_source : string -> t

paths guaranteed to be in the source directory

Sourceval of_local : Local.t -> t
Sourceval set_root : External.t -> unit

Set the workspace root. Can only be called once and the path must be absolute

Sourcemodule L : sig ... end
Sourceval local_part : t -> Local.t

Return the "local part" of a path. For local paths (in build directory or source tree), this returns the path itself. For external paths, it returns a path that is relative to the current directory. For example, the local part of /a/b is ./a/b.

Sourceval stat : t -> Unix.stats
Sourceval set_of_source_paths : Source.Set.t -> Set.t
Sourceval set_of_build_paths_list : Build.t list -> Set.t
Sourceval string_of_file_kind : Unix.file_kind -> string
Sourceval temp_dir : ?temp_dir:t -> ?mode:int -> string -> string -> t

temp_dir prefix suffix returns the name of a fresh temporary directory in the temporary directory. The base name of the temporary directory is formed by concatenating prefix, then a suitably chosen integer number, then suffix. The optional argument temp_dir indicates the temporary directory to use, defaulting to the current result of Filename.get_temp_dir_name. The temporary directory is created with permissions mode, defaulting to 0700. The directory is guaranteed to be different from any other directory that existed when temp_dir was called.

Sourceval rename : t -> t -> unit

Rename a file. rename oldpath newpath renames the file called oldpath, giving it newpath as its new name, moving it between directories if needed. If newpath already exists, its contents will be replaced with those of oldpath.

Sourceval chmod : mode:int -> ?stats:Unix.stats option -> ?op:[ `Add | `Remove | `Set ] -> t -> unit

Set permissions on the designed files. op is `Set by default, which sets the permissions exactly to mode, while `Add will add the given mode to the current permissions and `Remove remove them. path will be stat'd in the `Add and `Remove case to determine the current premission, unless the already computed stats are passed as stats to save a system call.

OCaml

Innovation. Community. Security.