FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/app/src/processing/app/syntax/TokenMarker.java at master · processing/processing · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
processing
/
processing
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
1.5k
Star
6.5k
Code
Issues
0
Pull requests
0
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing
/
app
/
src
/
processing
/
app
/
syntax
/
TokenMarker.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
90 lines (78 loc) · 2.93 KB
Breadcrumbs
processing
/
app
/
src
/
processing
/
app
/
syntax
/
TokenMarker.java
Copy path
File metadata and controls
90 lines (78 loc) · 2.93 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* TokenMarker.java - Generic token marker
* Copyright (C) 1998, 1999 Slava Pestov
*
* You may use and modify this package for any purpose. Redistribution is
* permitted, in both source and binary form, provided that this notice
* remains intact in all source distributions of this package.
*/
package
processing
.
app
.
syntax
;
import
javax
.
swing
.
text
.
Segment
;
/**
* A token marker that splits lines of text into tokens. Each token carries
* a length field and an indentification tag that can be mapped to a color
* for painting that token.<p>
* <p>
* For performance reasons, the linked list of tokens is reused after each
* line is tokenized. Therefore, the return value of <code>markTokens</code>
* should only be used for immediate painting. Notably, it cannot be
* cached.
*
* @author Slava Pestov
*/
public
abstract
class
TokenMarker
{
public
interface
TokenListener
{
void
addToken
(
int
length
,
byte
id
);
}
// Only needed during markTokensImpl() call so addToken() can be forwarded
private
TokenListener
tokenListener
=
null
;
public
final
void
setTokenListener
(
TokenListener
listener
) {
this
.
tokenListener
=
listener
;
}
public
final
TokenMarkerState
createStateInstance
() {
return
new
TokenMarkerState
(
this
);
}
/**
* Creates a new <code>TokenMarker</code>. This DOES NOT create
* a lineInfo array; an initial call to <code>insertLines()</code>
* does that.
*/
protected
TokenMarker
() { }
abstract
public
void
addColoring
(
String
keyword
,
String
coloring
);
/**
* An abstract method that splits a line up into tokens. It
* should parse the line, and call <code>addToken()</code> to
* add syntax tokens to the token list. Then, it should return
* the initial token type for the next line.<p>
* <p>
* 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.
*
* @param token The initial token type for this line
* @param line The line to be tokenized
* @param lineIndex The index of the line in the document,
* starting at 0
* @return The initial token type for the next line
*/
protected
abstract
byte
markTokensImpl
(
byte
token
,
Segment
line
,
int
lineIndex
);
protected
final
void
addToken
(
int
length
,
byte
id
) {
if
(
tokenListener
!=
null
) {
tokenListener
.
addToken
(
length
,
id
);
}
}
/**
* Returns if the token marker supports tokens that span multiple
* lines. If this is true, the object using this token marker is
* required to pass all lines in the document to the
* <code>markTokens()</code> method (in turn).<p>
* <p>
* The default implementation returns true; it should be overridden
* to return false on simpler token markers for increased speed.
*/
public
boolean
supportsMultilineTokens
() {
return
true
;
}
}
Back
|
FazBrowse Home
|
New Git URL