/// <summary> /// Our internal implementation of the bulb item which assumes it is running within a transaction /// </summary> /// <param name="solution">The currently open solution</param> /// <param name="textControl">The text control that is currently open</param> public void ExecuteEx(ISolution solution, ITextControl textControl) { // Get the comment block owner (ie the part of the declaration which will own the comment). IDocCommentBlockOwner docCommentBlockOwnerNode = XmlDocTemplateUtil.FindDocCommentOwner(_declaration as ITypeMemberDeclaration); // If we didn't get an owner then give up if (docCommentBlockOwnerNode == null) { return; } // We got one // Ask resharper to create the xml for us. int myCursorOffset; string text = XmlDocTemplateUtil.GetDocTemplate(docCommentBlockOwnerNode, out myCursorOffset); // Get a factory which can create elements in the C# docs CSharpElementFactory factory = CSharpElementFactory.GetInstance(docCommentBlockOwnerNode.GetPsiModule()); // Create the comment block IDocCommentBlock comment = factory.CreateDocCommentBlock(text); // And set the comment on the declaration. docCommentBlockOwnerNode.SetDocCommentBlock(comment); }
public static void AddXmlComment(this ITypeMemberDeclaration declaration, string text, CSharpElementFactory factory) { var docCommentBlockOwnerNode = XmlDocTemplateUtil.FindDocCommentOwner(declaration); if (docCommentBlockOwnerNode == null) { return; } var comment = factory.CreateDocCommentBlock(text); docCommentBlockOwnerNode.SetDocCommentBlock(comment); }