Module Superbol_project

Type definitions

module TYPES : sig ... end
include module type of TYPES with type rootdir = TYPES.rootdir and type project = TYPES.project and type rootdir_fallback_policy = TYPES.rootdir_fallback_policy and 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 = TYPES.rootdir_fallback_policy =
  1. | Same_as_file_directory
  2. | Given_directory of string
type cache_storage_location =
  1. | No_cache_storage
  2. | Store_cache_in_relative_dir of {
    1. relative_dirname : string;
      (*

      Name of cache directory, relative to project root directory.

      *)
    }
  3. | Store_cache_in_shared_dir of {
    1. dirname : string;
    }
type t = project

Initializers

val rootdir_at : dirname:string -> rootdir

rootdir_at ~dirname initializes a project into an existing directory.

Raises Invalid_argument in case dirname is not the name of an existing directory.

val rootdir_for : filename:string -> layout:layout -> rootdir

rootdir_for ~filename ~layout locates the project directory for a given file name. This project directory is the closest parent directory of filename that contains a file with the name layout.project_config_filename.

When no such file is found, the behavior depends on the given fallback policy: if layout.rootdir_fallback_policy = Same_as_file_directory, the name of the directory that contains filename is chosen as root for the project; alternatively, if the fallback is Given_directory dirname, directory dirname is used instead.

for_ ~platform ~rootdir ~layout retrieves a project based on its root directory.

This may trigger reading project configuration files if the project was not yet loaded. The name of the project's configuration file is determined by the layout argument. The configuration files of its dialect are accessed through platform.

val with_default_config : rootdir:rootdir -> layout:layout -> t

with_default_config ~rootdir ~layout initializes a project structure with a default configuration.

Accessors

val rootdir : t -> rootdir
val copybook_lookup_config_for : filename:string -> t -> Cobol_common.Copybook.TYPES.lookup_config

copybook_lookup_config_for ~uri project constructs a copybook lookup configuration for a source file with name filename, in the given project.

val detect_copybook : platform:Cobol_common.Platform.TYPES.platform -> filename:string -> ?contents:string -> t -> bool

detect_copybook ~filename project indicates whether a document with the given filename should be treated as a copybook in project.

val decode_source : ?encoding:Cobol_common.Text_encoding.t -> t -> string -> string

decode_source ?encoding project contents decodes the contents of a source file of project read from disk, with encoding if given, or else with the source_encoding of its configuration (if any).

Cached representation

type cached
val to_cache : t -> cached

to_cache project constructs a cached representation for project.

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).

Project configuration

val config : t -> Superbol_project__.Project_config.TYPES.config
val save_config : ?verbose:bool -> t -> unit

save_config ~verbose project dumps the current configuration of project into a TOML file. Prints some informative message on stderr if verbose is set.

The name of the configuration file is determined via the layout argument given to (the first call to) for_ or of_cache with project's root directory.

val reload_config : platform:Cobol_common.Platform.TYPES.platform -> ?verbose:bool -> t -> bool Cobol_common.Diagnostics.TYPES.with_diags

reload_config ~verbose project reloads the configuration of project from its associated TOML file. Returns true when the reloaded configuration does not match with the one before the call. Prints some informative message on stderr if verbose is set.

Collections

val have_same_rootdirs : t -> t -> bool
module SET : sig ... end
module MAP : sig ... end

Miscellaneous

val string_of_rootdir : rootdir -> string
val relative_path_for : filename:string -> t -> string
val absolute_path_for : filename:string -> t -> string
val work_dirname : layout:layout -> t -> string option

work_dirname ~layout project is the directory where working files of project (caches, etc.) are put according to layout, if any. Walks through the sources of the project should skip it.

module Config : sig ... end
module Layout : sig ... end
module Diagnostics : sig ... end
module Cache : sig ... end
module Walk : sig ... end
module Analysis : sig ... end

Analysis of individual documents, independently of any front-end.

module Cached_diagnostics : sig ... end

Diagnostics of documents, cached on their own so that they can be reported for documents that are not open, without restoring their (much larger) analysis for the LSP.

module Semantic_tokens : sig ... end

Semantic tokens of documents, cached apart from the analysis for the LSP they are computed from.

module Hardcoded_assumptions : sig ... end

Assumptions about the target machine that are hard-coded for now, and could become configurable later.