/// <summary> /// Attempts to run code cleanup on the specified markup document. /// </summary> /// <param name="document">The document for cleanup.</param> private void RunCodeCleanupMarkup(Document document) { var textDocument = document.GetTextDocument(); RunExternalFormatting(textDocument); if (!document.IsExternal()) { _usingStatementCleanupLogic.RemoveAndSortUsingStatements(textDocument); } // Perform file header cleanup. _fileHeaderLogic.UpdateFileHeader(textDocument); // Perform removal cleanup. _removeWhitespaceLogic.RemoveEOLWhitespace(textDocument); _removeWhitespaceLogic.RemoveBlankLinesAtTop(textDocument); _removeWhitespaceLogic.RemoveBlankLinesAtBottom(textDocument); _removeWhitespaceLogic.RemoveEOFTrailingNewLine(textDocument); _removeWhitespaceLogic.RemoveBlankLinesBeforeClosingTag(textDocument); _removeWhitespaceLogic.RemoveBlankSpacesBeforeClosingAngleBracket(textDocument); _removeWhitespaceLogic.RemoveMultipleConsecutiveBlankLines(textDocument); // Perform insertion cleanup. _insertWhitespaceLogic.InsertBlankSpaceBeforeSelfClosingAngleBracket(textDocument); _insertWhitespaceLogic.InsertEOFTrailingNewLine(textDocument); }
/// <summary> /// Attempts to run code cleanup on the specified markup document. /// </summary> /// <param name="document">The document for cleanup.</param> /// <param name="isAutoSave">A flag indicating if occurring due to auto-save.</param> private void RunCodeCleanupMarkup(Document document, bool isAutoSave) { var textDocument = document.GetTextDocument(); RunExternalFormatting(textDocument); // Perform removal cleanup. _removeWhitespaceLogic.RemoveEOLWhitespace(textDocument); _removeWhitespaceLogic.RemoveBlankLinesAtTop(textDocument); _removeWhitespaceLogic.RemoveBlankLinesAtBottom(textDocument); _removeWhitespaceLogic.RemoveEOFTrailingNewLine(textDocument); _removeWhitespaceLogic.RemoveBlankLinesBeforeClosingTag(textDocument); _removeWhitespaceLogic.RemoveBlankSpacesBeforeClosingAngleBracket(textDocument); _removeWhitespaceLogic.RemoveMultipleConsecutiveBlankLines(textDocument); // Perform insertion cleanup. _insertWhitespaceLogic.InsertBlankSpaceBeforeSelfClosingAngleBracket(textDocument); }