예제 #1
0
        S IAstVisitor <T, S> .VisitSwitchSection(SwitchSection switchSection, T data)
        {
            var handler = SwitchSectionVisited;

            if (handler != null)
            {
                handler(switchSection, data);
            }
            return(VisitChildren(switchSection, data));
        }
        public override void VisitSwitchSection(SwitchSection switchSection)
        {
            if (policy.IndentSwitchBody)
            {
                curIndent.Push(IndentType.Block);
            }

            foreach (CaseLabel label in switchSection.CaseLabels)
            {
                FixStatementIndentation(label.StartLocation);
                label.AcceptVisitor(this);
            }
            if (policy.IndentCaseBody)
            {
                curIndent.Push(IndentType.Block);
            }

            foreach (var stmt in switchSection.Statements)
            {
                if (stmt is BreakStatement && !policy.IndentBreakStatements && policy.IndentCaseBody)
                {
                    curIndent.Pop();
                    FixStatementIndentation(stmt.StartLocation);
                    stmt.AcceptVisitor(this);
                    curIndent.Push(IndentType.Block);
                    continue;
                }
                FixStatementIndentation(stmt.StartLocation);
                stmt.AcceptVisitor(this);
            }
            if (policy.IndentCaseBody)
            {
                curIndent.Pop();
            }

            if (policy.IndentSwitchBody)
            {
                curIndent.Pop();
            }
        }
예제 #3
0
 void IAstVisitor.VisitSwitchSection(SwitchSection switchSection)
 {
     Visit(EnterSwitchSection, LeaveSwitchSection, switchSection);
 }
        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
        {
            SwitchSection o = other as SwitchSection;

            return(o != null && this.CaseLabels.DoMatch(o.CaseLabels, match) && this.Statements.DoMatch(o.Statements, match));
        }