Package org.eclipse.jface.text.rules
Class DefaultDamagerRepairer
java.lang.Object
org.eclipse.jface.text.rules.DefaultDamagerRepairer
- All Implemented Interfaces:
- IPresentationDamager,- IPresentationRepairer
- Direct Known Subclasses:
- RuleBasedDamagerRepairer
public class DefaultDamagerRepairer
extends Object
implements IPresentationDamager, 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:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected TextAttributeThe default text attribute if non is returned as data by the current tokenprotected IDocumentThe document this object works onprotected ITokenScannerThe scanner it uses
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultDamagerRepairer(ITokenScanner scanner) Creates a damager/repairer that uses the given scanner.DefaultDamagerRepairer(ITokenScanner scanner, TextAttribute defaultTextAttribute) Deprecated.use DefaultDamagerRepairer(ITokenScanner) instead
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddRange(TextPresentation presentation, int offset, int length, TextAttribute attr) Adds style information to the given text presentation.voidcreatePresentation(TextPresentation presentation, ITypedRegion region) Fills the given presentation with the style ranges which when applied to the presentation reconciler's text viewer repair the presentation damage described by the given region.protected intendOfLineOf(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.getDamageRegion(ITypedRegion partition, DocumentEvent e, boolean documentPartitioningChanged) Returns the damage in the document's presentation caused by the given document change.protected TextAttributegetTokenTextAttribute(IToken token) Returns a text attribute encoded in the given token.voidsetDocument(IDocument document) Tells the presentation damager on which document it will work.
- 
Field Details- 
fDocumentThe document this object works on
- 
fScannerThe scanner it uses
- 
fDefaultTextAttributeThe default text attribute if non is returned as data by the current token
 
- 
- 
Constructor Details- 
DefaultDamagerRepairer@Deprecated public DefaultDamagerRepairer(ITokenScanner scanner, TextAttribute defaultTextAttribute) Deprecated.use DefaultDamagerRepairer(ITokenScanner) insteadCreates 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
 
- 
DefaultDamagerRepairerCreates a damager/repairer that uses the given scanner. The scanner may not benulland is assumed to return only token that carry text attributes.- Parameters:
- scanner- the token scanner to be used, may not be- null
 
 
- 
- 
Method Details- 
setDocumentDescription copied from interface:IPresentationDamagerTells the presentation damager on which document it will work.- Specified by:
- setDocumentin interface- IPresentationDamager
- Specified by:
- setDocumentin interface- IPresentationRepairer
- Parameters:
- document- the damager's working document
 
- 
endOfLineOfReturns 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:
- BadLocationException- if offset is invalid in the current document
 
- 
getDamageRegionpublic IRegion getDamageRegion(ITypedRegion partition, DocumentEvent e, boolean documentPartitioningChanged) Returns the damage in the document's presentation caused by the given document change. The damage is restricted to the specified partition for which the presentation damager is responsible. The damage may also depend on whether the document change also caused changes of the document's partitioning.This implementation damages entire lines unless clipped by the given partition. - Specified by:
- getDamageRegionin interface- IPresentationDamager
- Parameters:
- partition- the partition inside which the damage must be determined
- e- the event describing the change whose damage must be determined
- documentPartitioningChanged- indicates whether the given change changed the document's partitioning
- Returns:
- the full lines containing the document changes described by the document event, clipped by the given partition. If there was a partitioning change then the whole partition is returned.
 
- 
createPresentationDescription copied from interface:IPresentationRepairerFills the given presentation with the style ranges which when applied to the presentation reconciler's text viewer repair the presentation damage described by the given region.- Specified by:
- createPresentationin interface- IPresentationRepairer
- Parameters:
- presentation- the text presentation to be filled by this repairer
- region- the damage to be repaired
 
- 
getTokenTextAttributeReturns a text attribute encoded in the given token. If the token's data is notnulland 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
 
- 
addRangeAdds 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
 
 
-