This repository has been archived by the owner on May 30, 2024. It is now read-only.
Remove experimental variable guessing in Ruby grammar #962
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.
Motivation
The grammar file incorrectly assumes most top level method calls are variables.
There is a comment in the grammar labeling this as "experimental".
I don't agree with "any normal word in certain curcumstances that haven't already been scoped as something else are probably variables" because method calls fall under this. I'd rather we error on the side of not scoping something we don't know.
When the LSP is active it adds semantic highlighting tokens which properly discerns local variables from method calls. It is better to use this instead of the grammar to determine local variables.
See further discussion in Shopify/ruby-lsp#1573.
Implementation
I removed this experimental part of the grammar so it no longer scopes method calls as
variable.other.ruby
.Automated Tests
There are no automated tests for the grammar file.
Manual Tests
You can check this by opening a Ruby file, putting text cursor in a method call, and running the "Inspect Editor Tokens and Scopes" command. It should not show
variable.other.ruby
undertextmate scopes
section.