diff --git a/data/fixtures/scopes/r/functionCall.chain.scope b/data/fixtures/scopes/r/functionCall.chain.scope deleted file mode 100644 index c73434c70d..0000000000 --- a/data/fixtures/scopes/r/functionCall.chain.scope +++ /dev/null @@ -1,19 +0,0 @@ -foo().bar() ---- - -[#1 Content] = -[#1 Removal] = -[#1 Domain] = 0:0-0:5 - >-----< -0| foo().bar() - -[#1 Insertion delimiter] = " " - - -[#2 Content] = -[#2 Removal] = -[#2 Domain] = 0:0-0:11 - >-----------< -0| foo().bar() - -[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/r/functionCallee.chain.scope b/data/fixtures/scopes/r/functionCallee.chain.scope deleted file mode 100644 index b0b9872650..0000000000 --- a/data/fixtures/scopes/r/functionCallee.chain.scope +++ /dev/null @@ -1,25 +0,0 @@ -foo().bar() ---- - -[#1 Content] = -[#1 Removal] = 0:0-0:3 - >---< -0| foo().bar() - -[#1 Domain] = 0:0-0:5 - >-----< -0| foo().bar() - -[#1 Insertion delimiter] = " " - - -[#2 Content] = -[#2 Removal] = 0:0-0:9 - >---------< -0| foo().bar() - -[#2 Domain] = 0:0-0:11 - >-----------< -0| foo().bar() - -[#2 Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/r.ts b/packages/common/src/scopeSupportFacets/r.ts index 2fbf78b394..dfd6ed26a8 100644 --- a/packages/common/src/scopeSupportFacets/r.ts +++ b/packages/common/src/scopeSupportFacets/r.ts @@ -27,10 +27,8 @@ export const rScopeSupport: LanguageScopeSupportFacetMap = { functionCall: supported, "functionCall.method": supported, - "functionCall.chain": supported, functionCallee: supported, "functionCallee.method": supported, - "functionCallee.chain": supported, "comment.line": supported, ifStatement: supported, @@ -81,6 +79,10 @@ export const rScopeSupport: LanguageScopeSupportFacetMap = { // Not applicable + // Chained function calls + "functionCall.chain": notApplicable, + "functionCallee.chain": notApplicable, + "interior.cell": notApplicable, "interior.command": notApplicable, "interior.element": notApplicable, diff --git a/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts b/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts index 12e5559a0a..dc8594d6ef 100644 --- a/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts +++ b/packages/cursorless-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts @@ -263,59 +263,6 @@ class GrowToNamedSiblings extends QueryPredicateOperator { return true; } } -/** - * A predicate operator that modifies the range of the match to grow to leading siblings of the same type. - * - * The `leadingSeparator` argument specificies the separator each node except the first sibling will be separated by. - * - * ``` - * (#call-chain! @foo ".") - * ``` - */ -class CallChain extends QueryPredicateOperator { - name = "call-chain!" as const; - schema = z.union([z.tuple([q.node]), z.tuple([q.node, q.string])]); - - run(nodeInfo: MutableQueryCapture, leadingSeparator: string) { - const { node } = nodeInfo; - - if (node.parent == null) { - throw Error("Node has no parent"); - } - - const { children } = node.parent; - const nodeIndex = children.findIndex((n) => n.id === node.id); - - if (nodeIndex === -1) { - throw Error("Node not found in parent"); - } - - let start = children[nodeIndex]; - - for (let i = nodeIndex; i > -1; --i) { - const child = children[i]; - - if (child.type !== node.type) { - break; - } - - start = child; - - if (!child.text.startsWith(leadingSeparator)) { - break; - } - } - - if (start.id !== node.id) { - nodeInfo.range = makeRangeFromPositions( - start.startPosition, - children[nodeIndex].endPosition, - ); - } - - return true; - } -} /** * A predicate operator that modifies the range of the match by trimming trailing whitespace, @@ -494,7 +441,6 @@ export const queryPredicateOperators = [ new CharacterRange(), new ShrinkToMatch(), new GrowToNamedSiblings(), - new CallChain(), new AllowMultiple(), new InsertionDelimiter(), new SingleOrMultilineDelimiter(), diff --git a/queries/r.scm b/queries/r.scm index 0f37c81fe9..65c9155fa4 100644 --- a/queries/r.scm +++ b/queries/r.scm @@ -17,15 +17,6 @@ ;;! ^^^^^^^^^^^^^^ (if_statement) @ifStatement -;; ;;!! if (TRUE) { print("hello") } else { print("world") } -;; ;;! ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -;; (if_statement -;; "if" @branch.start -;; (_) @condition -;; consequence: (braced_expression) @branch.end -;; alternative: (braced_expression)? @branch.end -;; ) @branch.iteration - ;; named function ;;!! abc <- function(x){ } ;;! ^^^^^^^^^^^^^^^^^^^^^ @@ -136,14 +127,10 @@ ;;! ^^^^^ ;;! ^^^ ;;! ----- -( - (call - (identifier) @functionCallee.end - ) @functionCall @functionCallee.start.startOf @functionCallee.domain - (#call-chain! @functionCall ".") - (#call-chain! @functionCallee.start.startOf ".") - (#call-chain! @functionCallee.domain ".") -) + +(call + (identifier) @functionCallee +) @functionCall @functionCallee.domain ;; Technically lists and arrays are just calls to the function `list` or `c` ;;!! list(1, 2, 3)