File tree Expand file tree Collapse file tree
java/src/org/antlr/codebuff Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -722,7 +722,16 @@ public static int getChildIndex(ParseTree t) {
722722 // we know we have a parent now
723723 // check to see if we are 2nd or beyond element in a sibling list
724724 if ( t instanceof ParserRuleContext ) {
725- List <ParserRuleContext > siblings = ((ParserRuleContext )parent ).getRuleContexts (((ParserRuleContext )t ).getClass ());
725+ List <ParserRuleContext > siblings =
726+ ((ParserRuleContext )parent ).getRuleContexts (((ParserRuleContext )t ).getClass ());
727+ if ( siblings .size ()>1 && siblings .indexOf (t )>0 ) {
728+ return CHILD_INDEX_LIST_ELEMENT ;
729+ }
730+ }
731+ else {
732+ TerminalNode node = (TerminalNode )t ;
733+ List <TerminalNode > siblings =
734+ ((ParserRuleContext )parent ).getTokens (node .getSymbol ().getType ());
726735 if ( siblings .size ()>1 && siblings .indexOf (t )>0 ) {
727736 return CHILD_INDEX_LIST_ELEMENT ;
728737 }
You can’t perform that action at this time.
0 commit comments