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

Raise if the attached namespace is missing during linearization #2279

Merged

Conversation

vinistock
Copy link
Member

Motivation

Linearization for singletons currently fails with a no method error if we have never indexed the attached class.

This happens due to a shortcoming of the current implementation: we only index files once they are saved, rather than indexing them during modifications while computing all of the other features (using the dispatcher).

See the manual tests to understand what I mean.

Implementation

For now, we need to error properly if the attached class does not exist.

Automated Tests

Added a test.

Manual Tests

  1. Create a new file
  2. Enter the following code (do not save the file)
class Foo
  # cursor here
end
  1. Now, in the position of the cursor, add an @ symbol

The moment the @ symbol is added, we need to linearize ancestors for the singleton class of Foo to provide completion for class instance variables. However, because the file has not been saved, we never indexed Foo in the first place.

On main that fails and on this branch we simply don't show completion until the file is saved.

@vinistock vinistock added bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes labels Jul 9, 2024
@vinistock vinistock self-assigned this Jul 9, 2024
@vinistock vinistock requested a review from a team as a code owner July 9, 2024 20:49
@vinistock vinistock requested review from andyw8 and st0012 July 9, 2024 20:49
@vinistock vinistock merged commit 999ffb5 into main Jul 9, 2024
35 checks passed
@vinistock vinistock deleted the vs/raise_if_attached_class_missing_during_linearization branch July 9, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants