/// <summary> /// Analyzes the formatting of a given document and syntax tree. /// </summary> /// <param name="document">Document.</param> /// <param name="syntaxTree">Syntax tree.</param> /// <param name="token">The cancellation token.</param> public FormattingChanges AnalyzeFormatting(IDocument document, SyntaxTree syntaxTree, CancellationToken token = default(CancellationToken)) { if (document == null) { throw new ArgumentNullException("document"); } if (syntaxTree == null) { throw new ArgumentNullException("syntaxTree"); } var result = new FormattingChanges(document); var visitor = new FormattingVisitor(this, document, result, token); syntaxTree.AcceptVisitor(visitor); return(result); }
public FormattingVisitor(CSharpFormatter formatter, IDocument document, FormattingChanges changes, CancellationToken token) { if (formatter == null) { throw new ArgumentNullException("formatter"); } if (document == null) { throw new ArgumentNullException("document"); } if (changes == null) { throw new ArgumentNullException("changes"); } this.formatter = formatter; this.changes = changes; this.document = document; this.token = token; curIndent = new Indent(formatter.TextEditorOptions); }