Interface BasedSequence

    • Method Detail

      • of

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

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

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

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

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

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

        @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
                         IBasedSegmentBuilder<?> builder)
        Add segments for this sequence, replacing out of base characters with strings
        Parameters:
        builder - builder
      • getSegmentTree

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

        @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
        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
        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
        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
                             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
        BasedSequence getEmptyPrefix()
        Get empty prefix to this sequence
        Returns:
        same as subSequence(0,0)
      • getEmptySuffix

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

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

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

        @NotNull
        BasedSequence unescape​(@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
        BasedSequence normalizeEOL​(@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
        BasedSequence normalizeEndWithEOL​(@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
                              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
                                 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
        BasedSequence spliceAtEnd​(@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
                              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
                               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
        BasedSequence prefixOf​(@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
        BasedSequence suffixOf​(@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
        BasedSequence intersect​(@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
        BasedSequence extendByAny​(@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
                               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
                                  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
                               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
                                  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
        BasedSequence extendByAnyNot​(@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 BasedSequence extendToAny​(@NotNull
                                          CharPredicate charSet,
                                          int maxCount)
        Deprecated.
      • extendToEndOfLine

        @NotNull
        BasedSequence extendToEndOfLine​(@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
        BasedSequence extendToEndOfLine​(boolean includeEol)
      • extendToStartOfLine

        @NotNull
        BasedSequence extendToStartOfLine​(@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
        BasedSequence extendToStartOfLine​(boolean includeEol)
      • extendToStartOfLine

        @NotNull
        BasedSequence extendToStartOfLine()
      • prefixWithIndent

        @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
      • baseLineColumnAtIndex

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

        @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
        Pair<java.lang.Integer,​java.lang.Integer> baseLineColumnAtStart()
      • baseLineColumnAtEnd

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

        int baseEndOfLine()
      • baseEndOfLineAnyEOL

        int baseEndOfLineAnyEOL()
      • baseStartOfLine

        int baseStartOfLine()
      • baseStartOfLineAnyEOL

        int baseStartOfLineAnyEOL()
      • baseLineRangeAtStart

        @NotNull
        Range baseLineRangeAtStart()
      • baseLineRangeAtEnd

        @NotNull
        Range baseLineRangeAtEnd()
      • baseColumnAtEnd

        int baseColumnAtEnd()
      • baseColumnAtStart

        int baseColumnAtStart()