java: public static PredictionContext fromRuleContext(ATN atn, RuleContext outerContext) {if ( outerContext==null ) outerContext = RuleContext.EMPTY;if ( outerContext.parent==null || outerContext==RuleContext.EMPTY ) {return PredictionContext.EMPTY;}PredictionContext parent = EMPTY;parent = PredictionContext.fromRuleContext(atn, outerContext.parent);ATNState state = atn.states.get(outerContext.invokingState);RuleTransition transition = (RuleTransition)state.transition(0);return SingletonPredictionContext.create(parent, transition.followState.stateNumber);}
C#: public static PredictionContext FromRuleContext(ATN atn, RuleContext outerContext){if (outerContext == null)outerContext = ParserRuleContext.EMPTY;if (outerContext.Parent == null || outerContext == ParserRuleContext.EMPTY)return PredictionContext.EMPTY;PredictionContext parent = PredictionContext.FromRuleContext(atn, outerContext.Parent);ATNState state = atn.states[outerContext.invokingState];RuleTransition transition = (RuleTransition)state.Transition(0);return parent.GetChild(transition.followState.stateNumber);}