(call) - Python
function calls
clojure
(call receiver? args?)Where:
Matching:
- regular calls, e.g.
func() - method calls, e.g.
obj.method() - calls with generator expressions, e.g.
func(x for x in items)
Behavior
- When a call uses a generator expression as its sole argument, you can match it with
(gen ...)in the args slot.
Examples
Find print calls that emit string messages.
clojure
(call (id "print") (arg 1 (str)))Selects in lines { 1 } but not in { 2, 3 }:
python
print("hello")
print(123)
log("hello")Locate sum calls that iterate over prices with a generator expression.
clojure
(call (id "sum") (gen (id price)))Selects in lines { 1 } but not in { 2, 3 }:
python
total = sum(price for price in prices)
total = sum(cost for cost in costs)
total = sum([price for price in prices])Find open calls that pass a binary mode.
clojure
(call (id "open") (arg 2 (str /b/)))Selects in lines { 1, 3 } but not in { 2 }:
python
open(path, "rb")
open(path, "r")
open(path, "wb")Arguments
receiver
- Identifier: shorthand for (id)
- Pattern: shorthand for (id)
- (:into)
- (:nearest)
- (:and)
- (:or)
- (:not)
- (:text)
- (:kind)
- (:replace)
- (:replace-in)
- (:capture)
- (:ref)
- (call)
- (fun)
- (gen)
- (id)
- (num)
- (str)