Module Cobol_lsp.Document

module ANALYSIS = Superbol_project.Analysis
module TYPES : sig ... end
include module type of struct include TYPES end
type document = TYPES.document = {
  1. project : Superbol_project__.Project.TYPES.project;
  2. textdoc : Lsp.Text_document.t;
  3. copybook : bool;
  4. artifacts : Cobol_parser.Outputs.artifacts;
  5. semtoks : Superbol_project.Semantic_tokens.t Stdlib.Lazy.t option;
  6. checked : checked_doc option;
  7. rewinder : rewinder option;
  8. recorder : Superbol_cache.Recorder.t option;
  9. parsing_diags : Cobol_parser.Diagnostics.ALL.t;
  10. typecking_diags : Cobol_typeck.Diagnostics.t;
}
and checked_doc = Cobol_typeck.Outputs.t
exception Unparseable of Lsp.Types.DocumentUri.t

Raised by Document.checked.

exception Copybook of Lsp.Types.DocumentUri.t
exception Internal_error of document * exn * Stdlib.Printexc.raw_backtrace

Raised by Document.load and Document.update; allows keeping consistent document contents.

type cached = TYPES.cached = {
  1. doc_cache_filename : string;
}

Persistent representation of LSP-specific data (for caching). The analysis results are cached separately, as a Superbol_project.Analysis.for_lsp, so that they can be shared with other front-ends.

type t = document
val uri : document -> Lsp__.Uri0.t
val language_id : document -> string
val analysis_overrides : language_id:string -> ANALYSIS.overrides

analysis_overrides ~language_id are the departures from their project's configuration with which documents with the given language identifier are to be analyzed.

val analysis_overrides_for : document -> ANALYSIS.overrides
val rewindable_parse : platform:Cobol_common.Platform.TYPES.platform -> document -> ((Cobol_ptree.compilation_group option, Cobol_common.Behaviors.eidetic) Cobol_parser__.Parser_outputs.output * (Cobol_ptree.compilation_group, Cobol_common.Behaviors.eidetic) Cobol_parser.rewinder) Cobol_common__Diagnostics_accumulator.MAKE(Cobol_parser__.Parser_diagnostics.ALL).TYPES.with_diags
val parse_and_analyze : document -> document
val reparse_and_analyze : ?position:Cobol_parser.position -> document -> document
val inspect_at : position:Lsp.Types.Position.t -> f:(Cobol_parser.inspectable_parser_state -> 'a) -> document -> 'a option

inspect_at ~position ~f doc passes to f the state that is reached by the parser at position in doc. Returns None on copybooks, or Some r for r the result of f.

val blank : project:Superbol_project__.Project.TYPES.project -> Lsp.Text_document.t -> document

Creates a record for a document that is not yet parsed or analyzed.

val load : project:Superbol_project__.Project.TYPES.project -> params:Cobol_lsp__.Lsp_types.params -> Lsp__.Types.DidOpenTextDocumentParams.t -> document
val unload : document -> unit
val first_change_pos : Lsp.Types.TextDocumentContentChangeEvent.t list -> Cobol_parser.position
val reload : document -> document
val update : document -> Lsp__.Types.TextDocumentContentChangeEvent.t list -> document
val checked : document -> checked_doc

Raises Unparseable in case the document cannot be parsed entierely, or Copybook in case the document is not a main program.

val diagnostics : document -> DIAGS.Set.t

Caching utilities

val to_cache : with_semantic_tokens:bool -> document -> ANALYSIS.for_lsp * Superbol_project.Semantic_tokens.t option * Superbol_cache.Types.witness list option * cached

to_cache ~with_semantic_tokens doc splits doc into its analysis results, its semantic tokens, the witnesses these were obtained against, and LSP-specific data. The witnesses are None on a document whose analysis was restored from cache rather than performed: there is then nothing to store it against, and the entries it was restored from are there already anyway.

Semantic tokens are only given if with_semantic_tokens holds (the client is then bound to ask for them anyway), and the witnesses are not None.

val of_cache : project:Superbol_project__.Project.TYPES.project -> params:Cobol_lsp__.Lsp_types.params -> doc:Lsp__.Types.DidOpenTextDocumentParams.t -> ?semtoks:Superbol_project.Semantic_tokens.t -> ANALYSIS.for_lsp -> cached option -> document

of_cache ~project ~params ~doc ?semtoks analysis cached rebuilds a document from the client's doc, its cached analysis analysis, and its cached semantic tokens semtoks, if any.

The caller has already established that the contents of doc are what analysis was recorded against: the contents take part in the key the entry is stored under. Everything else the analysis depended upon is checked by the cache, against the witnesses it was stored with.

Miscellaneous