Add walkDeps to context and module_ctx.
walkDeps performs a pre-order DFS (unlike visitDepsDepthFirst which is
a post-order DFS). The visit function takes in both a parent and child
node and returns a bool indicating if the child node should be
traversed.
diff --git a/module_ctx.go b/module_ctx.go
index 6254596..94db01e 100644
--- a/module_ctx.go
+++ b/module_ctx.go
@@ -133,6 +133,7 @@
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
VisitDepsDepthFirst(visit func(Module))
VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
+ WalkDeps(visit func(Module, Module) bool)
ModuleSubDir() string
@@ -251,6 +252,10 @@
m.context.visitDepsDepthFirstIf(m.module, pred, visit)
}
+func (m *moduleContext) WalkDeps(visit func(Module, Module) bool) {
+ m.context.walkDeps(m.module, visit)
+}
+
func (m *moduleContext) ModuleSubDir() string {
return m.module.variantName
}
@@ -382,6 +387,7 @@
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
VisitDepsDepthFirst(visit func(Module))
VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
+ WalkDeps(visit func(Module, Module) bool)
}
type BottomUpMutatorContext interface {
@@ -501,3 +507,7 @@
mctx.context.visitDepsDepthFirstIf(mctx.module, pred, visit)
}
+
+func (mctx *mutatorContext) WalkDeps(visit func(Module, Module) bool) {
+ mctx.context.walkDeps(mctx.module, visit)
+}