Interface CompletingParsedLine

  • All Superinterfaces:
    ParsedLine
    All Known Implementing Classes:
    DefaultParser.ArgumentList

    public interface CompletingParsedLine
    extends ParsedLine
    An extension of ParsedLine that, being aware of the quoting and escaping rules of the Parser that produced it, knows if and how a completion candidate should be escaped/quoted.

    This interface adds methods to handle the raw (unprocessed) form of words, including any quotes and escape characters that may be present in the original input. It also provides functionality to properly escape completion candidates according to the parser's syntax rules.

    Implementations of this interface are crucial for proper tab completion in shells that support complex quoting and escaping mechanisms, ensuring that completed text is properly formatted according to the shell's syntax.

    See Also:
    ParsedLine, Parser
    • Method Detail

      • escape

        java.lang.CharSequence escape​(java.lang.CharSequence candidate,
                                      boolean complete)
        Escapes a completion candidate according to the parser's quoting and escaping rules.

        This method ensures that special characters in the candidate are properly escaped or quoted according to the syntax rules of the parser, maintaining consistency with the current input line's quoting style.

        Parameters:
        candidate - the completion candidate that may need escaping
        complete - true if this is a complete word, false if it's a partial completion
        Returns:
        the properly escaped/quoted candidate ready for insertion
      • rawWordCursor

        int rawWordCursor()
        Returns the cursor position within the raw (unprocessed) current word.

        Unlike ParsedLine.wordCursor(), this method returns the cursor position in the original word text, including any quotes and escape characters.

        Returns:
        the cursor position within the raw current word
      • rawWordLength

        int rawWordLength()
        Returns the length of the raw (unprocessed) current word.

        This is the length of the original word text, including any quotes and escape characters that may have been removed during parsing.

        Returns:
        the length of the raw current word