From b8a7e686317b98a650a4e66fb5c8d0c3fdec0c55 Mon Sep 17 00:00:00 2001 From: Ewan Chou Date: Wed, 4 Nov 2015 17:59:12 +0800 Subject: [PATCH] ast: add comments about implementation rule on Accept method. --- ast/ast.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ast/ast.go b/ast/ast.go index 6b699d796e..a10d99dbd7 100644 --- a/ast/ast.go +++ b/ast/ast.go @@ -26,6 +26,11 @@ type Node interface { // Accept accepts Visitor to visit itself. // The returned node should replace original node. // ok returns false to stop visiting. + // + // Implementation of this method should first call visitor.Enter, + // assign the returned node to its method receiver, if skipChildren returns true, + // children should be skipped. Otherwise, call its children in particular order that + // later elements depends on on former elements. Finally, return visitor.Leave. Accept(v Visitor) (node Node, ok bool) // Text returns the original text of the element. Text() string