|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.editor.tokenmarker.TokenMarker
public abstract class TokenMarker
A token marker splits lines of text into tokens. Each token carries a length field and an identification tag that can be mapped to a color for painting that token.
For performance reasons, the linked list of tokens is reused after each line is tokenized. Therefore, the return value of
markTokens
should only be used for immediate painting. Notably, it cannot be cached.
Token
Nested Class Summary | |
---|---|
class |
TokenMarker.LineInfo
Deprecated. replaced by a byte array and an Object array in TokenMarker to reduce memory usage. |
Field Summary | |
---|---|
protected Object[] |
_lineInfoExtended
An array for storing other information about lines. |
protected byte[] |
_lineInfoToken
An array for storing token information about lines. |
protected Token[] |
_tokens
Token array to contain firstToken and lastToken so that the token marker process is thread safe. |
protected Token |
firstToken
Deprecated. replaced by the first element of _tokens |
protected int |
lastLine
The last tokenized line. |
protected Token |
lastToken
Deprecated. replaced by the second element of _tokens |
protected int |
length
The number of lines in the model being tokenized. |
protected TokenMarker.LineInfo[] |
lineInfo
Deprecated. replaced by _lineInfoToken && _lineInfoExtended to reduce memory usage. |
protected boolean |
nextLineRequested
True if the next line should be painted. |
Constructor Summary | |
---|---|
protected |
TokenMarker()
Creates a new TokenMarker . |
Method Summary | |
---|---|
protected void |
addToken(int length,
byte id)
Adds a token to the token list. |
void |
deleteLines(int index,
int lines)
Informs the token marker that line have been deleted from the document. |
protected void |
ensureCapacity(int index)
Ensures that the _lineInfoToken array can contain the specified index. |
SyntaxDocument |
getDocument()
Get the document the TokenMarker is parsing. |
byte |
getLastToken(int lineIndex)
Get the last token of the line. |
int |
getLineCount()
Returns the number of lines in this token marker. |
void |
insertLines(int index,
int lines)
Informs the token marker that lines have been inserted into the document. |
boolean |
isNextLineRequested()
Returns true if the next line should be repainted. |
Token |
markTokens(Segment line,
int lineIndex)
A wrapper for the lower-level markTokensImpl method that is called to split a line up into tokens. |
protected abstract byte |
markTokensImpl(byte token,
Segment line,
int lineIndex)
An abstract method that splits a line up into tokens. |
void |
setDocument(SyntaxDocument document)
Set the document the TokenMarker is parsing. |
boolean |
supportsMultilineTokens()
Returns if the token marker supports tokens that span multiple lines. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@Deprecated protected Token firstToken
_tokens
markTokens()
.
@Deprecated protected Token lastToken
_tokens
protected final Token[] _tokens
@Deprecated protected TokenMarker.LineInfo[] lineInfo
_lineInfoToken
&& _lineInfoExtended
to reduce memory usage.insertLines()
and deleteLines()
methods.
protected byte[] _lineInfoToken
insertLines()
and deleteLines()
methods.
protected Object[] _lineInfoExtended
insertLines()
and deleteLines()
methods.
protected int length
_lineInfoToken
array.
protected int lastLine
protected boolean nextLineRequested
Constructor Detail |
---|
protected TokenMarker()
TokenMarker
. This DOES NOT create a _lineInfoToken array; an initial call to
insertLines()
does that.
Method Detail |
---|
public Token markTokens(Segment line, int lineIndex)
markTokensImpl
method that is called to split a line up into tokens.
line
- The linelineIndex
- The line number
public byte getLastToken(int lineIndex)
lineIndex
- the line index
protected abstract byte markTokensImpl(byte token, Segment line, int lineIndex)
addToken()
to add syntax tokens to the token list. Then, it should return the initial token type for the next line.For example if the current line contains the start of a multiline comment that doesn't end on that line, this method should return the comment token type so that it continues on the next line.
token
- The initial token type for this lineline
- The line to be tokenizedlineIndex
- The index of the line in the document, starting at 0
public boolean supportsMultilineTokens()
markTokens()
method (in turn).The default implementation returns true; it should be overridden to return false on simpler token markers for increased speed.
public void insertLines(int index, int lines)
_lineInfoToken
array.
index
- The first line numberlines
- The number of linespublic void deleteLines(int index, int lines)
_lineInfoToken
array.
index
- The first line numberlines
- The number of linespublic int getLineCount()
public boolean isNextLineRequested()
protected void ensureCapacity(int index)
_lineInfoToken
array can contain the specified index. This enlarges it if
necessary. No action is taken if the array is large enough already.It should be unnecessary to call this under normal circumstances;
insertLine()
should take care of
enlarging the line info array automatically.
index
- The array indexprotected void addToken(int length, byte id)
length
- The length of the tokenid
- The id of the tokenpublic SyntaxDocument getDocument()
public void setDocument(SyntaxDocument document)
SyntaxDocument.setTokenMarker(TokenMarker)
.
You should always invoke that method to build correct relationship between SyntaxDocument and TokenMarker.
document
- the document
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |