public GetStatementBlock ( IEnumerable |
||
statements | IEnumerable |
|
return | BlockSyntax |
private IEnumerable <CatchClauseSyntax> BuildCatchSyntaxList(ITryStatement itemAsT) { var ret = new List <CatchClauseSyntax>(); foreach (var ctch in itemAsT.Catches) { var syntax = SyntaxFactory.CatchClause(); if (ctch.ExceptionType != null) { TypeSyntax typeSyntax = (TypeSyntax)(RDom.CSharp.GetSyntaxNode(ctch.ExceptionType)); var declaration = SyntaxFactory.CatchDeclaration(typeSyntax); if (ctch.Variable != null) { declaration = declaration.WithIdentifier(SyntaxFactory.Identifier(ctch.Variable.Name)); } declaration = BuildSyntaxHelpers.AttachWhitespace(declaration, ctch.Whitespace2Set, WhitespaceLookup); syntax = syntax.WithDeclaration(declaration); } // TODO: Add catch filter for 6.0 // TODO: Empty statement would return empty brackets here? var block = BuildSyntaxWorker.GetStatementBlock(ctch.Statements); block = BuildSyntaxHelpers.AttachWhitespace(block, ctch.Whitespace2Set, WhitespaceLookup); syntax = syntax.WithBlock(block); syntax = BuildSyntaxHelpers.AttachWhitespace(syntax, ctch.Whitespace2Set, WhitespaceLookup); ret.Add(syntax); } return(ret); }
public override IEnumerable <SyntaxNode> BuildSyntax(IDom item) { var itemAsT = item as IBlockStatement; var block = BuildSyntaxWorker.GetStatementBlock(itemAsT.Statements); var node = SyntaxFactory.Block(SyntaxFactory.List(block.Statements)); node = BuildSyntaxHelpers.AttachWhitespace(node, itemAsT.Whitespace2Set, WhitespaceLookup); return(node.PrepareForBuildSyntaxOutput(item, OutputContext)); }
private FinallyClauseSyntax BuildFinallySyntax(ITryStatement itemAsT) { var fnally = itemAsT.Finally; // TODO: Empty statement would return empty brackets here? var block = BuildSyntaxWorker.GetStatementBlock(fnally.Statements); block = BuildSyntaxHelpers.AttachWhitespace(block, fnally.Whitespace2Set, WhitespaceLookup); var syntax = SyntaxFactory.FinallyClause(block); syntax = BuildSyntaxHelpers.AttachWhitespace(syntax, fnally.Whitespace2Set, WhitespaceLookup); return(syntax); }
public override IEnumerable <SyntaxNode> BuildSyntax(IDom item) { var itemAsT = item as ITryStatement; var node = SyntaxFactory.TryStatement(); var catches = BuildCatchSyntaxList(itemAsT); var fnally = BuildFinallySyntax(itemAsT); var block = BuildSyntaxWorker.GetStatementBlock(itemAsT.Statements); block = BuildSyntaxHelpers.AttachWhitespace(block, itemAsT.Whitespace2Set, WhitespaceLookup); node = node.WithCatches(SyntaxFactory.List(catches)) .WithFinally(fnally) .WithBlock(block); node = BuildSyntaxHelpers.AttachWhitespace(node, itemAsT.Whitespace2Set, WhitespaceLookup); return(node.PrepareForBuildSyntaxOutput(item, OutputContext)); }