From 42cb19ef24fbfe93c0545ef99b927c2a6049bd48 Mon Sep 17 00:00:00 2001 From: sh0rez Date: Sun, 6 Oct 2019 22:38:37 +0200 Subject: [PATCH] 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 --- toolutils/BUILD.bazel | 12 ++++++++++++ toolutils/ast.go | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 toolutils/BUILD.bazel create mode 100644 toolutils/ast.go diff --git a/toolutils/BUILD.bazel b/toolutils/BUILD.bazel new file mode 100644 index 0000000..7c0a6a7 --- /dev/null +++ b/toolutils/BUILD.bazel @@ -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", + ], +) diff --git a/toolutils/ast.go b/toolutils/ast.go new file mode 100644 index 0000000..b791252 --- /dev/null +++ b/toolutils/ast.go @@ -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) +}