public static IEnumerable <DocumentationCommentTriviaSyntax> FindNodes(SyntaxNode rootNode) { // Find the DocXML nodes. var syntaxWalker = new DocXmlFinder(rootNode.FullSpan); syntaxWalker.Visit(rootNode); return(syntaxWalker._nodes); }
public static IEnumerable <DocumentationCommentTriviaSyntax> FindNodes(SyntaxNode node, TextSpan span) { // Find the node that encloses the selection span. var enclosingNode = node.FindNode(span, getInnermostNodeForTie: true); // Find the DocXML nodes that overlap the selection span. var syntaxWalker = new DocXmlFinder(span); syntaxWalker.Visit(enclosingNode); return(syntaxWalker._nodes); }
/// <summary> /// Determines the changes necessary to format the XML documentation comments that overlap a /// specified span of a specified document. /// </summary> /// <param name="document">The document to format the XML documentation comments in.</param> /// <param name="span">The span to format in the document. XML documentation comments that /// overlap the span will be formatted.</param> /// <param name="options">The options that control formatting behavior. If /// <paramref name="options"/> is <see langword="null"/> then the options from the /// workspace are used.</param> /// <param name="cancellationToken">The cancellation token to observe.</param> /// <returns>The changes that will format the XML documentation comments.</returns> /// <exception cref="ArgumentNullException"><paramref name="document"/> is /// <see langword="null"/>.</exception> public static async Task <IList <TextChange> > FormatAsync(Document document, TextSpan span, OptionSet options = null, CancellationToken cancellationToken = default) { if (document == null) { throw new ArgumentNullException(nameof(document)); } if (options == null) { options = document.Project.Solution.Workspace.Options; } var formatter = new DocXmlFormatter(options); var rootNode = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); foreach (var node in DocXmlFinder.FindNodes(rootNode, span)) { formatter.Format(node, cancellationToken); } return(formatter._changes); }