File tree Expand file tree Collapse file tree 2 files changed +15
-16
lines changed
packages/cursorless-engine/src/languages Expand file tree Collapse file tree 2 files changed +15
-16
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,7 @@ import type { SimpleScopeTypeType } from "@cursorless/common";
22import type { Node } from "web-tree-sitter" ;
33import type { NodeFinder , NodeMatcherAlternative } from "../typings/Types" ;
44import { 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" ;
126import { 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
8276const functionCallPattern = "~quoting_lit.list_lit!" ;
83- const functionCallFinder = patternFinder ( functionCallPattern ) ;
8477
8578const 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
10692export default createPatternMatchers ( nodeMatchers ) ;
Original file line number Diff line number Diff line change 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)
113125;; ! ^^^^
114126(
115127 (list_lit
128+ .
116129 value: (_) @_dummy
117130 .
118131 value: (_) @condition
You can’t perform that action at this time.
0 commit comments