See: Description
Interface | Description |
---|---|
IAutowrapFormatter |
A strategy for formatting that is to be applied on auto wrapping.
|
IFormattableDocument |
A FormattableDocument is a stateful object that holds a list of
replacers . |
IFormattableSubDocument |
A sub document describes the formatting for a part of the entire document.
|
IFormatter2 |
Use this interface to invoke a formatter.
|
IHiddenRegionFormatter |
An
IHiddenRegionFormatter is used to build a formatting setting for a hidden region. |
IHiddenRegionFormatting |
HiddenRegionFormatting specifies formatting information for a HiddenRegion.
|
IMerger<T> |
Generic interface to describe an external merger for some
mergable type.
|
ISubFormatter |
An ISubFormatter is responsible to format a sub document.
|
ITextReplacer |
A TextReplacer is responsible for a
text region inside a IFormattableDocument and
produces replacements for that region. |
ITextReplacerContext |
Relevant state and methods during execution of a
text replacer . |
Class | Description |
---|---|
AbstractFormatter2 |
This is an abstract base class for language-specific formatters.
|
FormatterPreferenceKeys |
General preference keys used by this formatting infrastructure.
|
FormatterPreferenceValuesProvider |
Default
IPreferenceValuesProvider for a formatter. |
FormatterRequest |
A request tells the formatter what and how to format.
|
Exception | Description |
---|---|
ConflictingFormattingException |
An exception to indicate that a region of the document was formatted with
conflicting settings.
|
FormattingNotApplicableException |
This exception can be thrown by a
ISubFormatter to indicate that a conditional formatting attempt failed. |
Annotation Type | Description |
---|---|
FormatterPreferences |
Marks an instance of
IPreferenceValuesProvider as the one that should be used by the formatter. |
Xtext formatting infrastructure since Xtext 2.8.
A formatter is responsible for arranging line-wraps, indentation, whitespace, etc. in a text document to improve its readability and emphasize its structure. A formatter is not supposed to alter a document in a way that impacts the semantic model.
This infrastructure is capable of formatting documents based on the node model and based on the serializer's output. The actual formatting is done by constructing a list of text replacements. Applying the text replacements turns the unformatted document into a formatted document. Purpose of this infrastructure is to make it convenient for implementers to construct these text replacements.
To run the formatter, you'll need to construct a FormatterRequest
,
get an instance of IFormatter2
from your language's Guice Injector,
and call IFormatter2.format(FormatterRequest)
. The result will be a list
of text replacements. Use ITextRegionRewriter
to apply the replacements to a String/CharSequence, if desired.
To implement a formatter or to understand how to implement a formatter, see
AbstractFormatter2
.
Use the IFormatter2 to invoke the formatter
,
Extend the AbstractFormatter2 to implement a formatter
,
The FormatterRequest is a per-execution scoped configuration for the formatter.
Per-language configuration is handled by the injector
or {@link org.eclipse.xtext.formatting2.AbstractFormatter2}.