parent property

  1. @override
ParserRuleContext? get parent
inherited

Implementation

@override
ParserRuleContext? get parent {
  return super.parent as ParserRuleContext?;
}
  1. @override
set parent (covariant RuleContext? parent)
covariantinherited

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

Implementation

@override
// Work around for https://github.com/antlr/antlr4/issues/3248
// ignore: unnecessary_getters_setters
set parent(RuleContext? parent) {
  _parent = parent;
}