eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
669 stars 62 forks source link

Reparse documents only when content changed #1304

Closed msujew closed 7 months ago

msujew commented 7 months ago

When opening a workspace, we currently parse documents twice, even if their content hasn't changed.

  1. Documents are parsed the first time when the initializeWorkspace method of the WorkspaceManager is called.
  2. When a document has been opened in the editor, a textDocument/onDidChange notification is sent to the language server. This leads to a LangiumDocumentFactory#update call that tries to reparse the document.

This reparsing step can be quite expensive in case our documents are very large, as the parsing step cannot be interrupted, unlike every other builder step.

This change addresses point 2 by skipping the reparse in case the text document hasn't changed since the last parse. See tests on the effect (and potential side effects) of this change.