Class TokenMarker

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected TokenMarker()
      Creates a new TokenMarker.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addToken​(int length, byte id)
      Adds a token to the token list.
      void deleteLines​(int index, int lines)
      Informs the token marker that line have been deleted from the document.
      void insertLines​(int index, int lines)
      Informs the token marker that lines have been inserted into the document.
      boolean isNextLineRequested()
      Returns true if the next line should be repainted.
      @NotNull java.util.List<Token> markTokens​(@NotNull javax.swing.text.Segment line, int lineIndex)
      A wrapper for the lower-level markTokensImpl method that is called to split a line up into tokens.
      protected abstract byte markTokensImpl​(byte token, @NotNull javax.swing.text.Segment line)
      An abstract method that splits a line up into tokens.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TokenMarker

        protected TokenMarker()
        Creates a new TokenMarker. This DOES NOT create a lineInfo array; an initial call to insertLines() does that.
    • Method Detail

      • markTokens

        @NotNull
        public @NotNull java.util.List<Token> markTokens​(@NotNull
                                                         @NotNull javax.swing.text.Segment line,
                                                         int lineIndex)
        A wrapper for the lower-level markTokensImpl method that is called to split a line up into tokens.
        Parameters:
        line - the line
        lineIndex - the line number
        Returns:
        the tokens
      • markTokensImpl

        protected abstract byte markTokensImpl​(byte token,
                                               @NotNull
                                               @NotNull javax.swing.text.Segment line)
        An abstract method that splits a line up into tokens. It should parse the line, and call addToken() to add syntax tokens to the token list. Then, it should return the initial token type for the next line.

        For example if the current line contains the start of a multi-line comment that doesn't end on that line, this method should return the comment token type so that it continues on the next line.

        Parameters:
        token - the initial token type for this line
        line - the line to be tokenized
        Returns:
        the initial token type for the next line
      • insertLines

        public void insertLines​(int index,
                                int lines)
        Informs the token marker that lines have been inserted into the document. This inserts a gap in the lineInfo array.
        Parameters:
        index - the first line number
        lines - the number of lines
      • deleteLines

        public void deleteLines​(int index,
                                int lines)
        Informs the token marker that line have been deleted from the document. This removes the lines in question from the lineInfo array.
        Parameters:
        index - the first line number
        lines - the number of lines
      • isNextLineRequested

        public boolean isNextLineRequested()
        Returns true if the next line should be repainted. This will return true after a line has been tokenized that starts a multi-line token that continues onto the next line.
      • addToken

        protected void addToken​(int length,
                                byte id)
        Adds a token to the token list.
        Parameters:
        length - the length of the token
        id - the id of the token