PrintTree returns a string representation of the syntax tree for the provided JavaScript source
(source []byte)
| 508 | // PrintTree returns a string representation of the syntax tree |
| 509 | // for the provided JavaScript source |
| 510 | func 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? |