next_non_comment: Find the index of the next or previous non-comment in a parse...

View source: R/utils-navigate-nest.R

next_non_commentR Documentation

Find the index of the next or previous non-comment in a parse table.

Description

Find the index of the next or previous non-comment in a parse table.

Usage

next_non_comment(pd, pos)

previous_non_comment(pd, pos)

Arguments

pd

A parse table.

pos

The position of the token to start the search from.

See Also

Other third-party style guide helpers: pd_is, scope_normalize()

Examples

code <- "a <- # hi \n x %>% b()"
writeLines(code)
pd <- compute_parse_data_nested(code)
child <- pd$child[[1]]
previous_non_comment(child, 4L)
next_non_comment(child, 2L)

r-lib/styler documentation built on April 10, 2024, 4 a.m.