Skip to content

Commit b3d09fc

Browse files
Migrate function
1 parent 9e89672 commit b3d09fc

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ import { q } from "./operatorArgumentSchemaTypes";
1515
class Text extends QueryPredicateOperator<Text> {
1616
name = "text?" as const;
1717
schema = z.tuple([q.node, q.string]).rest(q.string);
18-
run({ node, document, range }: MutableQueryCapture, ...texts: string[]) {
19-
const text = document.getText(range);
20-
return texts.includes(text);
18+
run({ document, range }: MutableQueryCapture, ...texts: string[]) {
19+
return texts.includes(document.getText(range));
2120
}
2221
}
2322

packages/cursorless-engine/src/languages/clojure.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,6 @@ const nodeMatchers: Partial<
130130
(functionNode) => getValueNodes(functionNode)[0],
131131
]),
132132

133-
namedFunction: matcher(functionFinder),
134-
135-
functionName: functionNameMatcher,
136-
137-
// FIXME: Handle `let` declarations, defs, etc
138-
name: functionNameMatcher,
139-
140133
anonymousFunction: cascadingMatcher(
141134
functionNameBasedMatcher("fn"),
142135
patternMatcher("anon_fn_lit"),

queries/clojure.scm

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,27 @@
8383
;;!! (if true "hello")
8484
;;! ^^^^^^^^^^^^^^^^^
8585
;;! ^^^^
86-
(list_lit
87-
value: (_) @_dummy
88-
.
89-
value: (_) @condition
90-
(#text? @_dummy "if" "if-let" "when" "when-let")
91-
) @ifStatement @condition.domain
86+
(
87+
(list_lit
88+
value: (_) @_dummy
89+
.
90+
value: (_) @condition
91+
(#text? @_dummy "if" "if-let" "when" "when-let")
92+
) @ifStatement @condition.domain
93+
;; A function call is a list literal which is not quoted
94+
(#not-parent-type? @ifStatement quoting_lit)
95+
)
96+
97+
;;!! (defn foo [] 5)
98+
;;! ^^^^^^^^^^^^^^^
99+
;;! ^^^
100+
(
101+
(list_lit
102+
value: (_) @_dummy
103+
.
104+
value: (_) @name @functionName
105+
(#text? @_dummy defn defmacro)
106+
) @namedFunction @name.domain @functionName.domain
107+
;; A function call is a list literal which is not quoted
108+
(#not-parent-type? @namedFunction quoting_lit)
109+
)

0 commit comments

Comments
 (0)