Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## devel

- `tags.scm` now tags function definitions with a string name as `@definition.function` (#147, @MichaelChirico).

- Binary exponents are now supported in hexadecimal constants (#159).

- `NULL` is now allowed as a function call argument name (#164).
Expand Down
12 changes: 12 additions & 0 deletions queries/tags.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
rhs: (function_definition)
) @definition.function

(binary_operator
lhs: (string) @name
operator: "<-"
rhs: (function_definition)
) @definition.function

(binary_operator
lhs: (string) @name
operator: "="
rhs: (function_definition)
) @definition.function

(call
function: (identifier) @name
) @reference.call
Expand Down
34 changes: 29 additions & 5 deletions test/tags/function-definitions.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
fn <- function() {
# <- definition.function
# <- definition.function
}

fn = function() {
# <- definition.function
# <- definition.function
}

fn <- function(a, b) {
# <- definition.function
# <- definition.function

bar <- function() {}
# ^ definition.function
# ^ definition.function
}

"fn" <- function() {
# <- definition.function
}

"fn" = function() {
# <- definition.function
}

'fn' <- function() {
# <- definition.function
}

'fn' = function() {
# <- definition.function
}

`fn` <- function() {
# <- definition.function
}

`fn` = function() {
# <- definition.function
}