Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds ParentAwareVisitor for implementation that needs to know all parent AST nodes (Visitee) #39

Closed
wants to merge 35 commits into from

Conversation

emicklei
Copy link
Owner

No description provided.


func (v *ParentAwareVisitor) pop() {
if len(v.Parents) == 0 {
log.Fatal("no parent to pop")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't very lib-like - most people don't use the log package, and this is an uncatchable os.Exit call.

This single line would prevent me from using all this code.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. actually this was debug code added to get a better hint at what went wrong when building it. I think it can be removed altogether.

// ParentAwareVisitor keeps track of all the parents of each AST node
// while visiting all the elements and options.
type ParentAwareVisitor struct {
Parents []Visitee
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to have LastParent Visitee which is nil if there is no parent, otherwise has the last element of the Parents list, checking if LastParent != nil is nicer than len(Parents) > 0 and then getting the last parent with Parents[len(Parents)-1]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, actually disregard potentially, if you have #38 it's fine.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking about dropping #38 in favour of this.

return &ParentAwareVisitor{delegate: delegate}
}

func (v *ParentAwareVisitor) push(parent Visitee) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i would put these at the bottom

emicklei and others added 22 commits January 2, 2018 22:13
moved formatter and all commands to proto-contrib package
* fix issue47 : inline comment for rpc without option or stat
@emicklei
Copy link
Owner Author

emicklei commented Mar 4, 2018

see #68 instead

@emicklei emicklei closed this Mar 4, 2018
@emicklei emicklei deleted the parentaware branch October 28, 2018 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants