Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cursorless-dev/cursorless
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 38ee67014057e66e51d75ca674d9e2f786f9199c
Choose a base ref
..
head repository: cursorless-dev/cursorless
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 43690c8be4354f80a0516e75ba1cc5871f391ed3
Choose a head ref
Showing with 26 additions and 26 deletions.
  1. +26 −26 queries/javascript.function.scm
52 changes: 26 additions & 26 deletions queries/javascript.function.scm
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
;; Anonymous functions
[
;; function() {}
;;!! function() {}
(function
!name
)

;; function *() {}
;;!! function *() {}
(generator_function
!name
)

;; () => {}
;;!! () => {}
(arrow_function)
] @anonymousFunction

;; If we export an anonymous function as default, it semantically feels like a
;; named function.
(export_statement
[
;; export default function() {}
;;!! export default function() {}
(function
!name
)

;; export default function *() {}
;;!! export default function *() {}
(generator_function
!name
)

;; export default () => {}
;;!! export default () => {}
(arrow_function)
]
) @namedFunction

;; Named functions without export
(
[
;; function foo() {}
;;!! function foo() {}
(function_declaration
name: (_) @functionName
)

;; function *foo() {}
;;!! function *foo() {}
(generator_function_declaration
name: (_) @functionName
)

;; (let | const) foo = () => {}
;; (let | const) foo = function() {}
;; (let | const) foo = function *() {}
;;!! (let | const) foo = () => {}
;;!! (let | const) foo = function() {}
;;!! (let | const) foo = function *() {}
(lexical_declaration
(variable_declarator
name: (_) @functionName
@@ -64,9 +64,9 @@
)
)

;; var foo = () => {}
;; var foo = function() {}
;; var foo = function *() {}
;;!! var foo = () => {}
;;!! var foo = function() {}
;;!! var foo = function *() {}
;; Note that we can't merge this with the variable declaration above because
;; of https://github.com/tree-sitter/tree-sitter/issues/1442#issuecomment-1584628651
(variable_declaration
@@ -90,19 +90,19 @@
;; Exported named functions
(export_statement
[
;; export [default] function foo() {}
;;!! export [default] function foo() {}
(function_declaration
name: (_) @functionName
)

;; export [default] function *foo() {}
;;!! export [default] function *foo() {}
(generator_function_declaration
name: (_) @functionName
)

;; export [default] (let | const | var) foo = () => {}
;; export [default] (let | const | var) foo = function() {}
;; export [default] (let | const | var) foo = function *() {}
;;!! export [default] (let | const | var) foo = () => {}
;;!! export [default] (let | const | var) foo = function() {}
;;!! export [default] (let | const | var) foo = function *() {}
(_
(variable_declarator
name: (_) @functionName
@@ -125,25 +125,25 @@
;; We also don't handle function declarations that only exist in Javascript;
;; see javascript.scm.
[
;; (function foo() {})
;;!! (function foo() {})
(function
name: (_) @functionName
)

;; (function *foo() {})
;;!! (function *foo() {})
(generator_function
name: (_) @functionName
)

;; foo() {}
;; (in class bodies)
;;!! class Foo { foo() {} }
;;! ^^^^^^^^
(method_definition
name: (_) @functionName
)

;; foo = () => {};
;; foo = function() {};
;; foo = function *() {};
;;!! foo = () => {};
;;!! foo = function() {};
;;!! foo = function *() {};
(assignment_expression
left: (_) @functionName
right: [