public interface IFormattableDocument
A FormattableDocument is a stateful object that holds a list of replacers
. Each replacer is
responsible for a text region inside this document. The document can be populated with replacers in any order.
However, it is not possible and not intended to register two or more replacers for the same or overlapping
region
.
Eventually, all replacers are invoked from the beginning of the document to the end of the document. Each replacer
produces text replacements
for their region. A ITextReplacerContext
is passed on
from replacer to replacer and holds state such as the current indentation level.
Besides this, a formattable document
ITextRegionAccess
for a definition of
HiddenRegions and IHiddenRegionFormatter
for how they can be formatted.Modifier and Type | Method and Description |
---|---|
void |
addReplacer(ITextReplacer replacer)
Add a new replacer to the document.
|
ISemanticRegion |
append(ISemanticRegion appendAfter,
Procedures.Procedure1<? super IHiddenRegionFormatter> initializer)
Create a new
IHiddenRegionFormatting , initialize it, and add it behind the given semanticRegion. |
<T extends org.eclipse.emf.ecore.EObject> |
append(T appendAfter,
Procedures.Procedure1<? super IHiddenRegionFormatter> initializer)
Create a new
IHiddenRegionFormatting , initialize it, and add it behind the given semantic object. |
<T> T |
format(T obj) |
void |
formatConditionally(org.eclipse.emf.ecore.EObject owner,
ISubFormatter... formatters)
Apply the formatting of the first sub formatter that can successfully format the given owner's region.
|
void |
formatConditionally(int offset,
int length,
ISubFormatter... formatters)
Apply the formatting of the first sub formatter that can successfully format the given region.
|
AbstractFormatter2 |
getFormatter()
Returns the formatter that is being used.
|
ITextSegment |
getRegion()
Returns the region this formattable document is responsible for.
|
FormatterRequest |
getRequest()
Returns the current formatting request.
|
<T1 extends ISemanticRegion,T2 extends ISemanticRegion> |
interior(Pair<T1,T2> pair,
Procedures.Procedure1<? super IHiddenRegionFormatter> init) |
<T1 extends ISemanticRegion,T2 extends ISemanticRegion> |
interior(T1 first,
T2 second,
Procedures.Procedure1<? super IHiddenRegionFormatter> init) |
<T extends org.eclipse.emf.ecore.EObject> |
interior(T object,
Procedures.Procedure1<? super IHiddenRegionFormatter> init) |
ISemanticRegion |
prepend(ISemanticRegion prependBefore,
Procedures.Procedure1<? super IHiddenRegionFormatter> initializer)
Create a new
IHiddenRegionFormatting , initialize it, and add it before the given semanticRegion. |
<T extends org.eclipse.emf.ecore.EObject> |
prepend(T prependBefore,
Procedures.Procedure1<? super IHiddenRegionFormatter> initializer)
Create a new
IHiddenRegionFormatting , initialize it, and add it before the given semantic object. |
java.util.List<ITextReplacement> |
renderToTextReplacements()
Render the document.
|
Pair<IHiddenRegion,IHiddenRegion> |
set(IHiddenRegion first,
IHiddenRegion second,
Procedures.Procedure1<? super IHiddenRegionFormatter> init) |
IHiddenRegion |
set(IHiddenRegion hiddenRegion,
Procedures.Procedure1<? super IHiddenRegionFormatter> init)
Create a new
IHiddenRegionFormatting , initialize it, and add it for the given hidden region. |
ISemanticRegion |
surround(ISemanticRegion semanticRegion,
Procedures.Procedure1<? super IHiddenRegionFormatter> beforeAndAfter)
Create a new
IHiddenRegionFormatting , initialize it, and add it before and after the given semantic
region. |
<T extends org.eclipse.emf.ecore.EObject> |
surround(T owner,
Procedures.Procedure1<? super IHiddenRegionFormatter> beforeAndAfter)
Create a new
IHiddenRegionFormatting , initialize it, and add it before and after the given semantic
object. |
IFormattableDocument |
withReplacerFilter(com.google.common.base.Predicate<? super ITextReplacer> filter)
Creates a new formattable document to which only replacers can be added for which the provided predicate yields
true . |
IFormattableDocument withReplacerFilter(com.google.common.base.Predicate<? super ITextReplacer> filter)
true
.ITextSegment getRegion()
AbstractFormatter2 getFormatter()
FormatterRequest getRequest()
void addReplacer(ITextReplacer replacer)
java.util.List<ITextReplacement> renderToTextReplacements()
ISemanticRegion append(ISemanticRegion appendAfter, Procedures.Procedure1<? super IHiddenRegionFormatter> initializer)
IHiddenRegionFormatting
, initialize it, and add it behind the given semanticRegion.
Returns the given semantic region.<T extends org.eclipse.emf.ecore.EObject> T append(T appendAfter, Procedures.Procedure1<? super IHiddenRegionFormatter> initializer)
IHiddenRegionFormatting
, initialize it, and add it behind the given semantic object.
Returns the given semantic object.ISemanticRegion prepend(ISemanticRegion prependBefore, Procedures.Procedure1<? super IHiddenRegionFormatter> initializer)
IHiddenRegionFormatting
, initialize it, and add it before the given semanticRegion.
Returns the given semantic region.<T extends org.eclipse.emf.ecore.EObject> T prepend(T prependBefore, Procedures.Procedure1<? super IHiddenRegionFormatter> initializer)
IHiddenRegionFormatting
, initialize it, and add it before the given semantic object.
Returns the given semantic object.ISemanticRegion surround(ISemanticRegion semanticRegion, Procedures.Procedure1<? super IHiddenRegionFormatter> beforeAndAfter)
IHiddenRegionFormatting
, initialize it, and add it before and after the given semantic
region.
Returns the given semantic region.<T extends org.eclipse.emf.ecore.EObject> T surround(T owner, Procedures.Procedure1<? super IHiddenRegionFormatter> beforeAndAfter)
IHiddenRegionFormatting
, initialize it, and add it before and after the given semantic
object.
Returns the given semantic object.void formatConditionally(org.eclipse.emf.ecore.EObject owner, ISubFormatter... formatters) throws FormattingNotApplicableException
FormattingNotApplicableException
.FormattingNotApplicableException
void formatConditionally(int offset, int length, ISubFormatter... formatters) throws FormattingNotApplicableException
FormattingNotApplicableException
.FormattingNotApplicableException
IHiddenRegion set(IHiddenRegion hiddenRegion, Procedures.Procedure1<? super IHiddenRegionFormatter> init)
IHiddenRegionFormatting
, initialize it, and add it for the given hidden region.
Returns the given hidden region.Pair<IHiddenRegion,IHiddenRegion> set(IHiddenRegion first, IHiddenRegion second, Procedures.Procedure1<? super IHiddenRegionFormatter> init)
<T1 extends ISemanticRegion,T2 extends ISemanticRegion> Pair<T1,T2> interior(T1 first, T2 second, Procedures.Procedure1<? super IHiddenRegionFormatter> init)
<T1 extends ISemanticRegion,T2 extends ISemanticRegion> Pair<T1,T2> interior(Pair<T1,T2> pair, Procedures.Procedure1<? super IHiddenRegionFormatter> init)
<T extends org.eclipse.emf.ecore.EObject> T interior(T object, Procedures.Procedure1<? super IHiddenRegionFormatter> init)
<T> T format(T obj)