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

Update tree-sitter queries #102

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
103 changes: 66 additions & 37 deletions queries/apex/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,76 +1,105 @@
(class_declaration
body: (class_body) @class.inner) @class.outer
body: (class_body) @class.inner) @class.outer

(method_declaration) @function.outer

(method_declaration
body: (block . "{" . (_) @function.inner._start @function.inner._end (_)? @function.inner._end . "}"
))
body: (block
.
"{"
.
(_) @function.inner._start @function.inner._end
(_)? @function.inner._end
.
"}"
))

(constructor_declaration) @function.outer

(constructor_declaration
body: (constructor_body . "{" . (_) @function.inner._start @function.inner._end (_)? @function.inner._end . "}"
))
body: (constructor_body
.
"{"
.
(_) @function.inner._start @function.inner._end
(_)? @function.inner._end
.
"}"
))

(for_statement
body: (_)? @loop.inner) @loop.outer
body: (_)? @loop.inner) @loop.outer

(enhanced_for_statement
body: (_)? @loop.inner) @loop.outer
body: (_)? @loop.inner) @loop.outer

(while_statement
body: (_)? @loop.inner) @loop.outer
body: (_)? @loop.inner) @loop.outer

(do_statement
body: (_)? @loop.inner) @loop.outer
body: (_)? @loop.inner) @loop.outer

(if_statement
condition: (_ (parenthesized_expression) @conditional.inner) @conditional.outer)
condition: (_
(parenthesized_expression) @conditional.inner) @conditional.outer)

(if_statement
consequence: (_)? @conditional.inner
alternative: (_)? @conditional.inner
) @conditional.outer
consequence: (_)? @conditional.inner
alternative: (_)? @conditional.inner) @conditional.outer

(switch_expression
body: (_)? @conditional.inner) @conditional.outer
body: (_)? @conditional.inner) @conditional.outer

;; blocks
; blocks
(block) @block.outer


(method_invocation) @call.outer
(method_invocation
arguments: (argument_list . "(" . (_) @call.inner._start (_)? @call.inner._end . ")"
))

;; parameters
(method_invocation
arguments: (argument_list
.
"("
.
(_) @call.inner._start
(_)? @call.inner._end
.
")"
))

; parameters
(formal_parameters
"," @parameter.outer._start .
(formal_parameter) @parameter.inner @parameter.outer._end
)
"," @parameter.outer._start
.
(formal_parameter) @parameter.inner @parameter.outer._end
)

(formal_parameters
. (formal_parameter) @parameter.inner @parameter.outer._start
. ","? @parameter.outer._end
)
.
(formal_parameter) @parameter.inner @parameter.outer._start
.
","? @parameter.outer._end
)

(argument_list
"," @parameter.outer._start .
(_) @parameter.inner @parameter.outer._end
)
"," @parameter.outer._start
.
(_) @parameter.inner @parameter.outer._end
)

(argument_list
. (_) @parameter.inner @parameter.outer._start
. ","? @parameter.outer._end
)
.
(_) @parameter.inner @parameter.outer._start
.
","? @parameter.outer._end
)

[
(line_comment)
(block_comment)
(line_comment)
(block_comment)
] @comment.outer

;; assignment
; assignment
(variable_declarator
name: (identifier) @assignment.lhs
value: (_) @assignment.rhs) @assignment.inner @assignment.outer
name: (identifier) @assignment.lhs
value: (_) @assignment.rhs) @assignment.inner @assignment.outer

2 changes: 2 additions & 0 deletions queries/astro/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; inherits: html

31 changes: 23 additions & 8 deletions queries/bash/textobjects.scm
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
(function_definition) @function.outer

(function_definition
body: (compound_statement . "{" . (_) @function.inner._start @function.inner._end (_)? @function.inner._end . "}"
))
body: (compound_statement
.
"{"
.
(_) @function.inner._start @function.inner._end
(_)? @function.inner._end
.
"}"
))

(case_statement) @conditional.outer

(if_statement
(_) @conditional.inner ) @conditional.outer
(_) @conditional.inner) @conditional.outer

(for_statement
(_) @loop.inner ) @loop.outer
(_) @loop.inner) @loop.outer

(while_statement
(_) @loop.inner ) @loop.outer
(_) @loop.inner) @loop.outer

(comment) @comment.outer

(regex) @regex.inner

((word) @number.inner
(#match? @number.inner "^[0-9]+$"))
(#match? @number.inner "^[0-9]+$"))

(variable_assignment) @assignment.outer
(variable_assignment name: (_) @assignment.inner @assignment.lhs)
(variable_assignment value: (_) @assignment.inner @assignment.rhs)

(variable_assignment
name: (_) @assignment.inner @assignment.lhs)

(variable_assignment
value: (_) @assignment.inner @assignment.rhs)

(command
argument: (word) @parameter.inner)

Loading
Loading