Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

oracle.javatools.editor.language
Class LexerDocumentRenderer

java.lang.Object
  extended by oracle.javatools.editor.language.AbstractDocumentRenderer
      extended by oracle.javatools.editor.language.LexerDocumentRenderer
All Implemented Interfaces:
DocumentRenderer

public abstract class LexerDocumentRenderer
extends AbstractDocumentRenderer

An LexerDocumentRenderer is the abstact starting point for DocumentRenderers implementations based on languages that have Lexer implementations available for tokenizing the language. This takes care of common functionality with the usage of the Lexer.

See Also:
AbstractDocumentRenderer, BlockRenderer, DocumentRenderer, Lexer

Nested Class Summary
static class LexerDocumentRenderer.LexerOffsetsCache
          The LexerOffsetsCache provides rapid access for offsets that correspond to the start of a language token.
 
Field Summary
protected  BlockRenderer blockRenderer
          The block renderer used for rendering.
protected  Lexer lexer
          The Lexer that is used for tokenizing.
protected  LexerToken lexerToken
          The LexerToken structure for interfacing with the Lexer.
protected  LexerDocumentRenderer.LexerOffsetsCache offsetsCache
          The offsets cache to quickly locate token start offsets.
 
Constructor Summary
LexerDocumentRenderer(LanguageSupport support)
          Constructs a new style provider for the specified document.
 
Method Summary
 void calculateDamage(javax.swing.event.DocumentEvent changes, NumberRange damageRange)
          Calculates what range of the document is "damaged" or needs to be repainted based on a given insert or removal of text.
protected abstract  BlockRenderer createBlockRenderer()
          Creates a BlockRenderer used for rendering the tokens in the primary language of this specific DocumentRenderer implementation.
protected abstract  Lexer createLexer()
          Creates a Lexer used for breaking apart tokens in the primary language of the specific DocumentRenderer implementation
protected  BlockRenderer getBlockRenderer()
          Get a cached block renderer (so that we don't have to keep recreating it.)
protected  Lexer getLexer()
          Get a cached language-specific Lexer (so that we don't have to constantly recreate it every time.)
protected  LexerToken getLexerToken()
          Get a cached lexer-specific LexerToken (that we don't have to recreate every time) from the Lexer.
 LexerDocumentRenderer.LexerOffsetsCache getOffsetsCache()
          Fetches a LexerOffsetsCache that we can use to speed up the location of token starts for the purposes of rendering.
abstract  boolean isMultiLineToken(int token)
          Determines whether the given token can potentially extend across line boundaries in the primary language of the style provider.
 void notifyUpdate(javax.swing.event.DocumentEvent changes)
          Notifies the DocumentRenderer that the given document has been updated - this allows DocumentRenderers which cache offset information to update or invalidate their cache.
 void renderRegion(StyledFragmentsList fragmentsList, int startOffset, int endOffset)
          Renders the region of text bounded by the given offsets.
 
Methods inherited from class oracle.javatools.editor.language.AbstractDocumentRenderer
allocateFragmentsList, getDocument, getLineMap, getTextBuffer, recycleFragmentsList, renderLines
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

offsetsCache

protected LexerDocumentRenderer.LexerOffsetsCache offsetsCache
The offsets cache to quickly locate token start offsets.


blockRenderer

protected BlockRenderer blockRenderer
The block renderer used for rendering.


lexer

protected Lexer lexer
The Lexer that is used for tokenizing.


lexerToken

protected LexerToken lexerToken
The LexerToken structure for interfacing with the Lexer.

Constructor Detail

LexerDocumentRenderer

public LexerDocumentRenderer(LanguageSupport support)
Constructs a new style provider for the specified document.

Parameters:
support - the language support
Method Detail

createBlockRenderer

protected abstract BlockRenderer createBlockRenderer()
Creates a BlockRenderer used for rendering the tokens in the primary language of this specific DocumentRenderer implementation.

Returns:
a BlockRenderer as the primary renderer to use

getBlockRenderer

protected final BlockRenderer getBlockRenderer()
Get a cached block renderer (so that we don't have to keep recreating it.)

Returns:
the block-renderer to use

createLexer

protected abstract Lexer createLexer()
Creates a Lexer used for breaking apart tokens in the primary language of the specific DocumentRenderer implementation

Returns:
the language-specific lexer

getLexer

protected final Lexer getLexer()
Get a cached language-specific Lexer (so that we don't have to constantly recreate it every time.)

Returns:
the language-specific lexer

getLexerToken

protected final LexerToken getLexerToken()
Get a cached lexer-specific LexerToken (that we don't have to recreate every time) from the Lexer.

Returns:
a Lexer-specific LexerToken

getOffsetsCache

public LexerDocumentRenderer.LexerOffsetsCache getOffsetsCache()
Fetches a LexerOffsetsCache that we can use to speed up the location of token starts for the purposes of rendering. This abstract class takes care of invalidating old offsets in notifyUpdate().

Returns:
an offsets cache

isMultiLineToken

public abstract boolean isMultiLineToken(int token)
Determines whether the given token can potentially extend across line boundaries in the primary language of the style provider.

Parameters:
token - the token to check
Returns:
true if this token can extend across line boundaries

renderRegion

public void renderRegion(StyledFragmentsList fragmentsList,
                         int startOffset,
                         int endOffset)
Renders the region of text bounded by the given offsets. The styles generated should be added (appended) to the provided fragments list.

Specified by:
renderRegion in class AbstractDocumentRenderer
Parameters:
fragmentsList - the styled fragments list to added our styles to
startOffset - the starting offset to render from (inclusive)
endOffset - the ending offset to render to (exclusive)

calculateDamage

public void calculateDamage(javax.swing.event.DocumentEvent changes,
                            NumberRange damageRange)
Calculates what range of the document is "damaged" or needs to be repainted based on a given insert or removal of text. We override this to do our own custom damage calculations.

Specified by:
calculateDamage in interface DocumentRenderer
Overrides:
calculateDamage in class AbstractDocumentRenderer
Parameters:
changes - the document event indicating what changed
damageRange - the number range to return the damage range in

notifyUpdate

public void notifyUpdate(javax.swing.event.DocumentEvent changes)
Notifies the DocumentRenderer that the given document has been updated - this allows DocumentRenderers which cache offset information to update or invalidate their cache.

Specified by:
notifyUpdate in interface DocumentRenderer
Overrides:
notifyUpdate in class AbstractDocumentRenderer
Parameters:
changes - the document event indicating what changed

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

Copyright © 1997, 2009, Oracle. All rights reserved.