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.WhitespaceReplacer
WhitespaceReplacer that is able to perform force autowraps and manageBslWrapWithIndentByOffset
formatting
-
-
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 int
computeNewLineCount(org.eclipse.xtext.formatting2.ITextReplacerContext context)
org.eclipse.xtext.formatting2.ITextReplacerContext
createReplacements(org.eclipse.xtext.formatting2.ITextReplacerContext context)
Mainly copied fromWhitespaceReplacer
.void
enableNoNewLineForWrap()
Does not add newline for late calculated autowrap.protected int
logicalLength(String text, org.eclipse.xtext.formatting2.ITextReplacerContext context)
The representation size of textboolean
needsForceAutowrap()
Whether this replacer shall force autowrapvoid
setForceAutowrap(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 benull
formatting
- The formatting information, cannot benull
spacesForTabs
- Whether spaces shall be used for indentation, cannot benull
The
- 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 benull
formatting
- The formatting information, cannot benull
spacesForTabs
- Whether spaces shall be used for indentation, cannot benull
The
- 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 recognizeBslWrapWithIndentByOffset
and perform force wrapping- Specified by:
createReplacements
in interfaceorg.eclipse.xtext.formatting2.ITextReplacer
- Overrides:
createReplacements
in 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:
computeNewLineCount
in 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 benull
context
- The context to get preferences, cannot benull
- Returns:
- The logical length of text which is its representation length
-
-