Class StructuredSyntaxDocumentFilter

  • Direct Known Subclasses:
    GroovyFilter

    public class StructuredSyntaxDocumentFilter
    extends javax.swing.text.DocumentFilter
    • Constructor Summary

      Constructors 
      Constructor Description
      StructuredSyntaxDocumentFilter​(javax.swing.text.DefaultStyledDocument document)
      Creates a new instance of StructuredSyntaxDocumentFilter
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      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​(javax.swing.text.DocumentFilter.FilterBypass fb, int offset, java.lang.String text, javax.swing.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​(javax.swing.text.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​(javax.swing.text.DocumentFilter.FilterBypass fb, int offset, int length, java.lang.String text, javax.swing.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 Detail

      • styledDocument

        protected javax.swing.text.DefaultStyledDocument styledDocument
      • mlTextRunSet

        protected java.util.SortedSet mlTextRunSet
        The position tree of multi-line comments.
    • Constructor Detail

      • StructuredSyntaxDocumentFilter

        public StructuredSyntaxDocumentFilter​(javax.swing.text.DefaultStyledDocument document)
        Creates a new instance of StructuredSyntaxDocumentFilter
        Parameters:
        document - the styled document to parse
    • Method Detail

      • 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​(javax.swing.text.DocumentFilter.FilterBypass fb,
                                 int offset,
                                 java.lang.String text,
                                 javax.swing.text.AttributeSet attrs)
                          throws javax.swing.text.BadLocationException
        Insert a string into the document, and then parse it if the parser has been set.
        Overrides:
        insertString in class javax.swing.text.DocumentFilter
        Parameters:
        fb -
        offset -
        text -
        attrs -
        Throws:
        javax.swing.text.BadLocationException
      • parseDocument

        protected void parseDocument​(int offset,
                                     int length)
                              throws javax.swing.text.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:
        javax.swing.text.BadLocationException
      • remove

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

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