Module INTERNAL.Document

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. checked : checked_doc option;
  6. rewinder : rewinder option;
  7. parsing_diags : Cobol_parser.Diagnostics.ALL.t;
  8. 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;
  2. doc_cache_checksum : Stdlib.Digest.t;
  3. doc_cache_langid : string;
  4. doc_cache_version : int;
  5. doc_cache_pplog : Cobol_preproc.Trace.log;
  6. doc_cache_tokens : Cobol_parser.Outputs.tokens_with_locs;
  7. doc_cache_comments : Cobol_preproc.Text.comments;
  8. doc_cache_ignored : Cobol_common.Srcloc.lexloc list;
  9. doc_cache_checked : checked_doc option;
  10. doc_cache_parsing_diags : Cobol_parser.Diagnostics.ALL.t;
  11. doc_cache_typecking_diags : Cobol_typeck.Diagnostics.t;
}

Persistent representation (for caching)

type t = document
val uri : document -> Lsp__.Uri0.t
val language_id : document -> string
val rewindable_parse : document -> ((Cobol_ptree.compilation_group option, Cobol_common.Behaviors.eidetic) Cobol_parser__.Parser_outputs.output * (Cobol_ptree.compilation_group option, Cobol_common.Behaviors.eidetic) Cobol_parser__.Parser_outputs.output 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 position_encoding : [> `UTF8 ]
val load : project:Superbol_project__.Project.TYPES.project -> Lsp__.Types.DidOpenTextDocumentParams.t -> document
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 : document -> cached
val of_cache : project:Superbol_project__.Project.TYPES.project -> cached -> document

Raises Failure in case of bad checksum.

Miscellaneous