/// <summary> /// Determines whether this instance is documented. /// </summary> /// <param name="invocationExpression"> /// The invocation expression. /// </param> /// <param name="exceptions"> /// The exceptions. /// </param> private static void RemoveDocumented(IInvocationExpression invocationExpression, List<string[]> exceptions) { ITypeMemberDeclaration typeMemberDeclaration = invocationExpression.GetContainingTypeMemberDeclaration(); if (typeMemberDeclaration == null) { return; } IDeclaredElement declaredElement = typeMemberDeclaration.DeclaredElement; if (declaredElement == null) { return; } var xmlNode = declaredElement.GetXMLDoc(false); if (xmlNode == null) { return; } var exceptionList = xmlNode.SelectNodes("exception"); if (exceptionList == null || exceptionList.Count == 0) { return; } foreach (XmlNode node in exceptionList) { var attribute = node.Attributes["cref"]; if (attribute == null) { continue; } var cref = attribute.Value; if (string.IsNullOrEmpty(cref)) { continue; } if (cref.StartsWith("T:")) { cref = cref.Substring(2); } foreach (var exception in exceptions) { if (exception[0] == cref) { exceptions.Remove(exception); break; } } } }
/// <summary> /// Executes this instance. /// </summary> /// <param name="invocationExpression"> /// The invocation expression. /// </param> private static void Execute(IInvocationExpression invocationExpression) { ITypeMemberDeclaration typeMemberDeclaration = invocationExpression.GetContainingTypeMemberDeclaration(); if (typeMemberDeclaration == null) { return; } var docCommentBlockOwnerNode = typeMemberDeclaration as IDocCommentBlockOwnerNode; if (docCommentBlockOwnerNode == null) { return; } var anchor = typeMemberDeclaration.ToTreeNode(); if (anchor == null) { return; } var exceptions = new List<string[]>(); GetExceptions(invocationExpression, exceptions); var text = new StringBuilder(); foreach (var exception in exceptions) { var t = exception[1]; t = Regex.Replace(t, "<paramref name=\"([^\"]*)\" />", "$1"); text.Append("\r\n <exception cref=\"" + exception[0] + "\">" + t + "</exception>"); } var indent = GetIndent(anchor); InsertSlashes(text, indent); var docCommentBlockNode = docCommentBlockOwnerNode.GetDocCommentBlockNode(); if (docCommentBlockNode != null) { var docCommentText = GetDocCommentText(docCommentBlockNode); text.Insert(0, docCommentText); } else { text.Remove(0, 1); } text.Append("\nvoid foo(){}"); var declaration = CSharpElementFactory.GetInstance(typeMemberDeclaration.GetPsiModule()).CreateTypeMemberDeclaration(text.ToString()); if (declaration == null) { return; } var node = SharedImplUtil.GetDocCommentBlockNode(declaration.ToTreeNode()); if (node == null) { return; } docCommentBlockOwnerNode.SetDocCommentBlockNode(node); }