node_show_s_expression {treesitter}R Documentation

Pretty print a node's s-expression

Description

node_show_s_expression() prints a nicely formatted s-expression to the console. It powers the print methods of nodes and trees.

Usage

node_show_s_expression(
  x,
  ...,
  max_lines = NULL,
  show_anonymous = TRUE,
  show_locations = TRUE,
  show_parentheses = TRUE,
  dangling_parenthesis = TRUE,
  color_parentheses = TRUE,
  color_locations = TRUE
)

Arguments

x

⁠[tree_sitter_node]⁠

A node.

...

These dots are for future extensions and must be empty.

max_lines

⁠[double(1) / NULL]⁠

An optional maximum number of lines to print. If the maximum is hit, then ⁠<truncated>⁠ will be printed at the end.

show_anonymous

⁠[bool]⁠

Should anonymous nodes be shown? If FALSE, only named nodes are shown.

show_locations

⁠[bool]⁠

Should node locations be shown?

show_parentheses

⁠[bool]⁠

Should parentheses around each node be shown?

dangling_parenthesis

⁠[bool]⁠

Should the ⁠)⁠ parenthesis "dangle" on its own line? If FALSE, it is appended to the line containing the last child. This can be useful for conserving space.

color_parentheses

⁠[bool]⁠

Should parentheses be colored? Printing large s-expressions is faster if this is set to FALSE.

color_locations

⁠[bool]⁠

Should locations be colored? Printing large s-expressions is faster if this is set to FALSE.

Value

x invisibly.

Examples


language <- treesitter.r::language()
parser <- parser(language)

text <- "fn <- function(a, b = 2) { a + b + 2 }"
tree <- parser_parse(parser, text)
node <- tree_root_node(tree)

node_show_s_expression(node)

node_show_s_expression(node, max_lines = 5)

# This is more like a typical abstract syntax tree
node_show_s_expression(
  node,
  show_anonymous = FALSE,
  show_locations = FALSE,
  dangling_parenthesis = FALSE
)


[Package treesitter version 0.1.0 Index]