public static void InsertComment (AstNode node, MonoDevelop.CSharp.Ast.Comment comment)
{
if (node.EndLocation < comment.StartLocation) {
node.AddChild (comment, AstNode.Roles.Comment);
return;
}
foreach (var child in node.Children) {
if (child.StartLocation < comment.StartLocation && comment.StartLocation < child.EndLocation) {
InsertComment (child, comment);
return;
}
if (comment.StartLocation < child.StartLocation) {
node.InsertChildBefore (child, comment, AstNode.Roles.Comment);
return;
}
}
node.AddChild (comment, AstNode.Roles.Comment);
}