| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System.Collections.Generic;
- using System.Linq;
- using ICSharpCode.NRefactory.CSharp;
- namespace SharpieBinder
- {
- public static class Commenter
- {
- /// <summary>
- /// Inserts comments with "summary" tag over ast node. multiline.
- /// </summary>
- public static void InsertSummary(AstNode node, IEnumerable<string> lines)
- {
- if (node?.Parent != null && lines != null)
- {
- var commentLinesList = lines.ToList();
- if (commentLinesList.Count > 0)
- {
- node.Parent.InsertChildBefore(node, new Comment(" <summary>", 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(" </summary>", 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));
- }
- }
- }
|