feat(parser): export parser.Children (#327)

* feat(parser): export parser.Children

As parser was moved to internal/parser, it is not possible to import it into
external projects anymore.

However, parser.Children() is handy to use in static analysis tools, so it is
worth exporting. This does that by adding a stub package
`github.com/google/go-jsonnet/parser` that wraps the internal function.

Signed-off-by: sh0rez <me@shorez.de>
This commit is contained in:
sh0rez 2019-10-06 22:38:37 +02:00 committed by Stanisław Barzowski
parent 56da397819
commit 42cb19ef24
2 changed files with 24 additions and 0 deletions

12
toolutils/BUILD.bazel Normal file
View File

@ -0,0 +1,12 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["ast.go"],
importpath = "github.com/google/go-jsonnet/toolutils",
visibility = ["//visibility:public"],
deps = [
"//ast:go_default_library",
"//internal/parser:go_default_library",
],
)

12
toolutils/ast.go Normal file
View File

@ -0,0 +1,12 @@
// Package toolutils includes several utilities handy for use in code analysis tools
package toolutils
import (
"github.com/google/go-jsonnet/ast"
"github.com/google/go-jsonnet/internal/parser"
)
// Children returns all children of a node. It supports ASTs before and after desugaring.
func Children(node ast.Node) []ast.Node {
return parser.Children(node)
}