Class XMLFormatterDocument
java.lang.Object
org.eclipse.lemminx.services.format.XMLFormatterDocument
XML formatter which generates several text edit to remove, add,
update spaces / indent.
- Author:
- Angelo ZERR
-
Constructor Summary
ConstructorsConstructorDescriptionXMLFormatterDocument(DOMDocument xmlDocument, org.eclipse.lsp4j.Range range, SharedSettings sharedSettings, Collection<IFormatterParticipant> formatterParticipants) XML formatter document. -
Method Summary
Modifier and TypeMethodDescriptionintadjustOffsetWithLeftWhitespaces(int leftLimit, int to) List<? extends org.eclipse.lsp4j.TextEdit>format()Returns a List containing multiple TextEdit, containing the newly formatted changes of an XML document.List<? extends org.eclipse.lsp4j.TextEdit>format(DOMDocument document, int start, int end) voidformat(DOMNode child, XMLFormattingConstraints parentConstraints, int start, int end, List<org.eclipse.lsp4j.TextEdit> edits) voidformatAttributeValue(DOMAttr attr, XMLFormattingConstraints parentConstraints, List<org.eclipse.lsp4j.TextEdit> edits) voidformatChildren(DOMNode currentDOMNode, XMLFormattingConstraints parentConstraints, int start, int end, List<org.eclipse.lsp4j.TextEdit> edits) static intgetExistingNewLineCount(String text, int offset, String delimiter) Return the number of new lines in the whitespaces to the left of the given offset.getFormatElementCategory(DOMElement element, XMLFormattingConstraints parentConstraints) Returns the format element category of the given DOM element.intgetLineAtOffset(int offset) intgetLineBreakOffset(int startAttr, int start) intintgetNormalizedLength(int from, int to) intgetOffsetWithPreserveLineBreaks(int from, int to, int tabSize, boolean isInsertSpaces) booleanvoidremoveLeftSpaces(int leftLimit, int to, List<org.eclipse.lsp4j.TextEdit> edits) intreplaceLeftSpacesWithIndentation(int indentLevel, int leftLimit, int to, boolean addLineSeparator, List<org.eclipse.lsp4j.TextEdit> edits) voidreplaceLeftSpacesWithIndentationPreservedNewLines(int spaceStart, int spaceEnd, int indentLevel, List<org.eclipse.lsp4j.TextEdit> edits) intreplaceLeftSpacesWithIndentationWithMultiNewLines(int indentLevel, int leftLimit, int offset, int newLineCount, List<org.eclipse.lsp4j.TextEdit> edits) intreplaceLeftSpacesWithIndentationWithOffsetSpaces(int indentSpace, int leftLimit, int to, boolean addLineSeparator, List<org.eclipse.lsp4j.TextEdit> edits) voidreplaceLeftSpacesWithOneSpace(int leftLimit, int to, List<org.eclipse.lsp4j.TextEdit> edits) booleanshouldCollapseEmptyElement(DOMElement element, SharedSettings sharedSettings)
-
Constructor Details
-
Method Details
-
format
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
-
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
-
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.
-
getExistingNewLineCount
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)
-