-
Notifications
You must be signed in to change notification settings - Fork 247
Migrate workspace symbol to use Rubydex #4019
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
Open
vinistock
wants to merge
1
commit into
03-03-migrate_go_to_definition_to_use_rubydex
Choose a base branch
from
03-19-migrate_workspace_symbol_to_rubydex
base: 03-03-migrate_go_to_definition_to_use_rubydex
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 all commits
Commits
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 hidden or 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 |
|---|---|---|
|
|
@@ -12,54 +12,32 @@ class WorkspaceSymbol < Request | |
| #: (GlobalState global_state, String? query) -> void | ||
| def initialize(global_state, query) | ||
| super() | ||
| @global_state = global_state | ||
| @query = query | ||
| @index = global_state.index #: RubyIndexer::Index | ||
| @graph = global_state.graph #: Rubydex::Graph | ||
| end | ||
|
|
||
| # @override | ||
| #: -> Array[Interface::WorkspaceSymbol] | ||
| def perform | ||
| fuzzy_search.filter_map do |entry| | ||
| kind = kind_for_entry(entry) | ||
| loc = entry.location | ||
| response = [] | ||
|
|
||
| # We use the namespace as the container name, but we also use the full name as the regular name. The reason we | ||
| # do this is to allow people to search for fully qualified names (e.g.: `Foo::Bar`). If we only included the | ||
| # short name `Bar`, then searching for `Foo::Bar` would not return any results | ||
| *container, _short_name = entry.name.split("::") | ||
| @graph.search(@query || "").each do |declaration| | ||
| name = declaration.name | ||
|
|
||
| Interface::WorkspaceSymbol.new( | ||
| name: entry.name, | ||
| container_name: container.join("::"), | ||
| kind: kind, | ||
| location: Interface::Location.new( | ||
| uri: entry.uri.to_s, | ||
| range: Interface::Range.new( | ||
| start: Interface::Position.new(line: loc.start_line - 1, character: loc.start_column), | ||
| end: Interface::Position.new(line: loc.end_line - 1, character: loc.end_column), | ||
| ), | ||
| ), | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| private | ||
| declaration.definitions.each do |definition| | ||
| location = definition.location | ||
| uri = URI(location.uri) | ||
| file_path = uri.full_path | ||
|
Member
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. Not blocking, but does it make sense to make this |
||
|
|
||
| #: -> Array[RubyIndexer::Entry] | ||
| def fuzzy_search | ||
| @index.fuzzy_search(@query) do |entry| | ||
| file_path = entry.uri.full_path | ||
| # We only show symbols declared in the workspace | ||
| in_dependencies = file_path && !not_in_dependencies?(file_path) | ||
| next if in_dependencies | ||
|
|
||
| # We only show symbols declared in the workspace | ||
| in_dependencies = file_path && !not_in_dependencies?(file_path) | ||
| next if in_dependencies | ||
|
|
||
| # We should never show private symbols when searching the entire workspace | ||
| next if entry.private? | ||
|
|
||
| true | ||
| response << definition.to_lsp_workspace_symbol(name) | ||
| end | ||
| end | ||
|
|
||
| response | ||
| end | ||
| end | ||
| end | ||
|
|
||
This file contains hidden or 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 hidden or 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.
Since we don't need
@global_stateanymore, does it make sense to just passgraphin?