Class DOMProcessingInstructionFormatter
java.lang.Object
org.eclipse.lemminx.services.format.DOMProcessingInstructionFormatter
Formats processing instructions (
<?target ...?>).
Processing instructions like <?xml version="1.0"?> are formatted
with three operations:
- Indentation — when nested inside a parent element, the PI is
placed on a new line with proper indentation.
<a><?m2e?></a> → <a>\n <?m2e?>\n</a>
- Attribute spacing — extra spaces around
=and between attributes are removed.<?xml version = "1.0" encoding = "UTF-8"?> → <?xml version="1.0" encoding="UTF-8"?>
- Closing bracket — trailing space before
?>is removed.<?xml version="1.0" ?> → <?xml version="1.0"?>
- Author:
- Angelo ZERR
-
Constructor Summary
ConstructorsConstructorDescriptionDOMProcessingInstructionFormatter(XMLFormatterDocument formatterDocument, DOMAttributeFormatter attributeFormatter) Creates a new processing instruction formatter. -
Method Summary
Modifier and TypeMethodDescriptionvoidformatProcessingInstruction(DOMProcessingInstruction processingInstruction, XMLFormattingConstraints parentConstraints, List<org.eclipse.lsp4j.TextEdit> edits) Formats a processing instruction: indentation, attribute spacing, and closing bracket cleanup.
-
Constructor Details
-
DOMProcessingInstructionFormatter
public DOMProcessingInstructionFormatter(XMLFormatterDocument formatterDocument, DOMAttributeFormatter attributeFormatter) Creates a new processing instruction formatter.- Parameters:
formatterDocument- the parent formatter document (provides settings and edit helpers).attributeFormatter- the formatter for PI pseudo-attributes.
-
-
Method Details
-
formatProcessingInstruction
public void formatProcessingInstruction(DOMProcessingInstruction processingInstruction, XMLFormattingConstraints parentConstraints, List<org.eclipse.lsp4j.TextEdit> edits) Formats a processing instruction: indentation, attribute spacing, and closing bracket cleanup.- Parameters:
processingInstruction- the PI node to format.parentConstraints- the parent element's formatting constraints.edits- the list of text edits to populate.
-