createLangiumDocument(e, t, r, i) {
    let s;
    if (r)
      s = {
        parseResult: e,
        uri: t,
        state: U.Parsed,
        references: [],
        textDocument: r
      };
    else {
      const a = this.createTextDocumentGetter(t, i);
      s = {
        parseResult: e,
        uri: t,
        state: U.Parsed,
        references: [],
        get textDocument() {
          return a();
        }
      };
    }
    return e.value.$document = s, s;
  }
Create a LangiumDocument from a given parse result.

A TextDocument is created on demand if it is not provided as argument here. Usually this
should not be necessary because the main purpose of the TextDocument is to convert between
text ranges and offsets, which is done solely in LSP request handling.

With the introduction of {@link update} below this method is supposed to be mainly called
during workspace initialization and on addition/recognition of new files, while changes in
existing documents are processed via {@link update}.