Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store the parsed tree to avoid unnecessary re-parsing #13

Merged
merged 2 commits into from Mar 24, 2022

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Mar 24, 2022

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 and didChange requests. For every other request, we just re-use the existing tree.

@vinistock vinistock requested a review from a team March 24, 2022 14:08
@vinistock vinistock self-assigned this Mar 24, 2022
lib/ruby/lsp/store.rb Outdated Show resolved Hide resolved
@vinistock vinistock merged commit 3653a90 into main Mar 24, 2022
@vinistock vinistock deleted the store_parsed_tree branch March 24, 2022 15:48
bjarosze pushed a commit to bjarosze/ruby-lsp that referenced this pull request Mar 8, 2024
…cha-9.2.2

Bump mocha from 9.2.1 to 9.2.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants