-
Notifications
You must be signed in to change notification settings - Fork 172
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
Support Hover, Completion, Go to definition for Class Variables #2944
Open
rogancodes
wants to merge
11
commits into
Shopify:main
Choose a base branch
from
rogancodes:feature/add_hover_definition_completion_support_for_class_variables
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a53b2fe
Index class variables
rogancodes d7b3b31
support for class varaibles go to definition
rogancodes 37ba38e
Fixed failing class variable definition test
rogancodes 823ff6e
support for class variables hover
rogancodes c6583c0
support for class variables completion
rogancodes fd97ea1
provide hover, completion, go to definition for class variable based …
rogancodes f48298a
Set class variable owner to attached context in singleton scope durin…
rogancodes 80a7595
added support for type inference of class variables
rogancodes 28f2c68
added test cases for hover, definition, and completion of class varia…
rogancodes 358972d
changes as per review comment
rogancodes 6afa177
added a comment on declaration listener and renamed a completion test…
rogancodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1117,6 +1117,40 @@ def baz | |||||
end | ||||||
end | ||||||
|
||||||
def test_completion_for_inherited_class_variables | ||||||
source = <<~RUBY | ||||||
module Foo | ||||||
def set_variable | ||||||
@@bar = 9 | ||||||
end | ||||||
end | ||||||
|
||||||
class Parent | ||||||
def set_variable | ||||||
@@baz = 5 | ||||||
end | ||||||
end | ||||||
|
||||||
class Child < Parent | ||||||
include Foo | ||||||
|
||||||
def do_something | ||||||
@ | ||||||
end | ||||||
end | ||||||
RUBY | ||||||
|
||||||
with_server(source, stub_no_typechecker: true) do |server, uri| | ||||||
server.process_message(id: 1, method: "textDocument/completion", params: { | ||||||
textDocument: { uri: uri }, | ||||||
position: { line: 16, character: 5 }, | ||||||
}) | ||||||
|
||||||
result = server.pop_response.response | ||||||
assert_equal(["@@bar", "@@baz"], result.map(&:label)) | ||||||
end | ||||||
end | ||||||
|
||||||
def test_completion_for_class_variables_show_only_uniq_entries | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
source = <<~RUBY | ||||||
class Foo | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can narrow the type with a
grep
, so that even if someone passes a name that doesn't belong to a class variable, it still works.