-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Go target] Fix for #3926: Add accessors for tree navigation to interfaces in generated parser #3927
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
Conversation
82a2a59
to
edcead0
Compare
Hi @jimidle, I'd appreciate your review here |
I will look at this today. I notice one check does not pass though. We will need that to pass. On the face of it, this looks like the correct thing to generate |
Thanks, @jimidle. I saw that failure as well - it looks like infra flake to me. It passed on the next commit. |
Signed-off-by: Jeremiah Boyle <jeremiah.boyle@gmail.com>
Signed-off-by: Jeremiah Boyle <jeremiah.boyle@gmail.com>
edcead0
to
9b2137f
Compare
Hey @jimidle, I'd appreciate that review when you have a chance. Thank you! |
Looks wonderful. The generated code is exactly what we need, and mirrors what the other targets do. @parrt |
I can't tell if it's backward compatible...i don't wanna break code in google. ;) I'll wait for @jimidle to sign off on this but looks better. |
The only breaking scenario I can imagine is if user code is relying on implementing the parser-generated interfaces for some reason, which seems unlikely - but I'll defer to the experts! Thankya. |
@parrt We can merge this PR - it will not break anything as far as I can see. |
Thanks @jimidle ! |
@perezd this should help the visitor, if you have time to check. |
} | ||
|
||
/** Not used for output; just used to distinguish between decl types | ||
* to avoid dups. | ||
*/ | ||
public String getArgType() { return ""; }; // assume no args | ||
|
||
private boolean signature = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, it should be marked with final
.
} | ||
|
||
/** Not used for output; just used to distinguish between decl types | ||
* to avoid dups. | ||
*/ | ||
public String getArgType() { return ""; }; // assume no args | ||
|
||
private boolean signature = false; | ||
public boolean getSignature() { return signature; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use getter method if signature
is final.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call: #3947
What does this PR fix?
Discussion
This is an attempt to remove the need to always cast these interfaces to concrete types. I considered two options:
This PR implements option (2), as (1) would be a breaking change for existing applications. I believe (2) is backwards compatible.
The strategy here is to add a flag,
signature
, to each of theContextGetterDecl
subclasses so that each of their corresponding template definitions can conditionally generate a method signature (for the interface) versus the complete method declaration.The
getSignatureDecl()
functions on each of theContextGetterDecl
subclasses are pretty tedious... open to suggestions for a more elegant option...Grammar
abb
Before this change
Generated Go
Navigation in Go
After this change
Generated Go
Navigation in Go
Why is this PR important?
This change increases the usability of the Go parsers. Without this change, code littered with type assertions is difficult to read/maintain.