Interface BasedSequence

    • Method Detail

      • of

        @NotNull
        static @NotNull BasedSequence of​(@Nullable
                                         @Nullable java.lang.CharSequence charSequence)
      • ofSpaces

        @NotNull
        static @NotNull BasedSequence ofSpaces​(int count)
      • repeatOf

        @NotNull
        static @NotNull BasedSequence repeatOf​(char c,
                                               int count)
      • repeatOf

        @NotNull
        static @NotNull BasedSequence repeatOf​(@NotNull
                                               @NotNull java.lang.CharSequence chars,
                                               int count)
      • repeatOf

        @NotNull
        static @NotNull BasedSequence repeatOf​(@NotNull
                                               @NotNull java.lang.CharSequence chars,
                                               int startIndex,
                                               int endIndex)
      • getBase

        @NotNull
        @NotNull java.lang.Object getBase()
        Get the underlying object on which this sequence contents are based
        Returns:
        underlying object containing original text
      • getBaseSequence

        @NotNull
        @NotNull BasedSequence getBaseSequence()
        Get the base sequence for the text
        Returns:
        base sequence
      • getStartOffset

        int getStartOffset()
        Get the start offset of this sequence into getBaseSequence() and getBase() original text source.
        Returns:
        start offset in original text
      • getEndOffset

        int getEndOffset()
        Get the end offset of this sequence into getBaseSequence() and getBase() original text source.
        Returns:
        end offset in original text
      • getIndexOffset

        int getIndexOffset​(int index)
        Get the offset of index in this sequence mapped to offset into getBaseSequence() and getBase() original text source. NOTE: if the character at given index does not equal the corresponding character in the base sequence then this method should return -1 otherwise segmented based sequence will be created for original base character
        Parameters:
        index - index for which to get the offset in original source
        Returns:
        offset of index of this sequence in original text
      • addSegments

        void addSegments​(@NotNull
                         @NotNull IBasedSegmentBuilder<?> builder)
        Add segments for this sequence, replacing out of base characters with strings
        Parameters:
        builder - builder
      • getSegmentTree

        @NotNull
        @NotNull SegmentTree getSegmentTree()
        Get the segment tree for this sequence
        Returns:
        segment tree
      • getSourceRange

        @NotNull
        @NotNull Range getSourceRange()
        Get the range of this sequence in original getBaseSequence() and getBase() original text source.
        Returns:
        Range of start offset and end offset
      • subSequence

        @NotNull
        @NotNull BasedSequence subSequence​(int startIndex,
                                           int endIndex)
        Get a portion of this sequence
        Specified by:
        subSequence in interface java.lang.CharSequence
        Specified by:
        subSequence in interface IRichSequence<BasedSequence>
        Parameters:
        startIndex - offset from startIndex of this sequence
        endIndex - offset from startIndex of this sequence
        Returns:
        based sequence which represents the requested range of this sequence.
      • baseSubSequence

        @NotNull
        @NotNull BasedSequence baseSubSequence​(int startIndex,
                                               int endIndex)
        Get a portion of this sequence's base sequence

        NOTE: this means that if this sequence applies modifications to the original sequence then these modifications are NOT be applied to the returned sequence.

        NOTE: It should only be implemented in classes which provide base sequences such as CharSubSequence and SubSequence others use inherited implementation of BasedSequenceImpl

        Parameters:
        startIndex - offset from 0 of original sequence
        endIndex - offset from 0 of original sequence
        Returns:
        based sequence whose contents reflect the selected portion
      • baseSubSequence

        @NotNull
        @NotNull BasedSequence baseSubSequence​(int startIndex)
        Get a portion of the original sequence that this sequence is based on
        Parameters:
        startIndex - offset from 0 of original sequence
        Returns:
        based sequence from startIndex to the endIndex
      • safeBaseCharAt

        char safeBaseCharAt​(int index)
        Safe, if index out of range but based sequence has characters will return those, else returns '\0'

        Allows peeking into preceding/following characters to the ones contained in this sequence

        Parameters:
        index - index in string
        Returns:
        character or '\0' if index out of base sequence
      • isBaseCharAt

        boolean isBaseCharAt​(int index,
                             @NotNull
                             @NotNull CharPredicate predicate)
        Safe, if index out of range but based sequence has characters will return those, else returns '\0'

        Allows peeking into preceding/following characters to the ones contained in this sequence

        Parameters:
        index - index in string
        predicate - character set predicate
        Returns:
        true if character at index tests true
      • getEmptyPrefix

        @NotNull
        @NotNull BasedSequence getEmptyPrefix()
        Get empty prefix to this sequence
        Returns:
        same as subSequence(0,0)
      • getEmptySuffix

        @NotNull
        @NotNull BasedSequence getEmptySuffix()
        Get empty suffix to this sequence
        Returns:
        same as subSequence(length())
      • unescape

        @NotNull
        @NotNull java.lang.String unescape()
        Get the unescaped string of this sequence content
        Returns:
        unescaped text
      • unescapeNoEntities

        @NotNull
        @NotNull java.lang.String unescapeNoEntities()
        Get the unescaped string of this sequence content without unescaping entities
        Returns:
        unescaped text
      • unescape

        @NotNull
        @NotNull BasedSequence unescape​(@NotNull
                                        @NotNull ReplacedTextMapper textMapper)
        Get the unescaped string of this sequence content
        Parameters:
        textMapper - replaced text mapper which will be uses to map unescaped index to original source index
        Returns:
        unescaped text in based sequence
      • normalizeEOL

        @NotNull
        @NotNull BasedSequence normalizeEOL​(@NotNull
                                            @NotNull ReplacedTextMapper textMapper)
        replace any \r\n and \r by \n
        Parameters:
        textMapper - replaced text mapper which will be uses to map unescaped index to original source index
        Returns:
        based sequence with only \n for line separators
      • normalizeEndWithEOL

        @NotNull
        @NotNull BasedSequence normalizeEndWithEOL​(@NotNull
                                                   @NotNull ReplacedTextMapper textMapper)
        replace any \r\n and \r by \n, append terminating EOL if one is not present
        Parameters:
        textMapper - replaced text mapper which will be uses to map unescaped index to original source index
        Returns:
        based sequence with only \n for line separators and terminated by \n
      • isContinuedBy

        boolean isContinuedBy​(@NotNull
                              @NotNull BasedSequence other)
        Test if the given sequence is a continuation of this sequence in original source text
        Parameters:
        other - sequence to test
        Returns:
        true if the given sequence is a continuation of this one in the original text
      • isContinuationOf

        boolean isContinuationOf​(@NotNull
                                 @NotNull BasedSequence other)
        Test if this sequence is a continuation of the given sequence in original source text
        Parameters:
        other - sequence to test
        Returns:
        true if this sequence is a continuation of the given sequence in original source text
      • spliceAtEnd

        @NotNull
        @NotNull BasedSequence spliceAtEnd​(@NotNull
                                           @NotNull BasedSequence other)
        Splice the given sequence to the end of this one and return a BasedSequence of the result. Does not copy anything, creates a new based sequence of the original text but one that spans characters of this sequence and other
        Parameters:
        other - sequence to append to end of this one
        Returns:
        based sequence that contains the span from start of this sequence and end of other

        assertion will fail if the other sequence is not a continuation of this one

      • containsAllOf

        boolean containsAllOf​(@NotNull
                              @NotNull BasedSequence other)
        start/end offset based containment, not textual
        Parameters:
        other - based sequence from the same base
        Returns:
        true if other is contained in this
      • containsSomeOf

        boolean containsSomeOf​(@NotNull
                               @NotNull BasedSequence other)
        start/end offset based containment, not textual
        Parameters:
        other - based sequence from the same base
        Returns:
        true if other is contained in this
      • prefixOf

        @NotNull
        @NotNull BasedSequence prefixOf​(@NotNull
                                        @NotNull BasedSequence other)
        Get the prefix part of this from other, start/end offset based containment, not textual
        Parameters:
        other - based sequence from the same base
        Returns:
        prefix part of this as compared to other, start/end offset based, not content
      • suffixOf

        @NotNull
        @NotNull BasedSequence suffixOf​(@NotNull
                                        @NotNull BasedSequence other)
        Get the suffix part of this from other, start/end offset based containment, not textual
        Parameters:
        other - based sequence from the same base
        Returns:
        suffix part of this as compared to other, start/end offset based, not content
      • intersect

        @NotNull
        @NotNull BasedSequence intersect​(@NotNull
                                         @NotNull BasedSequence other)
        start/end offset based intersection, not textual
        Parameters:
        other - based sequence from the same parent
        Returns:
        sequence which is the intersection of the range of this and other
      • extendByAny

        @NotNull
        @NotNull BasedSequence extendByAny​(@NotNull
                                           @NotNull CharPredicate charSet,
                                           int maxCount)
        Extend this based sequence to include characters from underlying based sequence
        Parameters:
        charSet - set of characters to include
        maxCount - maximum extra characters to include
        Returns:
        sequence which
      • containsSomeIn

        boolean containsSomeIn​(@NotNull
                               @NotNull CharPredicate charSet)
        Test for line containing some of the characters in the set
        Parameters:
        charSet - set of characters to be tested
        Returns:
        true if line contains some characters in the set
      • containsSomeNotIn

        boolean containsSomeNotIn​(@NotNull
                                  @NotNull CharPredicate charSet)
        Test for line containing some characters not in the set
        Parameters:
        charSet - set of characters to be tested
        Returns:
        true if line contains some characters not in the set
      • containsOnlyIn

        boolean containsOnlyIn​(@NotNull
                               @NotNull CharPredicate charSet)
        Test for line contains only characters from the set
        Parameters:
        charSet - set of characters to be tested
        Returns:
        true if line contains some characters from the set
      • containsOnlyNotIn

        boolean containsOnlyNotIn​(@NotNull
                                  @NotNull CharPredicate charSet)
        Test for line containing only characters not in the set
        Parameters:
        charSet - set of characters to be tested
        Returns:
        true if line contains some characters from the set
      • extendByAnyNot

        @NotNull
        @NotNull BasedSequence extendByAnyNot​(@NotNull
                                              @NotNull CharPredicate charSet,
                                              int maxCount)
        Extend this based sequence to include characters from underlying based sequence not in character set
        Parameters:
        charSet - set of characters to include
        maxCount - maximum extra characters to include
        Returns:
        sequence which
      • extendToAny

        @NotNull
        @Deprecated
        default @NotNull BasedSequence extendToAny​(@NotNull
                                                   @NotNull CharPredicate charSet,
                                                   int maxCount)
        Deprecated.
      • extendToAny

        @NotNull
        @Deprecated
        default @NotNull BasedSequence extendToAny​(@NotNull
                                                   @NotNull CharPredicate charSet)
        Deprecated.
      • extendToEndOfLine

        @NotNull
        @NotNull BasedSequence extendToEndOfLine​(@NotNull
                                                 @NotNull CharPredicate eolChars,
                                                 boolean includeEol)
        Extend in contained based sequence
        Parameters:
        eolChars - characters to consider as EOL, note IRichSequence.eolStartLength(int) IRichSequence.eolEndLength(int) should report length of EOL found if length > 1
        includeEol - if to include the eol in the string
        Returns:
        resulting sequence after extension. If already spanning the line then this sequence is returned. if the last character of this sequence are found in eolChars then no extension will be performed since it already includes the line end
      • extendToEndOfLine

        @NotNull
        @NotNull BasedSequence extendToEndOfLine​(boolean includeEol)
      • extendToEndOfLine

        @NotNull
        @NotNull BasedSequence extendToEndOfLine()
      • extendToStartOfLine

        @NotNull
        @NotNull BasedSequence extendToStartOfLine​(@NotNull
                                                   @NotNull CharPredicate eolChars,
                                                   boolean includeEol)
        Extend in contained based sequence
        Parameters:
        eolChars - characters to consider as EOL, note IRichSequence.eolStartLength(int) IRichSequence.eolEndLength(int) should report length of EOL found if length > 1
        includeEol - if to include the eol in the string
        Returns:
        resulting sequence after extension. If already spanning the line then this sequence is returned. if the first character of this sequence are found in eolChars then no extension will be performed since it already includes the line end
      • extendToStartOfLine

        @NotNull
        @NotNull BasedSequence extendToStartOfLine​(boolean includeEol)
      • extendToStartOfLine

        @NotNull
        @NotNull BasedSequence extendToStartOfLine()
      • prefixWithIndent

        @NotNull
        @NotNull BasedSequence prefixWithIndent​(int maxColumns)
        Extend this based sequence to include characters from underlying based sequence taking tab expansion to 4th spaces into account
        Parameters:
        maxColumns - maximum columns to include, default Integer.MAX_VALUE
        Returns:
        sequence which
      • prefixWithIndent

        @NotNull
        @NotNull BasedSequence prefixWithIndent()
      • baseLineColumnAtIndex

        @NotNull
        @NotNull Pair<java.lang.Integer,​java.lang.Integer> baseLineColumnAtIndex​(int index)
      • baseLineRangeAtIndex

        @NotNull
        @NotNull Range baseLineRangeAtIndex​(int index)
      • baseEndOfLine

        int baseEndOfLine​(int index)
      • baseEndOfLineAnyEOL

        int baseEndOfLineAnyEOL​(int index)
      • baseStartOfLine

        int baseStartOfLine​(int index)
      • baseStartOfLineAnyEOL

        int baseStartOfLineAnyEOL​(int index)
      • baseColumnAtIndex

        int baseColumnAtIndex​(int index)
      • baseLineColumnAtStart

        @NotNull
        @NotNull Pair<java.lang.Integer,​java.lang.Integer> baseLineColumnAtStart()
      • baseLineColumnAtEnd

        @NotNull
        @NotNull Pair<java.lang.Integer,​java.lang.Integer> baseLineColumnAtEnd()
      • baseEndOfLine

        int baseEndOfLine()
      • baseEndOfLineAnyEOL

        int baseEndOfLineAnyEOL()
      • baseStartOfLine

        int baseStartOfLine()
      • baseStartOfLineAnyEOL

        int baseStartOfLineAnyEOL()
      • baseLineRangeAtStart

        @NotNull
        @NotNull Range baseLineRangeAtStart()
      • baseLineRangeAtEnd

        @NotNull
        @NotNull Range baseLineRangeAtEnd()
      • baseColumnAtEnd

        int baseColumnAtEnd()
      • baseColumnAtStart

        int baseColumnAtStart()