MCPcopy
hub / github.com/BishopFox/jsluice / PrintTree

Function PrintTree

tree.go:510–518  ·  view source on GitHub ↗

PrintTree returns a string representation of the syntax tree for the provided JavaScript source

(source []byte)

Source from the content-addressed store, hash-verified

508// PrintTree returns a string representation of the syntax tree
509// for the provided JavaScript source
510func PrintTree(source []byte) string {
511 parser := sitter.NewParser()
512 parser.SetLanguage(javascript.GetLanguage())
513
514 tree := parser.Parse(nil, source)
515 root := tree.RootNode()
516
517 return getTree(root, source)
518}
519
520// getTree does the actual heavy lifting and recursion for PrintTree
521// TODO: provide a way to print the tree as a JSON object?

Callers 1

printTreeFunction · 0.92

Calls 2

getTreeFunction · 0.85
RootNodeMethod · 0.80

Tested by

no test coverage detected