Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for strings on the LHS of function definitions #147

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
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
MichaelChirico marked this conversation as resolved.
Show resolved Hide resolved
}

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
}