Package org.eclipse.lemminx.settings
Class XMLFormattingProfile
java.lang.Object
org.eclipse.lemminx.settings.PathPatternMatcher
org.eclipse.lemminx.settings.DocumentMatcher
org.eclipse.lemminx.settings.XMLFormattingProfile
A formatting profile that overrides global
xml.format.* settings for
documents matching specific criteria. Extends DocumentMatcher so that
matching criteria (pattern, namespaceURI, publicId, systemId, grammarURI) and
format override fields all live at the same JSON level (flat structure).
Profiles are declared in xml.format.profiles and evaluated in order;
the first matching profile wins. All format fields use boxed types
(Boolean, Integer, String) so that null means
"not specified — use the global default".
Matching criteria (all optional, combined with AND)
pattern— glob on the file URI (inherited fromPathPatternMatcher).namespaceURI— root element namespace URI (inherited fromDocumentMatcher).rootElement— root element local name (inherited fromDocumentMatcher).publicId— DOCTYPE public identifier (inherited fromDocumentMatcher).systemId— DOCTYPE system identifier (inherited fromDocumentMatcher).grammarURI— resolved grammar URI from any source: DOCTYPE systemId,<?xml-model?>href, file association, or XML catalog (inherited fromDocumentMatcher).
Use case: DocBook formatting
"xml.format.profiles": [{
"namespaceURI": ["http://docbook.org/ns/docbook*"],
"mixedContent": "preserve"
}]
Use case: MyBatis via DOCTYPE
"xml.format.profiles": [{
"publicId": ["-//mybatis.org//DTD Mapper 3.0//EN"],
"splitAttributes": "preserve"
}]
Use case: POM files by path
"xml.format.profiles": [{
"pattern": "**/pom.xml",
"splitAttributes": "force-expand-multiline"
}]
Use case: AND combination — DocBook files in a specific folder
"xml.format.profiles": [{
"pattern": "**/docs/**/*.xml",
"namespaceURI": ["http://docbook.org/ns/docbook*"],
"mixedContent": "preserve"
}]
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyTo(XMLFormattingOptions target) Applies all non-null format override fields from this profile onto the given target formatting options.voidsetBlockElements(List<String> blockElements) voidsetClosingBracketNewLine(Boolean closingBracketNewLine) voidsetEmptyElements(String emptyElements) voidsetEnabled(Boolean enabled) voidsetEnforceQuoteStyle(String enforceQuoteStyle) voidsetFormatComments(Boolean formatComments) voidsetGrammarAwareFormatting(Boolean grammarAwareFormatting) voidsetJoinCDATALines(Boolean joinCDATALines) voidsetJoinCommentLines(Boolean joinCommentLines) voidsetJoinContentLines(Boolean joinContentLines) voidvoidsetMaxLineWidth(Integer maxLineWidth) voidsetMixedContent(String mixedContent) voidsetPreserveAttributeLineBreaks(Boolean preserveAttributeLineBreaks) voidsetPreservedNewlines(Integer preservedNewlines) voidsetPreserveEmptyContent(Boolean preserveEmptyContent) voidsetPreserveSpace(List<String> preserveSpace) voidsetSpaceBeforeEmptyCloseTag(Boolean spaceBeforeEmptyCloseTag) voidsetSplitAttributes(String splitAttributes) voidsetSplitAttributesIndentSize(Integer splitAttributesIndentSize) voidsetXsiSchemaLocationSplit(String xsiSchemaLocationSplit) Methods inherited from class org.eclipse.lemminx.settings.DocumentMatcher
getGrammarURI, getNamespaceURI, getPublicId, getRootElement, getSystemId, matches, setGrammarURI, setNamespaceURI, setPublicId, setRootElement, setSystemIdMethods inherited from class org.eclipse.lemminx.settings.PathPatternMatcher
createGlobMatcher, equals, getPathMatcher, getPattern, matches, matches, setPathMatcher, setPattern
-
Constructor Details
-
XMLFormattingProfile
public XMLFormattingProfile()
-
-
Method Details
-
applyTo
Applies all non-null format override fields from this profile onto the given target formatting options. Fields that arenullare left unchanged in the target (the global default is kept).Use case: given global settings with
splitAttributes=preserveand a profile withsplitAttributes=force-expand-multiline, callingapplyTo(globalCopy)changes onlysplitAttributeswhile keeping all other fields from the global settings.- Parameters:
target- the formatting options to modify (typically a copy of the global settings).
-
getSplitAttributes
-
setSplitAttributes
-
getJoinCDATALines
-
setJoinCDATALines
-
getFormatComments
-
setFormatComments
-
getJoinCommentLines
-
setJoinCommentLines
-
getJoinContentLines
-
setJoinContentLines
-
getEnabled
-
setEnabled
-
getSpaceBeforeEmptyCloseTag
-
setSpaceBeforeEmptyCloseTag
-
getPreservedNewlines
-
setPreservedNewlines
-
getEnforceQuoteStyle
-
setEnforceQuoteStyle
-
getPreserveAttributeLineBreaks
-
setPreserveAttributeLineBreaks
-
getPreserveEmptyContent
-
setPreserveEmptyContent
-
getSplitAttributesIndentSize
-
setSplitAttributesIndentSize
-
getClosingBracketNewLine
-
setClosingBracketNewLine
-
getEmptyElements
-
setEmptyElements
-
getPreserveSpace
-
setPreserveSpace
-
getBlockElements
-
setBlockElements
-
getMixedContent
-
setMixedContent
-
getGrammarAwareFormatting
-
setGrammarAwareFormatting
-
getXsiSchemaLocationSplit
-
setXsiSchemaLocationSplit
-
getLegacy
-
setLegacy
-
getMaxLineWidth
-
setMaxLineWidth
-