Skip to content

Commit 0e8eb7f

Browse files
Prefer #any-of? predicate over #match? with alternation (#80)
1 parent 02a6f7f commit 0e8eb7f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

queries/highlights.scm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
; * special
4949
(
5050
(identifier) @constant.builtin
51-
(#match? @constant.builtin "^(__MODULE__|__DIR__|__ENV__|__CALLER__|__STACKTRACE__)$")
51+
(#any-of? @constant.builtin "__MODULE__" "__DIR__" "__ENV__" "__CALLER__" "__STACKTRACE__")
5252
)
5353

5454
; Comment
@@ -122,12 +122,12 @@
122122
; * definition keyword
123123
(call
124124
target: (identifier) @keyword
125-
(#match? @keyword "^(def|defdelegate|defexception|defguard|defguardp|defimpl|defmacro|defmacrop|defmodule|defn|defnp|defoverridable|defp|defprotocol|defstruct)$"))
125+
(#any-of? @keyword "def" "defdelegate" "defexception" "defguard" "defguardp" "defimpl" "defmacro" "defmacrop" "defmodule" "defn" "defnp" "defoverridable" "defp" "defprotocol" "defstruct"))
126126

127127
; * kernel or special forms keyword
128128
(call
129129
target: (identifier) @keyword
130-
(#match? @keyword "^(alias|case|cond|for|if|import|quote|raise|receive|require|reraise|super|throw|try|unless|unquote|unquote_splicing|use|with)$"))
130+
(#any-of? @keyword "alias" "case" "cond" "for" "if" "import" "quote" "raise" "receive" "require" "reraise" "super" "throw" "try" "unless" "unquote" "unquote_splicing" "use" "with"))
131131

132132
; * just identifier in function definition
133133
(call
@@ -139,7 +139,7 @@
139139
left: (identifier) @function
140140
operator: "when")
141141
])
142-
(#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$"))
142+
(#any-of? @keyword "def" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defp"))
143143

144144
; * pipe into identifier (function call)
145145
(binary_operator
@@ -153,7 +153,7 @@
153153
(binary_operator
154154
operator: "|>"
155155
right: (identifier) @variable))
156-
(#match? @keyword "^(def|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defp)$"))
156+
(#any-of? @keyword "def" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defp"))
157157

158158
; * pipe into field without parentheses (function call)
159159
(binary_operator
@@ -208,7 +208,7 @@
208208
quoted_end: _ @comment.doc) @comment.doc
209209
(boolean) @comment.doc
210210
]))
211-
(#match? @comment.doc.__attribute__ "^(moduledoc|typedoc|doc)$"))
211+
(#any-of? @comment.doc.__attribute__ "moduledoc" "typedoc" "doc"))
212212

213213
; Module
214214

queries/injections.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
((sigil
33
(sigil_name) @_sigil_name
44
(quoted_content) @injection.content)
5-
(#match? @_sigil_name "^(H|LVN)$")
5+
(#any-of? @_sigil_name "H" "LVN")
66
(#set! injection.language "heex")
77
(#set! injection.combined))

queries/tags.scm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
(call
55
target: (identifier) @ignore
66
(arguments (alias) @name)
7-
(#match? @ignore "^(defmodule|defprotocol)$")) @definition.module
7+
(#any-of? @ignore "defmodule" "defprotocol")) @definition.module
88

99
; * functions/macros
1010
(call
@@ -20,14 +20,14 @@
2020
left: (call target: (identifier) @name)
2121
operator: "when")
2222
])
23-
(#match? @ignore "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$")) @definition.function
23+
(#any-of? @ignore "def" "defp" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp")) @definition.function
2424

2525
; References
2626

2727
; ignore calls to kernel/special-forms keywords
2828
(call
2929
target: (identifier) @ignore
30-
(#match? @ignore "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp|defmodule|defprotocol|defimpl|defstruct|defexception|defoverridable|alias|case|cond|else|for|if|import|quote|raise|receive|require|reraise|super|throw|try|unless|unquote|unquote_splicing|use|with)$"))
30+
(#any-of? @ignore "def" "defp" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defmodule" "defprotocol" "defimpl" "defstruct" "defexception" "defoverridable" "alias" "case" "cond" "else" "for" "if" "import" "quote" "raise" "receive" "require" "reraise" "super" "throw" "try" "unless" "unquote" "unquote_splicing" "use" "with"))
3131

3232
; ignore module attributes
3333
(unary_operator

0 commit comments

Comments
 (0)