示例#1
0
            public override Tuple <IParseTree, int> VisitOptionsSpec([NotNull] AbstractGrammarParser.OptionsSpecContext context)
            {
                // use previous option if any, otherwise use the block.
                // special handling for closing }
                if (targetElement == context.RBRACE())
                {
                    return(Tuple.Create <IParseTree, int>(context, 0));
                }

                int firstOptionIndex = -1;

                for (int i = 0; i < priorSiblings.Count; i++)
                {
                    IRuleNode sibling = priorSiblings[i] as IRuleNode;
                    if (sibling == null)
                    {
                        continue;
                    }

                    if (sibling.RuleContext.RuleIndex == GrammarParser.RULE_option)
                    {
                        firstOptionIndex = i;
                        break;
                    }
                }

                bool semi = ParseTrees.GetTerminalNodeType(targetElement) == GrammarParser.SEMI;

                for (int i = priorSiblings.Count - 2; i >= 0; i--)
                {
                    IRuleNode sibling = priorSiblings[i] as IRuleNode;
                    if (sibling == null)
                    {
                        continue;
                    }

                    RuleContext ruleContext = sibling.RuleContext;
                    if (ruleContext.RuleIndex == GrammarParser.RULE_option)
                    {
                        if (i == firstOptionIndex || ParseTrees.ElementStartsLine(sibling))
                        {
                            return(Tuple.Create <IParseTree, int>(sibling, semi ? _indentSize : 0));
                        }
                    }
                }

                return(Tuple.Create <IParseTree, int>(context, _indentSize));
            }
示例#2
0
 public override void EnterOptionsSpec([NotNull] AbstractGrammarParser.OptionsSpecContext context)
 {
     OutlineBlock(context, "options { ... }");
 }