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

Improve Ruby TextObjects #4601

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 20 additions & 30 deletions runtime/queries/ruby/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
; Class
(class) @class.around

(class [(constant) (scope_resolution)] !superclass
(_)+ @class.inside)

(class [(constant) (scope_resolution)] (superclass)
(_)+ @class.inside)
; Class and Modules
(class
body: (_)? @class.inside) @class.around

(singleton_class
value: (_)
Expand All @@ -17,37 +12,32 @@
(#match? @class_const "Class")
(#match? @class_method "new")
(do_block (_)+ @class.inside)) @class.around

(module
body: (_)? @class.inside) @class.around

; Functions
(method) @function.around
; Functions and Blocks
(singleton_method
body: (_)? @function.inside) @function.around

(method (identifier) (method_parameters)
(_)+ @function.inside)

(do_block !parameters
(_)+ @function.inside)

(do_block (block_parameters)
(_)+ @function.inside)

(block (block_parameters)
(_)+ @function.inside)

(block !parameters
(_)+ @function.inside)

(method (identifier) !parameters
(_)+ @function.inside)
(method
body: (_)? @function.inside) @function.around

(do_block
body: (_)? @function.inside) @function.around

(block
body: (_)? @function.inside) @function.around

; Parameters
(method_parameters
(_) @parameter.inside)
(_) @parameter.inside) @parameter.around

(block_parameters
(_) @parameter.inside)
(_) @parameter.inside) @parameter.around

(lambda_parameters
(_) @parameter.inside)
(_) @parameter.inside) @parameter.around

; Comments
(comment) @comment.inside
Expand Down