Skip to content

Commit

Permalink
Update tree-sitter queries to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
meain authored Apr 12, 2024
1 parent a19ab9d commit f24075f
Show file tree
Hide file tree
Showing 59 changed files with 3,640 additions and 1,246 deletions.
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

0 comments on commit f24075f

Please sign in to comment.