-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add tags.scm queries * mark defimpl modules as references to the interface * mark modules as module references instead of calls * define protocol modules as modules, remove interface references
- Loading branch information
1 parent
94d6471
commit 1516959
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
; Definitions | ||
|
||
; * modules and protocols | ||
(call | ||
target: (identifier) @ignore | ||
(arguments (alias) @name) | ||
(#match? @ignore "^(defmodule|defprotocol)$")) @definition.module | ||
|
||
; * functions/macros | ||
(call | ||
target: (identifier) @ignore | ||
(arguments | ||
[ | ||
; zero-arity functions with no parentheses | ||
(identifier) @name | ||
; regular function clause | ||
(call target: (identifier) @name) | ||
; function clause with a guard clause | ||
(binary_operator | ||
left: (call target: (identifier) @name) | ||
operator: "when") | ||
]) | ||
(#match? @ignore "^(def|defp|defdelegate|defguard|defguardp|defmacro|defmacrop|defn|defnp)$")) @definition.function | ||
|
||
; References | ||
|
||
; ignore calls to kernel/special-forms keywords | ||
(call | ||
target: (identifier) @ignore | ||
(#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)$")) | ||
|
||
; ignore module attributes | ||
(unary_operator | ||
operator: "@" | ||
operand: (call | ||
target: (identifier) @ignore)) | ||
|
||
; * function call | ||
(call | ||
target: [ | ||
; local | ||
(identifier) @name | ||
; remote | ||
(dot | ||
right: (identifier) @name) | ||
]) @reference.call | ||
|
||
; * pipe into function call | ||
(binary_operator | ||
operator: "|>" | ||
right: (identifier) @name) @reference.call | ||
|
||
; * modules | ||
(alias) @name @reference.module |