Store the parsed tree to avoid unnecessary re-parsing #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reflecting on @paracycle's comment, I think delivering this refactor partially will make the transition easier in the future.
This PR changes our storage to store a new helper class
Item
(let me know if you have better naming suggestions), which keeps the parsed tree and source. For the time being, it must also keep the parser instance so that we can figure out absolute column positions. Once the limitation is addressed in syntax_tree, we can drop the parser and keep only tree and source.This will probably make it easier to refactor requests later when we can drop the parser. Additionally, it makes it easier to handle syntax errors in a single place in the code (currently the LSP breaks every time you start typing something).
After this, we will only re-parse files when we receive
didOpen
anddidChange
requests. For every other request, we just re-use the existing tree.