Exemplo n.º 1
0
        public SteTryCatch TryCatch(ISyntaxTreeElement tryCode, ISyntaxTreeElement catchException, ISyntaxTreeElement catchCode)
        {
            var item = new SteTryCatch()
            {
                TryCode = tryCode
            };

            item.CatchItems.Add(
                new TccTryCatchItem()
            {
                CatchException = catchException, CatchCode = catchCode
            });

            return(item);
        }
Exemplo n.º 2
0
        public void Visit(SteTryCatch code)
        {
            TextComposer
            .AppendLineAtNewLine("try")
            .AppendLine("{")
            .IncreaseIndentation();

            code.TryCode.AcceptVisitor(this);

            TextComposer
            .DecreaseIndentation()
            .AppendLineAtNewLine("}");

            if (code.CatchItems.Count == 0)
            {
                TextComposer
                .AppendLineAtNewLine("catch")
                .AppendLine("{")
                .AppendLine("}");
            }
            else
            {
                foreach (var item in code.CatchItems)
                {
                    item.AcceptVisitor(this);
                }
            }

            if (code.FinallyCode != null)
            {
                TextComposer
                .AppendLineAtNewLine("finally")
                .AppendLine("{")
                .IncreaseIndentation();

                code.FinallyCode.AcceptVisitor(this);

                TextComposer
                .DecreaseIndentation()
                .AppendLineAtNewLine("}");
            }
        }