-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathjavascript.scm
58 lines (53 loc) · 1.22 KB
/
javascript.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
;; We include javascript.jsx.scm because jsx scopes technically work in
;; javascript files even if they're not technically javascriptreact file type.
;; import javascript.jsx.scm
;; import javascript.core.scm
;; Define this here because the `field_definition` node type doesn't exist
;; in typescript.
(_
;;!! class Foo {
;;!! foo = () => {};
;;! ^^^^^^^^^^^^^^^
;;!! foo = function() {};
;;! ^^^^^^^^^^^^^^^^^^^^
;;!! foo = function *() {};
;;! ^^^^^^^^^^^^^^^^^^^^^^
;;!! }
(field_definition
property: (_) @functionName
value: [
(function_expression
!name
)
(generator_function
!name
)
(arrow_function)
]
) @namedFunction.start @functionName.domain.start
.
";"? @namedFunction.end @functionName.domain.end
)
(_
;;!! foo = ...;
;;! ^^^-------
(field_definition
property: (_) @name @value.leading.endOf
value: (_)? @value @name.trailing.startOf
) @_.domain.start
.
";"? @_.domain.end
)
;;!! foo(name) {}
;;! ^^^^
(formal_parameters
(identifier) @name
)
;;!! foo(value = 5) {}
;;! ^^^^^ ^
(formal_parameters
(assignment_pattern
left: (_) @name @value.leading.endOf
right: (_) @value
) @_.domain
)