Package com.e1c.g5.v8.dt.formatter.bsl
Class BslWhitespaceReplacer
- java.lang.Object
-
- org.eclipse.xtext.formatting2.internal.WhitespaceReplacer
-
- com.e1c.g5.v8.dt.formatter.bsl.BslWhitespaceReplacer
-
- All Implemented Interfaces:
org.eclipse.xtext.formatting2.ITextReplacer
public class BslWhitespaceReplacer extends org.eclipse.xtext.formatting2.internal.WhitespaceReplacerWhitespaceReplacer that is able to perform force autowraps and manageBslWrapWithIndentByOffsetformatting
-
-
Constructor Summary
Constructors Constructor Description BslWhitespaceReplacer(org.eclipse.xtext.formatting2.regionaccess.ITextSegment whitespace, org.eclipse.xtext.formatting2.IHiddenRegionFormatting formatting, Boolean spacesForTabs, int tabWidth)Same as calling this(whitespace, formatting, spacesForTabs, tabWidth, false)BslWhitespaceReplacer(org.eclipse.xtext.formatting2.regionaccess.ITextSegment whitespace, org.eclipse.xtext.formatting2.IHiddenRegionFormatting formatting, Boolean spacesForTabs, int tabWidth, boolean forceAutowrap)Calls super's constructor with given parameters
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcomputeNewLineCount(org.eclipse.xtext.formatting2.ITextReplacerContext context)org.eclipse.xtext.formatting2.ITextReplacerContextcreateReplacements(org.eclipse.xtext.formatting2.ITextReplacerContext context)Mainly copied fromWhitespaceReplacer.voidenableNoNewLineForWrap()Does not add newline for late calculated autowrap.protected intlogicalLength(String text, org.eclipse.xtext.formatting2.ITextReplacerContext context)The representation size of textbooleanneedsForceAutowrap()Whether this replacer shall force autowrapvoidsetForceAutowrap(boolean forceAutowrap)Sets theforceAutowrap's value
-
-
-
Constructor Detail
-
BslWhitespaceReplacer
public BslWhitespaceReplacer(org.eclipse.xtext.formatting2.regionaccess.ITextSegment whitespace, org.eclipse.xtext.formatting2.IHiddenRegionFormatting formatting, Boolean spacesForTabs, int tabWidth)Same as calling this(whitespace, formatting, spacesForTabs, tabWidth, false)- Parameters:
whitespace- The region of replacement, cannot benullformatting- The formatting information, cannot benullspacesForTabs- Whether spaces shall be used for indentation, cannot benullThe- size of tab in symbols
-
BslWhitespaceReplacer
public BslWhitespaceReplacer(org.eclipse.xtext.formatting2.regionaccess.ITextSegment whitespace, org.eclipse.xtext.formatting2.IHiddenRegionFormatting formatting, Boolean spacesForTabs, int tabWidth, boolean forceAutowrap)Calls super's constructor with given parameters- Parameters:
whitespace- The region of replacement, cannot benullformatting- The formatting information, cannot benullspacesForTabs- Whether spaces shall be used for indentation, cannot benullThe- size of tab in symbolsforceAutowrap- Whether autowrap shall be forced by this replacer
-
-
Method Detail
-
createReplacements
public org.eclipse.xtext.formatting2.ITextReplacerContext createReplacements(org.eclipse.xtext.formatting2.ITextReplacerContext context)
Mainly copied fromWhitespaceReplacer. it can recognizeBslWrapWithIndentByOffsetand perform force wrapping- Specified by:
createReplacementsin interfaceorg.eclipse.xtext.formatting2.ITextReplacer- Overrides:
createReplacementsin classorg.eclipse.xtext.formatting2.internal.WhitespaceReplacer- Parameters:
context- The context to create replacements with, cannot benull- Returns:
- The next context, can be
null
-
needsForceAutowrap
public boolean needsForceAutowrap()
Whether this replacer shall force autowrap- Returns:
- The
forceAutowrap's value
-
setForceAutowrap
public void setForceAutowrap(boolean forceAutowrap)
Sets theforceAutowrap's value- Parameters:
forceAutowrap- The value to be set
-
enableNoNewLineForWrap
public void enableNoNewLineForWrap()
Does not add newline for late calculated autowrap. Useful for comments wrapping as comment contains new line in its own region
-
computeNewLineCount
protected int computeNewLineCount(org.eclipse.xtext.formatting2.ITextReplacerContext context)
- Overrides:
computeNewLineCountin classorg.eclipse.xtext.formatting2.internal.WhitespaceReplacer
-
logicalLength
protected int logicalLength(String text, org.eclipse.xtext.formatting2.ITextReplacerContext context)
The representation size of text- Parameters:
text- The text which logical length is evaluated, can benullcontext- The context to get preferences, cannot benull- Returns:
- The logical length of text which is its representation length
-
-