using System.Collections.Generic; using System.Linq; using ICSharpCode.NRefactory.CSharp; namespace SharpieBinder { public static class Commenter { /// /// Inserts comments with "summary" tag over ast node. multiline. /// public static void InsertSummary(AstNode node, IEnumerable lines) { if (node?.Parent != null && lines != null) { var commentLinesList = lines.ToList(); if (commentLinesList.Count > 0) { node.Parent.InsertChildBefore(node, new Comment(" ", CommentType.Documentation), Roles.Comment); foreach (var comment in commentLinesList) { node.Parent.InsertChildBefore(node, new Comment(" " + comment.Trim(' '), CommentType.Documentation), Roles.Comment); } node.Parent.InsertChildBefore(node, new Comment(" ", CommentType.Documentation), Roles.Comment); } } } public static void InsertHeader(SyntaxTree syntaxTree) { var lines = new[] { "WARNING - AUTOGENERATED - DO NOT EDIT", "", "Generated using `sharpie urho`", "", syntaxTree.FileName, "", "Copyright 2015 Xamarin Inc. All rights reserved.\n", }; foreach (var line in lines) syntaxTree.Members.Add(new Comment(" " + line)); } } }