-
Notifications
You must be signed in to change notification settings - Fork 22
Add constants to outline view #60
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
Conversation
Closes #50
|
|
||
| (assignment | ||
| (((constant) @constant | ||
| (#match? @constant "^[A-Z\\d_]")) @name |
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.
🤔 Why match on digits and underscores here? They're valid inside the constant name, but not at the beginning.
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.
That was a bold copy-and-paste from highlights.scm, I shouldn't have done it that way. I also found another case where this query matches the incorrect node in an assignment::
Category = Kernel
Such code produces two constants in the outline panel:
I think we should target places where the code assigns values to constants only:
(assignment left: (constant) @name) @item
[Previous version](#60) captures constant assignments to constants: ```ruby Left = Right ``` In the snippet above, we capture both constants `Left` and `Right` but we need `Left` only. This commit improves the TS query to capture only the left side of the assignment. |Before|After| |----|----| |||
Hi, this pull request updates the Ruby extension to v0.5.6, which includes many goodies and fixes. You can find the full list of changes on the release page [here](https://github.com/zed-extensions/ruby/releases/tag/v0.5.6). I'm also copying it below for your convenience: ## What's Changed ``` 1. Remove default tasks.json by @vitallium in zed-extensions/ruby#36 2. Remove else from outdent triggers by @vitallium in zed-extensions/ruby#42 3. Add completion_query_characters by @smitbarmase in zed-extensions/ruby#49 4. Add minimal README by @andyw8 in zed-extensions/ruby#54 5. Specify ? and ! as word characters by @andyw8 in zed-extensions/ruby#58 6. Add some basic tasks by @andyw8 in zed-extensions/ruby#57 7. Add constants to outline view by @vitallium in zed-extensions/ruby#60 8. Capture constants with assignments only for outline panel by @vitallium in zed-extensions/ruby#61 9. Include singleton class in outline by @joeldrapper in zed-extensions/ruby#67 10. Fix missing Tailwind completions by @I-Info in zed-extensions/ruby#62 11. Fix visibility keywords in outline by @joeldrapper in zed-extensions/ruby#65 12. Include method modifiers in outline by @joeldrapper in zed-extensions/ruby#66 13. Improve Ruby outlines with support for macros by @joeldrapper in zed-extensions/ruby#70 14. Mark instance & class variables as "@variable.special" by @asok in zed-extensions/ruby#63 15. Add task to evaluate selected text as Ruby by @andyw8 in zed-extensions/ruby#73 ``` Thanks!
Hi, this pull request updates the Ruby extension to v0.5.6, which includes many goodies and fixes. You can find the full list of changes on the release page [here](https://github.com/zed-extensions/ruby/releases/tag/v0.5.6). I'm also copying it below for your convenience: ## What's Changed ``` 1. Remove default tasks.json by @vitallium in zed-extensions/ruby#36 2. Remove else from outdent triggers by @vitallium in zed-extensions/ruby#42 3. Add completion_query_characters by @smitbarmase in zed-extensions/ruby#49 4. Add minimal README by @andyw8 in zed-extensions/ruby#54 5. Specify ? and ! as word characters by @andyw8 in zed-extensions/ruby#58 6. Add some basic tasks by @andyw8 in zed-extensions/ruby#57 7. Add constants to outline view by @vitallium in zed-extensions/ruby#60 8. Capture constants with assignments only for outline panel by @vitallium in zed-extensions/ruby#61 9. Include singleton class in outline by @joeldrapper in zed-extensions/ruby#67 10. Fix missing Tailwind completions by @I-Info in zed-extensions/ruby#62 11. Fix visibility keywords in outline by @joeldrapper in zed-extensions/ruby#65 12. Include method modifiers in outline by @joeldrapper in zed-extensions/ruby#66 13. Improve Ruby outlines with support for macros by @joeldrapper in zed-extensions/ruby#70 14. Mark instance & class variables as "@variable.special" by @asok in zed-extensions/ruby#63 15. Add task to evaluate selected text as Ruby by @andyw8 in zed-extensions/ruby#73 ``` Thanks!

Description
Adds constants assignments to the symbols outline.
According to the Ruby specification almost everything is a constant:
The challenge is to show only the most necessary symbols in the symbols outline. Pulling all constants results in an output where class declarations are shown as well, and this is not what we want. The solution is to pull only assigned constants. We are fortunate here because, otherwise, the Ruby interpreter would produce an uninitialized constant error. Consider the following code:
Opening the symbols outline panel produces the following:
Closes #50