Class FormattableDocument
- java.lang.Object
-
- org.eclipse.xtext.formatting2.internal.FormattableDocument
-
- All Implemented Interfaces:
IFormattableDocument
- Direct Known Subclasses:
RootDocument,SubDocument
public abstract class FormattableDocument extends java.lang.Object implements IFormattableDocument
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFormattableDocument()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddReplacer(ITextReplacer replacer)Add a new replacer to the document.ISemanticRegionappend(ISemanticRegion token, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> after)Create a newIHiddenRegionFormatting, initialize it, and add it behind the given semanticRegion.<T extends org.eclipse.emf.ecore.EObject>
Tappend(T owner, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> after)Create a newIHiddenRegionFormatting, initialize it, and add it behind the given semantic object.protected java.lang.StringapplyTextReplacements(java.lang.Iterable<ITextReplacement> replacements)protected ITextReplacerContextcreateReplacements(ITextReplacerContext previous)protected TextSegmentSet<ITextReplacer>createTextReplacerSet()<T> Tformat(T obj)voidformatConditionally(int offset, int length, ISubFormatter... formatters)Apply the formatting of the first sub formatter that can successfully format the given region.voidformatConditionally(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.ITypedPreferenceValuesgetPreferences()protected TextSegmentSet<ITextReplacer>getReplacers()ITextRegionAccessgetTextRegionAccess()<T1 extends ISemanticRegion,T2 extends ISemanticRegion>
org.eclipse.xtext.xbase.lib.Pair<T1,T2>interior(org.eclipse.xtext.xbase.lib.Pair<T1,T2> pair, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> init)<T1 extends ISemanticRegion,T2 extends ISemanticRegion>
org.eclipse.xtext.xbase.lib.Pair<T1,T2>interior(T1 first, T2 second, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> init)<T extends org.eclipse.emf.ecore.EObject>
Tinterior(T object, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> init)protected booleanneedsAutowrap(ITextReplacerContext wrappable, ITextReplacerContext context, int maxLineWidth)ISemanticRegionprepend(ISemanticRegion token, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> before)Create a newIHiddenRegionFormatting, initialize it, and add it before the given semanticRegion.<T extends org.eclipse.emf.ecore.EObject>
Tprepend(T owner, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> before)Create a newIHiddenRegionFormatting, initialize it, and add it before the given semantic object.java.util.List<ITextReplacement>renderToTextReplacements()Render the document.org.eclipse.xtext.xbase.lib.Pair<IHiddenRegion,IHiddenRegion>set(IHiddenRegion first, IHiddenRegion second, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> init)IHiddenRegionset(IHiddenRegion hiddenRegion, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> init)Create a newIHiddenRegionFormatting, initialize it, and add it for the given hidden region.ISemanticRegionsurround(ISemanticRegion token, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> beforeAndAfter)Create a newIHiddenRegionFormatting, initialize it, and add it before and after the given semantic region.<T extends org.eclipse.emf.ecore.EObject>
Tsurround(T owner, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> beforeAndAfter)Create a newIHiddenRegionFormatting, initialize it, and add it before and after the given semantic object.java.lang.StringtoString()IFormattableSubDocumentwithReplacerFilter(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 yieldstrue.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.xtext.formatting2.IFormattableDocument
getFormatter, getRegion, getRequest
-
-
-
-
Method Detail
-
getReplacers
protected TextSegmentSet<ITextReplacer> getReplacers()
-
addReplacer
public void addReplacer(ITextReplacer replacer)
Description copied from interface:IFormattableDocumentAdd a new replacer to the document.- Specified by:
addReplacerin interfaceIFormattableDocument
-
append
public ISemanticRegion append(ISemanticRegion token, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> after)
Description copied from interface:IFormattableDocumentCreate a newIHiddenRegionFormatting, initialize it, and add it behind the given semanticRegion. Returns the given semantic region.- Specified by:
appendin interfaceIFormattableDocument
-
append
public <T extends org.eclipse.emf.ecore.EObject> T append(T owner, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> after)Description copied from interface:IFormattableDocumentCreate a newIHiddenRegionFormatting, initialize it, and add it behind the given semantic object. Returns the given semantic object.- Specified by:
appendin interfaceIFormattableDocument
-
applyTextReplacements
protected java.lang.String applyTextReplacements(java.lang.Iterable<ITextReplacement> replacements)
-
createReplacements
protected ITextReplacerContext createReplacements(ITextReplacerContext previous)
-
createTextReplacerSet
protected TextSegmentSet<ITextReplacer> createTextReplacerSet()
-
format
public <T> T format(T obj)
- Specified by:
formatin interfaceIFormattableDocument
-
formatConditionally
public void formatConditionally(org.eclipse.emf.ecore.EObject owner, ISubFormatter... formatters)Description copied from interface:IFormattableDocumentApply the formatting of the first sub formatter that can successfully format the given owner's region. A sub formatters execution is considered successful if it didn't throw anFormattingNotApplicableException.- Specified by:
formatConditionallyin interfaceIFormattableDocument
-
formatConditionally
public void formatConditionally(int offset, int length, ISubFormatter... formatters) throws FormattingNotApplicableExceptionDescription copied from interface:IFormattableDocumentApply the formatting of the first sub formatter that can successfully format the given region. A sub formatters execution is considered successful if it didn't throw anFormattingNotApplicableException.- Specified by:
formatConditionallyin interfaceIFormattableDocument- Throws:
FormattingNotApplicableException
-
getPreferences
public ITypedPreferenceValues getPreferences()
-
getTextRegionAccess
public ITextRegionAccess getTextRegionAccess()
-
interior
public <T1 extends ISemanticRegion,T2 extends ISemanticRegion> org.eclipse.xtext.xbase.lib.Pair<T1,T2> interior(org.eclipse.xtext.xbase.lib.Pair<T1,T2> pair, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> init)
- Specified by:
interiorin interfaceIFormattableDocument
-
interior
public <T extends org.eclipse.emf.ecore.EObject> T interior(T object, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> init)- Specified by:
interiorin interfaceIFormattableDocument
-
interior
public <T1 extends ISemanticRegion,T2 extends ISemanticRegion> org.eclipse.xtext.xbase.lib.Pair<T1,T2> interior(T1 first, T2 second, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> init)
- Specified by:
interiorin interfaceIFormattableDocument
-
needsAutowrap
protected boolean needsAutowrap(ITextReplacerContext wrappable, ITextReplacerContext context, int maxLineWidth)
-
prepend
public ISemanticRegion prepend(ISemanticRegion token, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> before)
Description copied from interface:IFormattableDocumentCreate a newIHiddenRegionFormatting, initialize it, and add it before the given semanticRegion. Returns the given semantic region.- Specified by:
prependin interfaceIFormattableDocument
-
prepend
public <T extends org.eclipse.emf.ecore.EObject> T prepend(T owner, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> before)Description copied from interface:IFormattableDocumentCreate a newIHiddenRegionFormatting, initialize it, and add it before the given semantic object. Returns the given semantic object.- Specified by:
prependin interfaceIFormattableDocument
-
renderToTextReplacements
public java.util.List<ITextReplacement> renderToTextReplacements()
Description copied from interface:IFormattableDocumentRender the document. This executes all contained replacers and returns the text replacements created by them.- Specified by:
renderToTextReplacementsin interfaceIFormattableDocument
-
set
public org.eclipse.xtext.xbase.lib.Pair<IHiddenRegion,IHiddenRegion> set(IHiddenRegion first, IHiddenRegion second, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> init)
- Specified by:
setin interfaceIFormattableDocument
-
set
public IHiddenRegion set(IHiddenRegion hiddenRegion, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> init)
Description copied from interface:IFormattableDocumentCreate a newIHiddenRegionFormatting, initialize it, and add it for the given hidden region. Returns the given hidden region.- Specified by:
setin interfaceIFormattableDocument
-
surround
public ISemanticRegion surround(ISemanticRegion token, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> beforeAndAfter)
Description copied from interface:IFormattableDocumentCreate a newIHiddenRegionFormatting, initialize it, and add it before and after the given semantic region. Returns the given semantic region.- Specified by:
surroundin interfaceIFormattableDocument
-
surround
public <T extends org.eclipse.emf.ecore.EObject> T surround(T owner, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super IHiddenRegionFormatter> beforeAndAfter)Description copied from interface:IFormattableDocumentCreate a newIHiddenRegionFormatting, initialize it, and add it before and after the given semantic object. Returns the given semantic object.- Specified by:
surroundin interfaceIFormattableDocument
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
withReplacerFilter
public IFormattableSubDocument withReplacerFilter(com.google.common.base.Predicate<? super ITextReplacer> filter)
Description copied from interface:IFormattableDocumentCreates a new formattable document to which only replacers can be added for which the provided predicate yieldstrue.- Specified by:
withReplacerFilterin interfaceIFormattableDocument
-
-