forked from jasder/antlr
shift setParent up one level
This commit is contained in:
parent
ec428d1124
commit
39ba47554a
|
@ -163,6 +163,12 @@ public class RuleContext implements RuleNode {
|
|||
*/
|
||||
public void setAltNumber(int altNumber) { }
|
||||
|
||||
/** @since 4.7. {@see ParseTree#setParent} comment */
|
||||
@Override
|
||||
public void setParent(RuleContext parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParseTree getChild(int i) {
|
||||
return null;
|
||||
|
|
|
@ -24,6 +24,24 @@ public interface ParseTree extends SyntaxTree {
|
|||
@Override
|
||||
ParseTree getChild(int i);
|
||||
|
||||
|
||||
/** Set the parent for this node.
|
||||
*
|
||||
* This is not backward compatible as it changes
|
||||
* the interface but no one was able to create custom
|
||||
* nodes anyway so I'm adding as it improves internal
|
||||
* code quality.
|
||||
*
|
||||
* One could argue for a restructuring of
|
||||
* the class/interface hierarchy so that
|
||||
* setParent, addChild are moved up to Tree
|
||||
* but that's a major change. So I'll do the
|
||||
* minimal change, which is to add this method.
|
||||
*
|
||||
* @since 4.7
|
||||
*/
|
||||
void setParent(RuleContext parent);
|
||||
|
||||
/** The {@link ParseTreeVisitor} needs a double dispatch method. */
|
||||
<T> T accept(ParseTreeVisitor<? extends T> visitor);
|
||||
|
||||
|
|
|
@ -11,15 +11,4 @@ import org.antlr.v4.runtime.Token;
|
|||
|
||||
public interface TerminalNode extends ParseTree {
|
||||
Token getSymbol();
|
||||
|
||||
/** Set the parent for this leaf node.
|
||||
*
|
||||
* Technically, this is not backward compatible as it changes
|
||||
* the interface but no one was able to create custom
|
||||
* TerminalNodes anyway so I'm adding as it improves internal
|
||||
* code quality.
|
||||
*
|
||||
* @since 4.7
|
||||
*/
|
||||
void setParent(RuleContext parent);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue