11 package net.sf.gridarta.textedit.textarea.tokenmarker;
13 import java.util.LinkedList;
14 import java.util.List;
15 import javax.swing.text.Segment;
17 import org.jetbrains.annotations.Nullable;
36 private final List<Token>
tokens =
new LinkedList<>();
68 public List<Token>
markTokens(
final Segment line,
final int lineIndex) {
69 if (lineIndex >= length) {
70 throw new IllegalArgumentException(
"Tokenizing invalid line: " + lineIndex);
75 final LineInfo info = lineInfo[lineIndex];
80 prev = lineInfo[lineIndex - 1];
83 final byte oldToken = info.
getToken();
126 if (!(lastLine == lineIndex && nextLineRequested)) {
127 nextLineRequested = oldToken != token;
130 lastLine = lineIndex;
161 final int len = index + lines;
162 System.arraycopy(lineInfo, index, lineInfo, len, lineInfo.length - len);
164 for (
int i = index + lines - 1; i >= index; i--) {
179 final int len = index + lines;
181 System.arraycopy(lineInfo, len, lineInfo, index, lineInfo.length - len);
212 if (lineInfo == null) {
214 }
else if (lineInfo.length <= index) {
216 System.arraycopy(lineInfo, 0, lineInfoN, 0, lineInfo.length);
217 lineInfo = lineInfoN;
226 protected void addToken(
final int length,
final byte
id) {
228 throw new InternalError(
"Invalid id: " +
id);
235 tokens.add(
new Token(length,
id));
int length
The number of lines in the model being tokenized.
void insertLines(final int index, final int lines)
Informs the token marker that lines have been inserted into the document.
TokenMarker()
Creates a new.
void deleteLines(final int index, final int lines)
Informs the token marker that line have been deleted from the document.
static final byte INTERNAL_FIRST
The first id that can be used for internal state in a token marker.
Stores information about tokenized lines.
final List< Token > tokens
The collected tokens.
boolean nextLineRequested
True if the next line should be painted.
void addToken(final int length, final byte id)
Adds a token to the token list.
int lastLine
The last tokenized line.
Base package of all Gridarta classes.
void ensureCapacity(final int index)
Ensures that the.
LineInfo [] lineInfo
An array for storing information about lines.
abstract byte markTokensImpl(byte token, Segment line)
An abstract method that splits a line up into tokens.
This package contains the other part of the script editor.
List< Token > markTokens(final Segment line, final int lineIndex)
A wrapper for the lower-level.
static final byte NULL
Normal text token id.
A token marker that splits lines of text into tokens.
static final byte INTERNAL_LAST
The last id that can be used for internal state in a token marker.
void setToken(final byte token)
boolean isNextLineRequested()
Returns true if the next line should be repainted.