Package org.eclipse.xtext.formatting2
Class FormatterRequest
- java.lang.Object
-
- org.eclipse.xtext.formatting2.FormatterRequest
-
public class FormatterRequest extends java.lang.Object
A request tells the formatter what and how to format.
When invoking the formatter, the request is passed into
IFormatter2.format(FormatterRequest)
.A request carries information about:
- The
textRegionAccess
which allows to obtain the to-be-formatted semantic model with text regions. Preferences
with keys from e.g.FormatterPreferenceKeys
.regions
that describe how to restrict the text regions for whichreplacements
are produced.- An option to
allowIdentityEdits()
which will disable automated suppression of text replacements that do not cause changes. - A setting for green-field formatting (
formatUndefinedHiddenRegionsOnly
): only format regions that have no whitespace information yet.
- Since:
- 2.8
- The
-
-
Constructor Summary
Constructors Constructor Description FormatterRequest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FormatterRequest
addRegion(org.eclipse.xtext.util.ITextRegion region)
boolean
allowIdentityEdits()
org.eclipse.xtext.util.IAcceptor<java.lang.Exception>
getExceptionHandler()
org.eclipse.xtext.util.IAcceptor<java.lang.Exception>
getExplicitExceptionHandler()
ITypedPreferenceValues
getPreferences()
java.util.Collection<org.eclipse.xtext.util.ITextRegion>
getRegions()
ITextRegionAccess
getTextRegionAccess()
boolean
isEnableDebugTracing()
boolean
isFormatUndefinedHiddenRegionsOnly()
FormatterRequest
setAllowIdentityEdits(boolean allowIdentityEdits)
void
setEnableDebugTracing(boolean enableDebugTracing)
FormatterRequest
setExceptionHandler(org.eclipse.xtext.util.IAcceptor<java.lang.Exception> problemHandler)
FormatterRequest
setFormatUndefinedHiddenRegionsOnly(boolean formatUndefinedHiddenRegionsOnly)
FormatterRequest
setPreferences(ITypedPreferenceValues preferenceValues)
FormatterRequest
setRegions(java.util.Collection<org.eclipse.xtext.util.ITextRegion> regions)
FormatterRequest
setTextRegionAccess(ITextRegionAccess tokens)
Sets thetextRegionAccess
.
-
-
-
Method Detail
-
addRegion
public FormatterRequest addRegion(org.eclipse.xtext.util.ITextRegion region)
- See Also:
regions
-
setRegions
public FormatterRequest setRegions(java.util.Collection<org.eclipse.xtext.util.ITextRegion> regions)
- See Also:
regions
-
getRegions
public java.util.Collection<org.eclipse.xtext.util.ITextRegion> getRegions()
- See Also:
regions
-
getTextRegionAccess
public ITextRegionAccess getTextRegionAccess()
- See Also:
textRegionAccess
-
setTextRegionAccess
public FormatterRequest setTextRegionAccess(ITextRegionAccess tokens)
Sets thetextRegionAccess
. If the region has syntax errors and no explicitExceptionAcceptor
is configured yet, theignoring acceptor
will be configured.
-
setAllowIdentityEdits
public FormatterRequest setAllowIdentityEdits(boolean allowIdentityEdits)
- See Also:
allowIdentityEdits
-
allowIdentityEdits
public boolean allowIdentityEdits()
- See Also:
allowIdentityEdits
-
setPreferences
public FormatterRequest setPreferences(ITypedPreferenceValues preferenceValues)
- See Also:
preferences
-
getPreferences
public ITypedPreferenceValues getPreferences()
- See Also:
preferences
-
isFormatUndefinedHiddenRegionsOnly
public boolean isFormatUndefinedHiddenRegionsOnly()
- See Also:
formatUndefinedHiddenRegionsOnly
-
setFormatUndefinedHiddenRegionsOnly
public FormatterRequest setFormatUndefinedHiddenRegionsOnly(boolean formatUndefinedHiddenRegionsOnly)
- See Also:
formatUndefinedHiddenRegionsOnly
-
getExceptionHandler
public org.eclipse.xtext.util.IAcceptor<java.lang.Exception> getExceptionHandler()
- See Also:
exceptionHandler
-
getExplicitExceptionHandler
public org.eclipse.xtext.util.IAcceptor<java.lang.Exception> getExplicitExceptionHandler()
-
setExceptionHandler
public FormatterRequest setExceptionHandler(org.eclipse.xtext.util.IAcceptor<java.lang.Exception> problemHandler)
- See Also:
exceptionHandler
-
isEnableDebugTracing
public boolean isEnableDebugTracing()
-
setEnableDebugTracing
public void setEnableDebugTracing(boolean enableDebugTracing)
-
-