Module INTERNAL.Project

Type definitions

module TYPES : sig ... end
include module type of TYPES with type path = TYPES.path and type rootdir = TYPES.rootdir and type project = TYPES.project and type layout = TYPES.layout
include module type of Superbol_project.Config.TYPES with type path = TYPES.path
type path = TYPES.path =
  1. | RelativeToProjectRoot of string
  2. | RelativeToFileDir of string
type config = {
  1. mutable cobol_config : Cobol_config.t;
  2. mutable source_format : Cobol_config.source_format_spec;
  3. mutable libpath : path list;
  4. mutable libexts : string list;
  5. mutable indent_config : (string * int) list;
  6. toml_handle : Ezr_toml.toml_handle;
}
exception ERROR of Superbol_project__.Project_diagnostics.error
include module type of Superbol_project.TYPES with type rootdir = TYPES.rootdir with type project = TYPES.project with type layout = TYPES.layout
type rootdir = TYPES.rootdir
type project = TYPES.project = {
  1. rootdir : rootdir;
  2. config : Superbol_project__.Project_config.TYPES.config;
  3. config_filename : string;
}
type layout = TYPES.layout = {
  1. project_config_filename : string;
    (*

    Name of the TOML file that is to be found at the root of each project's directory tree.

    *)
  2. relative_work_dirname : string option;
    (*

    Relative name of a directory where the LSP should put its working files (caches, etc). No such storage is allowed when None.

    *)
  3. rootdir_fallback_policy : rootdir_fallback_policy;
    (*

    Policy to determine the root directory of projects based on individual filenames.

    *)
}
and rootdir_fallback_policy =
  1. | Same_as_file_directory
  2. | Given_directory of string
type t = project

Constructors & accessors

val for_ : rootdir:rootdir -> layout:layout -> t

for_ ~rootdir ~layout retrieves a project based on its root directory. This may trigger reading project configuration files if the project was not yet loaded.

May puplish notifications about the loading process directly via Lsp_io.send_diagnostics or Lsp_io.send_notification, and send diagnostics about loaded configuration files via Lsp_diagnostics.publish.

val in_existing_dir : string -> layout:layout -> t

in_existing_dir dirname ~layout retrieves a project after checking dirname actually refers to an exising directory that can serve as root for the project.

The same notes as for for_ apply, with the addition that Invalid_argument is raised in case dirname is not the name of an existing directory.

val rootdir_for : uri:Lsp.Uri.t -> layout:layout -> rootdir

rootdir_for ~uri ~layout locates the project directory (that contains a file with given name layout.project_config_filename) for a file at the given URI. The behavior when no such file is found is that of Superbol_project.rootdir_for.

val copybook_lookup_config_for : uri:Lsp.Uri.t -> t -> Cobol_common.Copybook.lookup_config

copybook_lookup_config_for ~uri project constructs a copybook lookup configuration for a source file at the given URI, in the given project.

val detect_copybook : uri:Lsp.Uri.t -> ?contents:string -> t -> bool

detect_copybook ~uri ?contents project indicates whether a document at the given URI for project should be treated as a copybook.

Cached representation

type cached
val to_cache : t -> cached

to_cache project constructs a cached representation for project.

val of_cache : rootdir:rootdir -> layout:layout -> cached -> t

of_cache ~rootdir ~layout cached_project attempts to load and return a cached project. Behaves like for_ ~rootdir ~layout in case of error (outdated or missing configuration file).

Collections

module SET : sig ... end
module MAP : Stdlib.Map.S with type key = t

Configuration management

Warning: functions below that return a Boolean actually perform some mutations on project's configurations. They return true if the configuration of the given project has changed.

val reload_project_config : t -> bool
val update_project_config : (string * Yojson.Safe.t) list -> t -> bool
val get_project_config : ?flat:bool -> t -> Yojson.Safe.t

Miscellaneous

val rootdir : t -> rootdir
val rooturi : t -> Lsp.Uri.t
val string_of_rootdir : rootdir -> string
val relative_path_for : uri:Lsp.Uri.t -> t -> string
val absolute_path_for : filename:string -> t -> string