Class XMLFormatterDocument

java.lang.Object
org.eclipse.lemminx.services.format.XMLFormatterDocument

public class XMLFormatterDocument extends Object
XML formatter which generates several text edit to remove, add, update spaces / indent.
Author:
Angelo ZERR
  • Constructor Details

  • Method Details

    • format

      public List<? extends org.eclipse.lsp4j.TextEdit> format() throws BadLocationException
      Returns a List containing multiple TextEdit, containing the newly formatted changes of an XML document.
      Returns:
      List containing multiple TextEdit of an XML document.
      Throws:
      BadLocationException
    • format

      public List<? extends org.eclipse.lsp4j.TextEdit> format(DOMDocument document, int start, int end)
    • format

      public void format(DOMNode child, XMLFormattingConstraints parentConstraints, int start, int end, List<org.eclipse.lsp4j.TextEdit> edits)
    • formatChildren

      public void formatChildren(DOMNode currentDOMNode, XMLFormattingConstraints parentConstraints, int start, int end, List<org.eclipse.lsp4j.TextEdit> edits)
    • formatAttributeValue

      public void formatAttributeValue(DOMAttr attr, XMLFormattingConstraints parentConstraints, List<org.eclipse.lsp4j.TextEdit> edits)
    • removeLeftSpaces

      public void removeLeftSpaces(int leftLimit, int to, List<org.eclipse.lsp4j.TextEdit> edits)
    • replaceLeftSpacesWithOneSpace

      public void replaceLeftSpacesWithOneSpace(int leftLimit, int to, List<org.eclipse.lsp4j.TextEdit> edits)
    • adjustOffsetWithLeftWhitespaces

      public int adjustOffsetWithLeftWhitespaces(int leftLimit, int to)
    • replaceLeftSpacesWithIndentation

      public int replaceLeftSpacesWithIndentation(int indentLevel, int leftLimit, int to, boolean addLineSeparator, List<org.eclipse.lsp4j.TextEdit> edits)
    • replaceLeftSpacesWithIndentationWithMultiNewLines

      public int replaceLeftSpacesWithIndentationWithMultiNewLines(int indentLevel, int leftLimit, int offset, int newLineCount, List<org.eclipse.lsp4j.TextEdit> edits)
    • replaceLeftSpacesWithIndentationWithOffsetSpaces

      public int replaceLeftSpacesWithIndentationWithOffsetSpaces(int indentSpace, int leftLimit, int to, boolean addLineSeparator, List<org.eclipse.lsp4j.TextEdit> edits)
    • replaceLeftSpacesWithIndentationPreservedNewLines

      public void replaceLeftSpacesWithIndentationPreservedNewLines(int spaceStart, int spaceEnd, int indentLevel, List<org.eclipse.lsp4j.TextEdit> edits)
    • getNormalizedLength

      public int getNormalizedLength(int from, int to)
    • getOffsetWithPreserveLineBreaks

      public int getOffsetWithPreserveLineBreaks(int from, int to, int tabSize, boolean isInsertSpaces)
    • getLineBreakOffset

      public int getLineBreakOffset(int startAttr, int start)
    • getFormatElementCategory

      public FormatElementCategory getFormatElementCategory(DOMElement element, XMLFormattingConstraints parentConstraints)
      Returns the format element category of the given DOM element.
      Parameters:
      element - the DOM element.
      parentConstraints - the parent constraints.
      Returns:
      the format element category of the given DOM element.
    • shouldCollapseEmptyElement

      public boolean shouldCollapseEmptyElement(DOMElement element, SharedSettings sharedSettings)
    • getExistingNewLineCount

      public static int getExistingNewLineCount(String text, int offset, String delimiter)
      Return the number of new lines in the whitespaces to the left of the given offset.
      Parameters:
      text - the xml text.
      offset - the offset to begin the count from.
      delimiter - the delimiter.
      Returns:
      the number of new lines in the whitespaces to the left of the given offset.
    • isMaxLineWidthSupported

      public boolean isMaxLineWidthSupported()
    • getMaxLineWidth

      public int getMaxLineWidth()
    • getLineAtOffset

      public int getLineAtOffset(int offset)