示例#1
0
        private GoTo TraverseGoTo(List<LabelStatement> labels, GoToStatementSyntax gtss)
        {
            GoTo gotoStm = new GoTo();

            LabelSyntax lss = gtss.Label;

            string lblName = lss.LabelToken.ValueText;

            bool found = false;

            foreach(LabelStatement lblStm in labels){
                if (lblStm.Name == lblName)
                {
                    gotoStm.GoToLabel = lblStm;
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                gotoStm.GoToLabel = new LabelStatement() { Name = lblName };
            }

            return gotoStm;
        }
        private GoTo TraverseGoToStatements(GotoStatementSyntax gtss)
        {
            GoTo retGoTo = new GoTo();

            if (gtss.HasLeadingTrivia)
            {
                SetOuterComments(retGoTo, gtss.GetLeadingTrivia().ToFullString());
            }

            if (gtss.HasTrailingTrivia)
            {
                SetInnerComments(retGoTo, gtss.GetTrailingTrivia().ToFullString());
            }

            var labelStatements = from aLabelStatement in gtss.ChildNodes().OfType<LabeledStatementSyntax>() select aLabelStatement;

            foreach (LabeledStatementSyntax lss in labelStatements)
            {
                retGoTo.GoToLabel = TraverseLabelStatements(lss);
            }

            return retGoTo;
        }