(of)
constructor calls using new
(of callee args?)Where:
- callee: constructor being instantiated (the
Fooinnew Foo()) * - args: constructor arguments (use
(arg ...)to match by position or value) *
Matching:
- constructor calls, e.g.
new Foo() - constructor calls without arguments, e.g.
new Foo - member constructors, e.g.
new Api.Client()
Behavior
- Only matches
newexpressions, not plain calls likeFoo().
Examples
Find error constructions with legacy messages to standardize.
(of Error (arg 1 (str /deprecated/i)))Selects in lines { 1 } but not in { 2, 1 }:
throw new Error("Deprecated API")
throw new Error(err)
throw Error("Deprecated API")Locate URL constructions that still hardcode http.
(of URL (arg 1 (str /http:\/\//)))Selects in lines { 1 } but not in { 2, 3 }:
const url1 = new URL("http://example.com")
const url2 = new URL("https://example.com")
const url3 = new URL("/path", base)Audit usages of a specific client constructor before renaming.
(of (mem Client Api))Selects in lines { 1 } but not in { 2, 3 }:
const client1 = new Api.Client()
const client2 = new Api.Server()
const client3 = new Client()Arguments
callee
• Identifier: shorthand for (id)
• Pattern: shorthand for (id)
• (:kind) • (:ref) • (:text) • (arr) • (attr) • (bool) • (call) • (child) • (comp) • (export) • (fun) • (id) • (id+) • (import) • (jsx) • (mem) • (null) • (num) • (obj) • (of) • (prop) • (regex) • (regex+) • (str) • (str*) • (str+) • (tpl) • (tpl*) • (var) • (:into) • (:and) • (:or) • (:not) • (:replace) • (:capture)
args
• (arg)
• (:into) • (:and) • (:or) • (:not) • (:text) • (:kind) • (:replace) • (:capture)