Interface VCSFile.Position

    • Method Detail

      • getFile

        VCSFile getFile()
        Returns the referenced file.
        Returns:
        The referenced file.
      • getLine

        int getLine()
        Returns the line of this position >= 1.
        Returns:
        The line of this position >= 1.
      • getColumn

        int getColumn()
        Returns the column of this position >= 1.
        Returns:
        The column of this position >= 1.
      • getOffset

        int getOffset()
        Returns the offset of this position >= 0.
        Returns:
        The offset of this position >= 0.
      • getLineOffset

        int getLineOffset()
        Returns the line offset of this position >= 0.
        Returns:
        The line offset of this position >= 0.
      • getTabSize

        int getTabSize()
        Returns the tab size of this position >= 1.
        Returns:
        The tab size of this position >= 1.
      • apply

        default java.util.Optional<VCSFile.Position> apply​(FileChange fileChange)
                                                    throws java.lang.NullPointerException,
                                                           java.lang.IllegalArgumentException,
                                                           java.io.IOException
        Applies the diff of fileChange (see FileChange.computeDiff()) and computes the resulting position. Returns an empty Optional if fileChange is of type FileChange.Type.REMOVE, or if the line of this position was deleted without a corresponding insertion. If the line of this position was changed to a non-empty string, the resulting column is set to 1. If the line of this position was changed to an empty string, an empty Optional is returned.
        Parameters:
        fileChange - The file change to apply.
        Returns:
        The updated position.
        Throws:
        java.lang.NullPointerException - If fileChange is null.
        java.lang.IllegalArgumentException - If the file referenced by fileChange differs from the file referenced by this position.
        java.io.IOException - If computing the line diff (see FileChange.computeDiff()) fails.
      • nextLine

        default java.util.Optional<VCSFile.Position> nextLine()
                                                       throws java.io.IOException
        Returns the position located at the first column of the next line. If this position is located at the last line, or if the next line is empty, an empty Optional is returned.
        Returns:
        The position located at the first column of the next line.
        Throws:
        java.io.IOException - If an error occurred while reading the file content.
      • previousLine

        default java.util.Optional<VCSFile.Position> previousLine()
                                                           throws java.io.IOException
        Returns the position located at the first column of the previous line. If this position is located at the first line, or if the previous line is empty, an empty Optional is returned.
        Returns:
        The position located at the first column of the previous line.
        Throws:
        java.io.IOException - If an error occurred while reading the file content.
      • beginOfLine

        default VCSFile.Position beginOfLine()
                                      throws java.io.IOException
        Returns the position located at the first column of the current line.
        Returns:
        The position located at the first column of the current line.
        Throws:
        java.io.IOException - If an error occurred while reading the file content.
      • endOfLine

        default VCSFile.Position endOfLine()
                                    throws java.io.IOException
        Returns the position located at the last column of the current line.
        Returns:
        The position located at the last column of the current line.
        Throws:
        java.io.IOException - If an error occurred while reading the file content.
      • mapTo

        default java.util.Optional<VCSFile.Position> mapTo​(VCSFile file)
                                                    throws java.io.IOException
        Returns a position with same line, column, offset, line offset, and tab size, but located in file. Returns an empty optional if this position does not exist in file.
        Parameters:
        file - The file to map this position to.
        Returns:
        A position with same line, column, offset, line offset, and tab size, but located in file.
        Throws:
        java.lang.NullPointerException - If file is null.
        java.io.IOException - If an error occurred while reading the file content.
      • readChar

        default char readChar()
                       throws java.io.IOException
        Reads the character this position points to.
        Returns:
        The character this position points to.
        Throws:
        java.io.IOException - If an error occurred while reading the file content.
      • rangeTo

        default VCSFile.Range rangeTo​(VCSFile.Position other)
        Creates a range from this and the given position. Automatically computes which position is the begin and which position is the end.
        Parameters:
        other - The position to create the range to.
        Returns:
        A range from this and the given position.
        Throws:
        java.lang.NullPointerException - If other is null.
        java.lang.IllegalArgumentException - If this and other reference different files.