Skip to content

Commit

Permalink
fix(elixir): add functions with guard clauses and/or no params (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
alcolmenar authored Aug 2, 2024
1 parent 115e3f1 commit 414d4b4
Showing 1 changed file with 85 additions and 20 deletions.
105 changes: 85 additions & 20 deletions queries/elixir/textobjects.scm
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,29 @@
target: ((identifier) @_identifier
(#any-of? @_identifier "def" "defmacro" "defmacrop" "defn" "defnp" "defp"))
(arguments
(call
[
(arguments
(_) @parameter.inner
.
"," @_delimiter)
(arguments
((_) @parameter.inner) @_delimiter .)
]
(#make-range! "parameter.outer" @parameter.inner @_delimiter)))
[
(call
[
(arguments
(_) @parameter.inner
.
"," @_delimiter)
(arguments
((_) @parameter.inner) @_delimiter .)
]
(#make-range! "parameter.outer" @parameter.inner @_delimiter))
(binary_operator
left: (call
[
(arguments
(_) @parameter.inner
.
"," @_delimiter)
(arguments
((_) @parameter.inner) @_delimiter .)
]
(#make-range! "parameter.outer" @parameter.inner @_delimiter)))
])
[
(do_block
"do"
Expand All @@ -85,16 +98,68 @@
target: ((identifier) @_identifier
(#any-of? @_identifier "def" "defmacro" "defmacrop" "defn" "defnp" "defp"))
(arguments
(call
[
(arguments
(_) @parameter.inner
.
"," @_delimiter)
(arguments
((_) @parameter.inner) @_delimiter .)
]
(#make-range! "parameter.outer" @parameter.inner @_delimiter))
[
(identifier)
(binary_operator
(identifier))
])
[
(do_block
"do"
.
(_) @_do
(_) @_end
.
"end")
(do_block
"do"
.
((_) @_do) @_end
.
"end")
]
(#make-range! "function.inner" @_do @_end)) @function.outer

(call
target: ((identifier) @_identifier
(#any-of? @_identifier "def" "defmacro" "defmacrop" "defn" "defnp" "defp"))
(arguments
[
(call
[
(arguments
(_) @parameter.inner
.
"," @_delimiter)
(arguments
((_) @parameter.inner) @_delimiter .)
]
(#make-range! "parameter.outer" @parameter.inner @_delimiter))
(binary_operator
left: (call
[
(arguments
(_) @parameter.inner
.
"," @_delimiter)
(arguments
((_) @parameter.inner) @_delimiter .)
]
(#make-range! "parameter.outer" @parameter.inner @_delimiter)))
]
(keywords
(pair
value: (_) @function.inner)))) @function.outer

(call
target: ((identifier) @_identifier
(#any-of? @_identifier "def" "defmacro" "defmacrop" "defn" "defnp" "defp"))
(arguments
[
(identifier)
(binary_operator
(identifier))
]
(keywords
(pair
value: (_) @function.inner)))) @function.outer
Expand Down

0 comments on commit 414d4b4

Please sign in to comment.