Skip to content

Commit 4b4981f

Browse files
Migrate function call
1 parent eeb5494 commit 4b4981f

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ import type { SimpleScopeTypeType } from "@cursorless/common";
22
import type { Node } from "web-tree-sitter";
33
import type { NodeFinder, NodeMatcherAlternative } from "../typings/Types";
44
import { patternFinder } from "../util/nodeFinders";
5-
import {
6-
cascadingMatcher,
7-
chainedMatcher,
8-
createPatternMatchers,
9-
matcher,
10-
patternMatcher,
11-
} from "../util/nodeMatchers";
5+
import { createPatternMatchers, matcher } from "../util/nodeMatchers";
126
import { getChildNodesForFieldName } from "../util/treeSitterUtils";
137

148
/**
@@ -80,7 +74,6 @@ const getValueNodes = (node: Node) => getChildNodesForFieldName(node, "value");
8074

8175
// A function call is a list literal which is not quoted
8276
const functionCallPattern = "~quoting_lit.list_lit!";
83-
const functionCallFinder = patternFinder(functionCallPattern);
8477

8578
const nodeMatchers: Partial<
8679
Record<SimpleScopeTypeType, NodeMatcherAlternative>
@@ -94,13 +87,6 @@ const nodeMatchers: Partial<
9487
nodeIndex !== 0 ? nodeIndex : -1,
9588
),
9689
),
97-
98-
functionCall: functionCallPattern,
99-
100-
functionCallee: chainedMatcher([
101-
functionCallFinder,
102-
(functionNode) => getValueNodes(functionNode)[0],
103-
]),
10490
};
10591

10692
export default createPatternMatchers(nodeMatchers);

queries/clojure.scm

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,36 @@
8080
close: "}" @collectionItem.iteration.end.startOf
8181
) @collectionItem.iteration.domain
8282

83+
;;!! (hello)
84+
;;! ^^^^^^^
85+
(
86+
(list_lit
87+
.
88+
value: (_) @functionCallee
89+
) @functionCall @functionCallee.domain
90+
;; A function call is a list literal which is not quoted
91+
(#not-parent-type? @functionCall quoting_lit)
92+
)
93+
8394
;;!! (defn foo [] 5)
8495
;;! ^^^^^^^^^^^^^^^
8596
;;! ^^^
8697
(
8798
(list_lit
99+
.
88100
value: (_) @_dummy
89101
.
90102
value: (_) @name @functionName
91103
) @namedFunction @name.domain @functionName.domain
92104
(#text? @_dummy defn defmacro)
93-
;; A function call is a list literal which is not quoted
94105
(#not-parent-type? @namedFunction quoting_lit)
95106
)
96107

97108
;;!! (fn [] 5)
98109
;;! ^^^^^^^^^
99110
(
100111
(list_lit
112+
.
101113
value: (_) @_dummy
102114
) @anonymousFunction
103115
(#text? @_dummy fn)
@@ -113,6 +125,7 @@
113125
;;! ^^^^
114126
(
115127
(list_lit
128+
.
116129
value: (_) @_dummy
117130
.
118131
value: (_) @condition

0 commit comments

Comments
 (0)