Package org.eclipse.lemminx.extensions.contentmodel.participants

## Class ContentModelFormatterParticipant

- java.lang.Object
- - org.eclipse.lemminx.extensions.contentmodel.participants.ContentModelFormatterParticipant

All Implemented Interfaces:
  `IFormatterParticipant`

    public class ContentModelFormatterParticipant
    extends Object
    implements IFormatterParticipant

Formatter participant which uses XSD/DTD grammar information to know the `FormatElementCategory` of a given element.

This participant is enabled when 'xml.format.grammarAwareFormatting' setting is set to true.

Author:
  Angelo ZERR

### Constructor Summary

Constructors
`ContentModelFormatterParticipant​(ContentModelManager contentModelManager)`

### Method Summary

All Methods Instance Methods Concrete Methods
`FormatElementCategory` `getFormatElementCategory​(DOMElement element, XMLFormattingConstraints parentConstraints, Map<String,​Collection<CMDocument>> formattingContext, SharedSettings sharedSettings)` Returns the format element category for the given DOM element and null otherwise.
`boolean` `shouldCollapseEmptyElement​(DOMElement element, SharedSettings sharedSettings)` Returns true if the given element can be collapsed according to grammar constraints.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.eclipse.lemminx.services.extensions.format.IFormatterParticipant

`formatAttributeValue, formatAttributeValue`

### Constructor Detail

#### ContentModelFormatterParticipant

    public ContentModelFormatterParticipant​(ContentModelManager contentModelManager)

### Method Detail

#### getFormatElementCategory

    public FormatElementCategory getFormatElementCategory​(DOMElement element,
                                                          XMLFormattingConstraints parentConstraints,
                                                          Map<String,​Collection<CMDocument>> formattingContext,
                                                          SharedSettings sharedSettings)

Description copied from interface: `IFormatterParticipant`
Returns the format element category for the given DOM element and null otherwise.

Specified by:
  `getFormatElementCategory` in interface `IFormatterParticipant`
Parameters:
  `element` - the DOM element.
  `parentConstraints` - the parent constraints.
  `sharedSettings` - the shared settings.
Returns:
  the format element category for the given DOM element and null otherwise.

#### shouldCollapseEmptyElement

    public boolean shouldCollapseEmptyElement​(DOMElement element,
                                              SharedSettings sharedSettings)

Description copied from interface: `IFormatterParticipant`
Returns true if the given element can be collapsed according to grammar constraints.

Specified by:
  `shouldCollapseEmptyElement` in interface `IFormatterParticipant`
Parameters:
  `element` - the DOM element.
  `sharedSettings` - the shared settings.
Returns:
  true if the given element can be collapsed according to grammar constraints.