Class 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 manage BslWrapWithIndentByOffset formatting
    • Field Summary

      • Fields inherited from interface org.eclipse.xtext.formatting2.ITextReplacer

        GET_REGION
    • 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
    • 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 be null
        formatting - The formatting information, cannot be null
        spacesForTabs - Whether spaces shall be used for indentation, cannot be null
        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 be null
        formatting - The formatting information, cannot be null
        spacesForTabs - Whether spaces shall be used for indentation, cannot be null
        The - size of tab in symbols
        forceAutowrap - 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 from WhitespaceReplacer. it can recognize BslWrapWithIndentByOffset and perform force wrapping
        Specified by:
        createReplacements in interface org.eclipse.xtext.formatting2.ITextReplacer
        Overrides:
        createReplacements in class org.eclipse.xtext.formatting2.internal.WhitespaceReplacer
        Parameters:
        context - The context to create replacements with, cannot be null
        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 the forceAutowrap'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 class org.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 be null
        context - The context to get preferences, cannot be null
        Returns:
        The logical length of text which is its representation length