|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.javatools.editor.language.LexerDocumentRenderer.LexerOffsetsCache
The LexerOffsetsCache
provides rapid access for
offsets that correspond to the start of a language token. This is
used primarily for rendering purposes to speed up painting of
arbitrary regions in the document. This is done by maintaining a
boolean bitmap representing the lines of the document. A value of
"true" in the bitmap corresponds to the presence (start, middle or
end) of a multi-line token in the given line of the document. Note
that this is only based on the "type" of the token, not whether it
actually occupies multiple lines. This information allows us to
rapidly determine which line of the document we can start scanning
from in order to render some portion of the document.
This class is primarily just a utility class - it is up to users of
this class (such as the LexerDocumentRenderer) to bear responsibility
for maintaining this cache. When the document is modified, the
style provider (or maintainer of this class) must call
invalidateOffsets()
to invalidate old, potentially
incorrect cached information.
Note that this implementation makes the assumption that changes (inserts or removes) in a given line will have no affect on tokens in previous lines except possibly to lengthen or shorten a token.
Specifically, suppose token A is token in line A (though token A may not necessarily end or start on line A), and line B is a line after line A (not necessarily immediately.) The implementation assumption is that changes in line B will have no affect on the starting offset of any token A and any line A that occur before line B (though the change may affect the end offset of token A.)
If the syntax of your language you wish to render does not fit this assumption, then you will not be able to use this cache implementation.
Constructor Summary | |
LexerDocumentRenderer.LexerOffsetsCache(LexerDocumentRenderer documentRenderer)
Constructs a new LexerOffsetsCache for the given style provider. |
Method Summary | |
int |
findClosestOffset(Lexer lexer,
LexerToken lexerToken,
int offset)
Find the closest offset in the buffer we can start scanning from that occurs at or before the indicated offset. |
void |
invalidateOffsets(int startOffset)
Invalidates all offsets larger than or equal to the given offset. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public LexerDocumentRenderer.LexerOffsetsCache(LexerDocumentRenderer documentRenderer)
documentRenderer
- the document renderer which mantains this cacheMethod Detail |
public int findClosestOffset(Lexer lexer, LexerToken lexerToken, int offset)
lexer
- the (scratch) lexer to uselexerToken
- the lexer token to useoffset
- the maximum offset to find
public void invalidateOffsets(int startOffset)
startOffset
- minimum offset to remove from the cache
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.