|
org.netbeans.modules.lexer/2 1.35.1 1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.netbeans.spi.lexer.TokenFactory<T>
public final class TokenFactory<T extends TokenId>
Lexer should delegate all the token instances creation to this class.
It's not allowed to create empty tokens.
| Field Summary | |
|---|---|
static Token |
SKIP_TOKEN
Deprecated. Use isSkipToken(Token) instead. |
| Method Summary | |
|---|---|
Token<T> |
createCustomTextToken(T id,
CharSequence text,
int length,
PartType partType)
Deprecated. This method is deprecated without replacement - see description how a similar effect can be obtained. |
Token<T> |
createPropertyToken(T id,
int length,
TokenPropertyProvider<T> propertyProvider)
Create complete token with properties. |
Token<T> |
createPropertyToken(T id,
int length,
TokenPropertyProvider<T> propertyProvider,
PartType partType)
Create token with properties. |
Token<T> |
createToken(T id)
Create token with token length corresponding to the number of characters read from the lexer input. |
Token<T> |
createToken(T id,
int length)
Create regular token instance with an explicit length. |
Token<T> |
createToken(T id,
int length,
PartType partType)
Create regular token instance with an explicit length and part type. |
Token<T> |
getFlyweightToken(T id,
String text)
Get flyweight token for the given arguments. |
boolean |
isSkipToken(Token<T> token)
Check whether a token (produced by one of the token creation methods) is a special flyweight token used in cases when there is an active filtering of certain token ids (e.g. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Token SKIP_TOKEN
isSkipToken(Token) instead.isSkipToken(Token) is a better typed alternative
to this field.
| Method Detail |
|---|
public Token<T> createToken(T id)
createToken(TokenId, int)
public Token<T> createToken(T id,
int length)
id - non-null token id recognized by the lexer.length - >=0 length of the token to be created. The length must not
exceed the number of characters read from the lexer input.
SKIP_TOKEN will be returned
if tokens for the given token id should be skipped
because of token id filter.
public Token<T> createToken(T id,
int length,
PartType partType)
id - non-null token id recognized by the lexer.length - >=0 length of the token to be created. The length must not
exceed the number of characters read from the lexer input.partType - whether this token is complete token or a part of a complete token.
SKIP_TOKEN will be returned
if tokens for the given token id should be skipped
because of token id filter.
public Token<T> getFlyweightToken(T id,
String text)
id - non-null token id.text - non-null text that the flyweight token should carry.
SKIP_TOKEN will be returned
if tokens for the given token id should be skipped
because of token id filter.
public Token<T> createPropertyToken(T id,
int length,
TokenPropertyProvider<T> propertyProvider)
id - non-null token id.length - >=0 length of the token to be created. The length must not
exceed the number of characters read from the lexer input.propertyProvider - token property provider or null if there are no extra properties.
See TokenPropertyProvider for examples how this parameter may be used.
SKIP_TOKEN will be returned
if tokens for the given token id should be skipped
because of token id filter.
public Token<T> createPropertyToken(T id,
int length,
TokenPropertyProvider<T> propertyProvider,
PartType partType)
id - non-null token id.length - >=0 length of the token to be created. The length must not
exceed the number of characters read from the lexer input.propertyProvider - token property provider or null if there are no extra properties.
See TokenPropertyProvider for examples how this parameter may be used.partType - whether this token is complete or just a part of complete token.
Null may be passed which implies PartType.COMPLETE.
SKIP_TOKEN will be returned
if tokens for the given token id should be skipped
because of token id filter.
public Token<T> createCustomTextToken(T id,
CharSequence text,
int length,
PartType partType)
StripFirstAndLastCharTokenPropertyProvider implements TokenPropertyProvider {
public TokenPropertyProvider INSTANCE = new StripFirstAndLastCharTokenPropertyProvider();
public Object getValue(Token token, Object key) {
if (key == CharSequence.class) {
return token.text().subSequence(1, token.length() - 1);
}
return null;
}
}
id - non-null token id of the token being created.text - non-null custom text assigned to the token.length - recognized characters corresponding to the token being created.partType - should always be null otherwise this method would throw
an exception.public boolean isSkipToken(Token<T> token)
token - non-null token.
|
org.netbeans.modules.lexer/2 1.35.1 1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||