Skip to content

Commit af34478

Browse files
Remove fixtures for R-lang function call chain (#3050)
1 parent 5d8e3dd commit af34478

File tree

5 files changed

+8
-117
lines changed

5 files changed

+8
-117
lines changed

data/fixtures/scopes/r/functionCall.chain.scope

Lines changed: 0 additions & 19 deletions
This file was deleted.

data/fixtures/scopes/r/functionCallee.chain.scope

Lines changed: 0 additions & 25 deletions
This file was deleted.

packages/common/src/scopeSupportFacets/r.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ export const rScopeSupport: LanguageScopeSupportFacetMap = {
2727

2828
functionCall: supported,
2929
"functionCall.method": supported,
30-
"functionCall.chain": supported,
3130
functionCallee: supported,
3231
"functionCallee.method": supported,
33-
"functionCallee.chain": supported,
3432

3533
"comment.line": supported,
3634
ifStatement: supported,
@@ -81,6 +79,10 @@ export const rScopeSupport: LanguageScopeSupportFacetMap = {
8179

8280
// Not applicable
8381

82+
// Chained function calls
83+
"functionCall.chain": notApplicable,
84+
"functionCallee.chain": notApplicable,
85+
8486
"interior.cell": notApplicable,
8587
"interior.command": notApplicable,
8688
"interior.element": notApplicable,

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

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -263,59 +263,6 @@ class GrowToNamedSiblings extends QueryPredicateOperator<GrowToNamedSiblings> {
263263
return true;
264264
}
265265
}
266-
/**
267-
* A predicate operator that modifies the range of the match to grow to leading siblings of the same type.
268-
*
269-
* The `leadingSeparator` argument specificies the separator each node except the first sibling will be separated by.
270-
*
271-
* ```
272-
* (#call-chain! @foo ".")
273-
* ```
274-
*/
275-
class CallChain extends QueryPredicateOperator<CallChain> {
276-
name = "call-chain!" as const;
277-
schema = z.union([z.tuple([q.node]), z.tuple([q.node, q.string])]);
278-
279-
run(nodeInfo: MutableQueryCapture, leadingSeparator: string) {
280-
const { node } = nodeInfo;
281-
282-
if (node.parent == null) {
283-
throw Error("Node has no parent");
284-
}
285-
286-
const { children } = node.parent;
287-
const nodeIndex = children.findIndex((n) => n.id === node.id);
288-
289-
if (nodeIndex === -1) {
290-
throw Error("Node not found in parent");
291-
}
292-
293-
let start = children[nodeIndex];
294-
295-
for (let i = nodeIndex; i > -1; --i) {
296-
const child = children[i];
297-
298-
if (child.type !== node.type) {
299-
break;
300-
}
301-
302-
start = child;
303-
304-
if (!child.text.startsWith(leadingSeparator)) {
305-
break;
306-
}
307-
}
308-
309-
if (start.id !== node.id) {
310-
nodeInfo.range = makeRangeFromPositions(
311-
start.startPosition,
312-
children[nodeIndex].endPosition,
313-
);
314-
}
315-
316-
return true;
317-
}
318-
}
319266

320267
/**
321268
* A predicate operator that modifies the range of the match by trimming trailing whitespace,
@@ -494,7 +441,6 @@ export const queryPredicateOperators = [
494441
new CharacterRange(),
495442
new ShrinkToMatch(),
496443
new GrowToNamedSiblings(),
497-
new CallChain(),
498444
new AllowMultiple(),
499445
new InsertionDelimiter(),
500446
new SingleOrMultilineDelimiter(),

queries/r.scm

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@
1717
;;! ^^^^^^^^^^^^^^
1818
(if_statement) @ifStatement
1919

20-
;; ;;!! if (TRUE) { print("hello") } else { print("world") }
21-
;; ;;! ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22-
;; (if_statement
23-
;; "if" @branch.start
24-
;; (_) @condition
25-
;; consequence: (braced_expression) @branch.end
26-
;; alternative: (braced_expression)? @branch.end
27-
;; ) @branch.iteration
28-
2920
;; named function
3021
;;!! abc <- function(x){ }
3122
;;! ^^^^^^^^^^^^^^^^^^^^^
@@ -136,14 +127,10 @@
136127
;;! ^^^^^
137128
;;! ^^^
138129
;;! -----
139-
(
140-
(call
141-
(identifier) @functionCallee.end
142-
) @functionCall @functionCallee.start.startOf @functionCallee.domain
143-
(#call-chain! @functionCall ".")
144-
(#call-chain! @functionCallee.start.startOf ".")
145-
(#call-chain! @functionCallee.domain ".")
146-
)
130+
131+
(call
132+
(identifier) @functionCallee
133+
) @functionCall @functionCallee.domain
147134

148135
;; Technically lists and arrays are just calls to the function `list` or `c`
149136
;;!! list(1, 2, 3)

0 commit comments

Comments
 (0)