本文整理汇总了Java中org.fife.ui.rsyntaxtextarea.TokenImpl类的典型用法代码示例。如果您正苦于以下问题:Java TokenImpl类的具体用法?Java TokenImpl怎么用?Java TokenImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TokenImpl类属于org.fife.ui.rsyntaxtextarea包,在下文中一共展示了TokenImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetTokenList_identifierStart_LiteralBackQuote
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_identifierStart_LiteralBackQuote() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
String text = "foo`cat foo.txt`";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue(token.is(TokenTypes.IDENTIFIER, "foo"));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.LITERAL_BACKQUOTE, "`cat foo.txt`"));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例2: testGetTokenList_identifierStart_LiteralDoubleQuote
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_identifierStart_LiteralDoubleQuote() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
String text = "foo\"Hello world\"";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue(token.is(TokenTypes.IDENTIFIER, "foo"));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.LITERAL_STRING_DOUBLE_QUOTE, "\"Hello world\""));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例3: testGetTokenList_identifierStart_LiteralSingleQuote
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_identifierStart_LiteralSingleQuote() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
String text = "foo'Hello world'";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue(token.is(TokenTypes.IDENTIFIER, "foo"));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.LITERAL_CHAR, "'Hello world'"));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例4: testGetTokenList_nullStart_EscapedBackQuote
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_nullStart_EscapedBackQuote() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
// Parsed as two identifiers: '\\' and '`'
String text = "\\`";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue("Unexpected token type: " + token,
token.is(TokenTypes.IDENTIFIER, "\\"));
token = token.getNextToken();
Assert.assertTrue("Unexpected token type: " + token,
token.is(TokenTypes.IDENTIFIER, "`"));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例5: testGetTokenList_nullStart_EscapedDollarSign
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_nullStart_EscapedDollarSign() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
// Parsed as two identifiers: '\\' and '$'
String text = "\\$";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue("Unexpected token type: " + token,
token.is(TokenTypes.IDENTIFIER, "\\"));
token = token.getNextToken();
Assert.assertTrue("Unexpected token type: " + token,
token.is(TokenTypes.IDENTIFIER, "$"));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例6: testGetTokenList_nullStart_EscapedDoubleQuote
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_nullStart_EscapedDoubleQuote() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
// Parsed as two identifiers: '\\' and '"'
String text = "\\\"";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue("Unexpected token type: " + token,
token.is(TokenTypes.IDENTIFIER, "\\"));
token = token.getNextToken();
Assert.assertTrue("Unexpected token type: " + token,
token.is(TokenTypes.IDENTIFIER, "\""));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例7: testGetTokenList_nullStart_EscapedSingleQuote
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_nullStart_EscapedSingleQuote() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
// Parsed as two identifiers: '\\' and "'"
String text = "\\'";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue("Unexpected token type: " + token,
token.is(TokenTypes.IDENTIFIER, "\\"));
token = token.getNextToken();
Assert.assertTrue("Unexpected token type: " + token,
token.is(TokenTypes.IDENTIFIER, "'"));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例8: testGetTokenList_nullStart_Variable
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_nullStart_Variable() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
String text = "$PATH";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue(token.is(TokenTypes.VARIABLE, text));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
text = "${varName}";
s = createSegment(text);
token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue(token.is(TokenTypes.VARIABLE, text));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例9: testGetTokenList_whitespaceStart_EolComment
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_whitespaceStart_EolComment() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
String text = " # This is a comment";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue(token.isSingleChar(TokenTypes.WHITESPACE, ' '));
token = token.getNextToken();
Assert.assertTrue("Unexpected token type: " + token,
token.is(TokenTypes.COMMENT_EOL, text.trim()));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例10: testGetTokenList_whitespaceStart_LiteralBackQuote
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_whitespaceStart_LiteralBackQuote() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
String text = " `cat foo.txt`";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue(token.isSingleChar(TokenTypes.WHITESPACE, ' '));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.LITERAL_BACKQUOTE, text.trim()));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例11: testGetTokenList_whitespaceStart_LiteralDoubleQuote
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_whitespaceStart_LiteralDoubleQuote() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
String text = " \"Hello world\"";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue(token.isSingleChar(TokenTypes.WHITESPACE, ' '));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.LITERAL_STRING_DOUBLE_QUOTE, text.trim()));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例12: testGetTokenList_whitespaceStart_LiteralSingleQuote
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_whitespaceStart_LiteralSingleQuote() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
String text = " 'Hello world'";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue(token.isSingleChar(TokenTypes.WHITESPACE, ' '));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.LITERAL_CHAR, text.trim()));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例13: testGetTokenList_whitespaceStart_Variable
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_whitespaceStart_Variable() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
String text = " $PATH";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue(token.isSingleChar(TokenTypes.WHITESPACE, ' '));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.VARIABLE, text.trim()));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例14: getTokenList
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
/**
* Returns the first token in the linked list of tokens generated
* from <code>text</code>. This method must be implemented by
* subclasses so they can correctly implement syntax highlighting.
*
* @param text The text from which to get tokens.
* @param initialTokenType The token type we should start with.
* @param startOffset The offset into the document at which
* <code>text</code> starts.
* @return The first <code>Token</code> in a linked list representing
* the syntax highlighted text.
*/
public Token getTokenList(Segment text, int initialTokenType, int startOffset) {
resetTokenList();
this.offsetShift = -text.offset + startOffset;
// Start off in the proper state.
int state = Token.NULL;
switch (initialTokenType) {
case Token.LITERAL_STRING_DOUBLE_QUOTE:
state = LONG_STRING_2;
break;
case Token.LITERAL_CHAR:
state = LONG_STRING_1;
break;
default:
state = Token.NULL;
}
s = text;
try {
yyreset(zzReader);
yybegin(state);
return yylex();
} catch (IOException ioe) {
ioe.printStackTrace();
return new TokenImpl();
}
}
示例15: testGetTokenList_nullStart_EolComment
import org.fife.ui.rsyntaxtextarea.TokenImpl; //导入依赖的package包/类
@Test
public void testGetTokenList_nullStart_EolComment() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
String text = "# This is a comment";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue("Unexpected token type: " + token,
token.is(TokenTypes.COMMENT_EOL, text));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}