Class DefaultDamagerRepairer2

  • All Implemented Interfaces:
    org.eclipse.jface.text.presentation.IPresentationDamager, org.eclipse.jface.text.presentation.IPresentationRepairer

    public class DefaultDamagerRepairer2
    extends java.lang.Object
    implements org.eclipse.jface.text.presentation.IPresentationDamager, org.eclipse.jface.text.presentation.IPresentationRepairer
    A standard implementation of a syntax driven presentation damager and presentation repairer. It uses a token scanner to scan the document and to determine its damage and new text presentation. The tokens returned by the scanner are supposed to return text attributes as their data.
    Since:
    2.0
    See Also:
    ITokenScanner
    • Field Summary

      Fields 
      Modifier and Type Field Description
      org.eclipse.jface.text.TextAttribute fDefaultTextAttribute
      The default text attribute if non is returned as data by the current token
      protected org.eclipse.jface.text.IDocument fDocument
      The document this object works on
      protected org.eclipse.jface.text.rules.ITokenScanner fScanner
      The scanner it uses
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultDamagerRepairer2​(org.eclipse.jface.text.rules.ITokenScanner scanner)
      Creates a damager/repairer that uses the given scanner.
      DefaultDamagerRepairer2​(org.eclipse.jface.text.rules.ITokenScanner scanner, org.eclipse.jface.text.TextAttribute defaultTextAttribute)
      Deprecated.
      use DefaultDamagerRepairer(ITokenScanner) instead
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addRange​(org.eclipse.jface.text.TextPresentation presentation, int offset, int length, org.eclipse.jface.text.TextAttribute attr)
      Adds style information to the given text presentation.
      void createPresentation​(org.eclipse.jface.text.TextPresentation presentation, org.eclipse.jface.text.ITypedRegion region)  
      protected int endOfLineOf​(int offset)
      Returns the end offset of the line that contains the specified offset or if the offset is inside a line delimiter, the end offset of the next line.
      org.eclipse.jface.text.IRegion getDamageRegion​(org.eclipse.jface.text.ITypedRegion partition, org.eclipse.jface.text.DocumentEvent e, boolean documentPartitioningChanged)  
      protected org.eclipse.jface.text.TextAttribute getTokenTextAttribute​(org.eclipse.jface.text.rules.IToken token)
      Returns a text attribute encoded in the given token.
      void setDocument​(org.eclipse.jface.text.IDocument document)  
      • Methods inherited from class java.lang.Object

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

      • fDocument

        protected org.eclipse.jface.text.IDocument fDocument
        The document this object works on
      • fScanner

        protected org.eclipse.jface.text.rules.ITokenScanner fScanner
        The scanner it uses
      • fDefaultTextAttribute

        public org.eclipse.jface.text.TextAttribute fDefaultTextAttribute
        The default text attribute if non is returned as data by the current token
    • Constructor Detail

      • DefaultDamagerRepairer2

        @Deprecated
        public DefaultDamagerRepairer2​(org.eclipse.jface.text.rules.ITokenScanner scanner,
                                       org.eclipse.jface.text.TextAttribute defaultTextAttribute)
        Deprecated.
        use DefaultDamagerRepairer(ITokenScanner) instead
        Creates a damager/repairer that uses the given scanner and returns the given default text attribute if the current token does not carry a text attribute.
        Parameters:
        scanner - the token scanner to be used
        defaultTextAttribute - the text attribute to be returned if non is specified by the current token, may not be null
      • DefaultDamagerRepairer2

        public DefaultDamagerRepairer2​(org.eclipse.jface.text.rules.ITokenScanner scanner)
        Creates a damager/repairer that uses the given scanner. The scanner may not be null and is assumed to return only token that carry text attributes.
        Parameters:
        scanner - the token scanner to be used, may not be null
    • Method Detail

      • setDocument

        public void setDocument​(org.eclipse.jface.text.IDocument document)
        Specified by:
        setDocument in interface org.eclipse.jface.text.presentation.IPresentationDamager
        Specified by:
        setDocument in interface org.eclipse.jface.text.presentation.IPresentationRepairer
      • endOfLineOf

        protected int endOfLineOf​(int offset)
                           throws org.eclipse.jface.text.BadLocationException
        Returns the end offset of the line that contains the specified offset or if the offset is inside a line delimiter, the end offset of the next line.
        Parameters:
        offset - the offset whose line end offset must be computed
        Returns:
        the line end offset for the given offset
        Throws:
        org.eclipse.jface.text.BadLocationException - if offset is invalid in the current document
      • getDamageRegion

        public org.eclipse.jface.text.IRegion getDamageRegion​(org.eclipse.jface.text.ITypedRegion partition,
                                                              org.eclipse.jface.text.DocumentEvent e,
                                                              boolean documentPartitioningChanged)
        Specified by:
        getDamageRegion in interface org.eclipse.jface.text.presentation.IPresentationDamager
      • createPresentation

        public void createPresentation​(org.eclipse.jface.text.TextPresentation presentation,
                                       org.eclipse.jface.text.ITypedRegion region)
        Specified by:
        createPresentation in interface org.eclipse.jface.text.presentation.IPresentationRepairer
      • getTokenTextAttribute

        protected org.eclipse.jface.text.TextAttribute getTokenTextAttribute​(org.eclipse.jface.text.rules.IToken token)
        Returns a text attribute encoded in the given token. If the token's data is not null and a text attribute it is assumed that it is the encoded text attribute. It returns the default text attribute if there is no encoded text attribute found.
        Parameters:
        token - the token whose text attribute is to be determined
        Returns:
        the token's text attribute
      • addRange

        protected void addRange​(org.eclipse.jface.text.TextPresentation presentation,
                                int offset,
                                int length,
                                org.eclipse.jface.text.TextAttribute attr)
        Adds style information to the given text presentation.
        Parameters:
        presentation - the text presentation to be extended
        offset - the offset of the range to be styled
        length - the length of the range to be styled
        attr - the attribute describing the style of the range to be styled