Package groovy.console.ui.text

# Class StructuredSyntaxDocumentFilter

java.lang.Object
javax.swing.text.DocumentFilter
groovy.console.ui.text.StructuredSyntaxDocumentFilter

Direct Known Subclasses:
  `GroovyFilter`

public class StructuredSyntaxDocumentFilter extends DocumentFilter
Document filter that applies regex-driven syntax highlighting to styled text.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `final class`
  `StructuredSyntaxDocumentFilter.LexerNode`
  Regex-driven lexer node that applies styles and nested lexers.
  `protected class`
  `StructuredSyntaxDocumentFilter.MultiLineRun`
  Tracks a multi-line styled region within the document.

  ## Nested classes/interfaces inherited from class javax.swing.text.DocumentFilter

  `DocumentFilter.FilterBypass`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected StructuredSyntaxDocumentFilter.LexerNode`
  `lexer`
  The root of the lexical parsing tree.
  `protected SortedSet<Object>`
  `mlTextRunSet`
  The position tree of multi-line comments.
  `protected DefaultStyledDocument`
  `styledDocument`
  The styled document currently being parsed.
  `static final String`
  `TAB_REPLACEMENT`
  Spaces inserted in place of tab characters.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StructuredSyntaxDocumentFilter(DefaultStyledDocument document)`
  Creates a new instance of StructuredSyntaxDocumentFilter

- ## Method Summary

  Modifier and Type
  Method
  Description
  `StructuredSyntaxDocumentFilter.LexerNode`
  `createLexerNode()`
  Create a new LexerNode for adding to root.
  `StructuredSyntaxDocumentFilter.LexerNode`
  `getRootNode()`
  Get the root node for lexing the document.
  `void`
  `insertString(DocumentFilter.FilterBypass fb, int offset, String text, AttributeSet attrs)`
  Insert a string into the document, and then parse it if the parser has been set.
  `protected void`
  `parseDocument(int offset, int length)`
  Parse the Document to update the character styles given an initial start position.
  `void`
  `remove(DocumentFilter.FilterBypass fb, int offset, int length)`
  Remove a string from the document, and then parse it if the parser has been set.
  `void`
  `replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs)`
  Replace a string in the document, and then parse it if the parser has been set.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### TAB_REPLACEMENT

    public static final String TAB_REPLACEMENT
    Spaces inserted in place of tab characters.
    See Also:
      - Constant Field Values

  - ### lexer

    protected StructuredSyntaxDocumentFilter.LexerNode lexer
    The root of the lexical parsing tree.

  - ### styledDocument

    protected DefaultStyledDocument styledDocument
    The styled document currently being parsed.

  - ### mlTextRunSet

    protected SortedSet<Object> mlTextRunSet
    The position tree of multi-line comments.

- ## Constructor Details

  - ### StructuredSyntaxDocumentFilter

    public StructuredSyntaxDocumentFilter(DefaultStyledDocument document)
    Creates a new instance of StructuredSyntaxDocumentFilter
    Parameters:
      `document` - the styled document to parse

- ## Method Details

  - ### createLexerNode

    public StructuredSyntaxDocumentFilter.LexerNode createLexerNode()
    Create a new LexerNode for adding to root.
    Returns:
      a new LexerNode

  - ### getRootNode

    public StructuredSyntaxDocumentFilter.LexerNode getRootNode()
    Get the root node for lexing the document. Children can be added such that matching patterns can be further parsed if required.
    Returns:
      the root lexing node.

  - ### insertString

    public void insertString(DocumentFilter.FilterBypass fb, int offset, String text, AttributeSet attrs) throws BadLocationException
    Insert a string into the document, and then parse it if the parser has been set.
    Overrides:
      `insertString` in class `DocumentFilter`
    Parameters:
      `fb` -
      `offset` -
      `text` -
      `attrs` -
    Throws:
      `BadLocationException`

  - ### parseDocument

    protected void parseDocument(int offset, int length) throws BadLocationException
    Parse the Document to update the character styles given an initial start position. Called by the filter after it has updated the text.
    Parameters:
      `offset` -
      `length` -
    Throws:
      `BadLocationException`

  - ### remove

    public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException
    Remove a string from the document, and then parse it if the parser has been set.
    Overrides:
      `remove` in class `DocumentFilter`
    Parameters:
      `fb` -
      `offset` -
      `length` -
    Throws:
      `BadLocationException`

  - ### replace

    public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException
    Replace a string in the document, and then parse it if the parser has been set.
    Overrides:
      `replace` in class `DocumentFilter`
    Parameters:
      `fb` -
      `offset` -
      `length` -
      `text` -
      `attrs` -
    Throws:
      `BadLocationException`