本文整理汇总了Java中org.fife.ui.rsyntaxtextarea.Token.getNextToken方法的典型用法代码示例。如果您正苦于以下问题:Java Token.getNextToken方法的具体用法?Java Token.getNextToken怎么用?Java Token.getNextToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fife.ui.rsyntaxtextarea.Token
的用法示例。
在下文中一共展示了Token.getNextToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testKeywords
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testKeywords() {
String code = "127.0.0.1 localhost";
Segment segment = createSegment(code);
TokenMaker tm = createTokenMaker();
Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
Assert.assertTrue(token.is(TokenTypes.RESERVED_WORD, "127.0.0.1"));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.WHITESPACE, " "));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.IDENTIFIER, "localhost"));
}
示例2: testOperators
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testOperators() {
String code = "| > >>";
Segment segment = createSegment(code);
TokenMaker tm = createTokenMaker();
Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
String[] keywords = code.split(" +");
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], token.getLexeme());
Assert.assertEquals("Not an operator: " + token, TokenTypes.OPERATOR, token.getType());
if (i < keywords.length - 1) {
token = token.getNextToken();
Assert.assertTrue("Not a whitespace token: " + token, token.isWhitespace());
Assert.assertTrue("Not a single space: " + token, token.is(TokenTypes.WHITESPACE, " "));
}
token = token.getNextToken();
}
Assert.assertTrue(token.getType() == TokenTypes.NULL);
}
示例3: testEolComments_URL
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testEolComments_URL() {
String[] eolCommentLiterals = {
"// Hello world http://www.sas.com",
};
for (String code : eolCommentLiterals) {
Segment segment = createSegment(code);
TokenMaker tm = createTokenMaker();
Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
Assert.assertEquals(TokenTypes.COMMENT_EOL, token.getType());
token = token.getNextToken();
Assert.assertTrue(token.isHyperlink());
Assert.assertEquals(TokenTypes.COMMENT_EOL, token.getType());
Assert.assertEquals("http://www.sas.com", token.getLexeme());
}
}
示例4: testGetTokenList_nullStart_EscapedBackQuote
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的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: testJS_DataTypes
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testJS_DataTypes() {
String code = "boolean byte char double float int long short";
Segment segment = createSegment(code);
JavaScriptTokenMaker tm = new JavaScriptTokenMaker();
Token token = tm.getTokenList(segment, JS_PREV_TOKEN_TYPE, 0);
String[] keywords = code.split(" +");
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], token.getLexeme());
Assert.assertEquals(TokenTypes.DATA_TYPE, token.getType());
if (i < keywords.length - 1) {
token = token.getNextToken();
Assert.assertTrue("Not a whitespace token: " + token, token.isWhitespace());
Assert.assertTrue(token.is(TokenTypes.WHITESPACE, " "));
}
token = token.getNextToken();
}
Assert.assertTrue(token.getType() == TokenTypes.NULL);
}
示例6: testJS_Functions
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testJS_Functions() {
String code = "eval parseInt parseFloat escape unescape isNaN isFinite";
Segment segment = createSegment(code);
JSPTokenMaker tm = new JSPTokenMaker();
Token token = tm.getTokenList(segment,
JSPTokenMaker.INTERNAL_IN_JS, 0);
String[] functions = code.split(" +");
for (int i = 0; i < functions.length; i++) {
Assert.assertEquals(functions[i], token.getLexeme());
Assert.assertEquals("Not a function token: " + token, TokenTypes.FUNCTION, token.getType());
if (i < functions.length - 1) {
token = token.getNextToken();
Assert.assertTrue("Not a whitespace token: " + token, token.isWhitespace());
Assert.assertTrue(token.is(TokenTypes.WHITESPACE, " "));
}
token = token.getNextToken();
}
}
示例7: testTS_BooleanLiterals
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testTS_BooleanLiterals() {
String code = "true false";
Segment segment = createSegment(code);
TokenMaker tm = createTokenMaker();
Token token = tm.getTokenList(segment, TS_PREV_TOKEN_TYPE, 0);
String[] keywords = code.split(" +");
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], token.getLexeme());
Assert.assertEquals(TokenTypes.LITERAL_BOOLEAN, token.getType());
if (i < keywords.length - 1) {
token = token.getNextToken();
Assert.assertTrue("Not a whitespace token: " + token, token.isWhitespace());
Assert.assertTrue(token.is(TokenTypes.WHITESPACE, " "));
}
token = token.getNextToken();
}
Assert.assertTrue(token.getType() == TokenTypes.NULL);
}
示例8: testGetTokenList_whitespaceStart_EolComment
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的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);
}
示例9: testJS_Keywords
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testJS_Keywords() {
String code = "break case catch class const continue " +
"debugger default delete do else export extends finally for function if " +
"import in instanceof let new super switch " +
"this throw try typeof void while with " +
"NaN Infinity";
Segment segment = createSegment(code);
JSPTokenMaker tm = new JSPTokenMaker();
Token token = tm.getTokenList(segment, JSPTokenMaker.INTERNAL_IN_JS, 0);
String[] keywords = code.split(" +");
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], token.getLexeme());
Assert.assertEquals("Not a keyword token: " + token, TokenTypes.RESERVED_WORD, token.getType());
if (i < keywords.length - 1) {
token = token.getNextToken();
Assert.assertTrue("Not a whitespace token: " + token, token.isWhitespace());
Assert.assertTrue(token.is(TokenTypes.WHITESPACE, " "));
}
token = token.getNextToken();
}
segment = createSegment("return");
token = tm.getTokenList(segment, JSPTokenMaker.INTERNAL_IN_JS, 0);
Assert.assertEquals("return", token.getLexeme());
Assert.assertEquals(TokenTypes.RESERVED_WORD_2, token.getType());
token = token.getNextToken();
}
示例10: testMxml_happyPath_tagWithAttributes
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testMxml_happyPath_tagWithAttributes() {
String code = "<body onload=\"doSomething()\" data-extra='true'>";
Segment segment = createSegment(code);
MxmlTokenMaker tm = new MxmlTokenMaker();
Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
Assert.assertTrue(token.isSingleChar(TokenTypes.MARKUP_TAG_DELIMITER, '<'));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.MARKUP_TAG_NAME, "body"));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.WHITESPACE, " "));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.MARKUP_TAG_ATTRIBUTE, "onload"));
token = token.getNextToken();
Assert.assertTrue(token.isSingleChar(TokenTypes.OPERATOR, '='));
token = token.getNextToken();
Assert.assertTrue("Unexpected token: " + token, token.is(TokenTypes.MARKUP_TAG_ATTRIBUTE_VALUE, "\"doSomething()\""));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.WHITESPACE, " "));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.MARKUP_TAG_ATTRIBUTE, "data-extra"));
token = token.getNextToken();
Assert.assertTrue(token.isSingleChar(TokenTypes.OPERATOR, '='));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.MARKUP_TAG_ATTRIBUTE_VALUE, "'true'"));
token = token.getNextToken();
Assert.assertTrue(token.isSingleChar(TokenTypes.MARKUP_TAG_DELIMITER, '>'));
}
示例11: testBooleanLiterals
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testBooleanLiterals() {
String code = "<?php true false TRUE FALSE ?>";
Segment segment = createSegment(code);
PHPTokenMaker tm = new PHPTokenMaker();
Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
String[] keywords = code.split(" +");
Assert.assertTrue("Unexpected token: " + token, token.is(TokenTypes.MARKUP_TAG_DELIMITER, "<?php"));
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.WHITESPACE, " "));
token = token.getNextToken();
for (int i = 1; i < 5; i++) {
Assert.assertEquals(keywords[i], token.getLexeme());
Assert.assertEquals(TokenTypes.LITERAL_BOOLEAN, token.getType());
token = token.getNextToken();
Assert.assertTrue("Not a whitespace token: " + token, token.isWhitespace());
Assert.assertTrue(token.is(TokenTypes.WHITESPACE, " "));
token = token.getNextToken();
}
Assert.assertTrue(token.is(TokenTypes.MARKUP_TAG_DELIMITER, "?>"));
token = token.getNextToken();
Assert.assertTrue(token.getType() == TokenTypes.NULL);
}
示例12: testGetTokenList_nullStart_LiteralDoubleQuote
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testGetTokenList_nullStart_LiteralDoubleQuote() {
UnixShellTokenMaker tm = new UnixShellTokenMaker();
String text = "\"Hello world\"";
Segment s = createSegment(text);
Token token = tm.getTokenList(s, TokenTypes.NULL, 0);
Assert.assertTrue(token.is(TokenTypes.LITERAL_STRING_DOUBLE_QUOTE, text));
token = token.getNextToken();
Assert.assertEquals(new TokenImpl(), token);
}
示例13: testJS_DocComments_Markup
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testJS_DocComments_Markup() {
String text = "<code>";
Segment segment = createSegment(text);
JavaScriptTokenMaker tm = new JavaScriptTokenMaker();
final int INTERNAL_IN_JS_COMMENT_DOCUMENTATION = -9;
Token token = tm.getTokenList(segment, INTERNAL_IN_JS_COMMENT_DOCUMENTATION, 0);
// Can sometimes produce empty tokens, if e.g. @foo is first token
// on a line. We could technically make that better, but it is not
// the common case
token = token.getNextToken();
Assert.assertTrue(token.is(TokenTypes.COMMENT_MARKUP, "<code>"));
}
示例14: testHexLiterals
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testHexLiterals() {
String code = "0x1 0xfe 0x333333333333 0X1 0Xfe 0X33333333333 0xFE 0XFE " +
"0x1l 0xfel 0x333333333333l 0X1l 0Xfel 0X33333333333l 0xFEl 0XFEl " +
"0x1L 0xfeL 0x333333333333L 0X1L 0XfeL 0X33333333333L 0xFEL 0XFEL " +
"0x1u 0xfeu 0x333333333333u 0X1u 0Xfeu 0X33333333333u 0xFEu 0XFEu " +
"0x1U 0xfeU 0x333333333333U 0X1U 0XfeU 0X33333333333U 0xFEU 0XFEU " +
"0x1lu 0xfelu 0x333333333333lu 0X1lu 0Xfelu 0X33333333333lu 0xFElu 0XFElu " +
"0x1LU 0xfeLU 0x333333333333LU 0X1LU 0XfeLU 0X33333333333LU 0xFELU 0XFELU " +
"0x1ul 0xfeul 0x333333333333ul 0X1ul 0Xfeul 0X33333333333ul 0xFEul 0XFEul " +
"0x1UL 0xfeUL 0x333333333333UL 0X1UL 0XfeUL 0X33333333333UL 0xFEUL 0XFEUL";
Segment segment = createSegment(code);
CPlusPlusTokenMaker tm = new CPlusPlusTokenMaker();
Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
String[] keywords = code.split(" +");
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], token.getLexeme());
Assert.assertEquals("Invalid hex literal: " + token, TokenTypes.LITERAL_NUMBER_HEXADECIMAL, token.getType());
if (i < keywords.length - 1) {
token = token.getNextToken();
Assert.assertTrue("Not a whitespace token: " + token, token.isWhitespace());
Assert.assertTrue(token.is(TokenTypes.WHITESPACE, " "));
}
token = token.getNextToken();
}
Assert.assertTrue(token.getType() == TokenTypes.NULL);
}
示例15: testFloatingPointLiterals
import org.fife.ui.rsyntaxtextarea.Token; //导入方法依赖的package包/类
@Test
public void testFloatingPointLiterals() {
String code =
// Basic doubles
"3.0 4.2 3.0 4.2 .111 " +
// Basic floats ending in f, F, d, or D
"3.f 3.F 3.0f 3.0F .111f .111F " +
// lower-case exponent, no sign
"3.e7f 3.e7F 3.0e7f 3.0e7F .111e7f .111e7F " +
// Upper-case exponent, no sign
"3.E7f 3.E7F 3.0E7f 3.0E7F .111E7f .111E7F " +
// Lower-case exponent, positive
"3.e+7f 3.e+7F 3.0e+7f 3.0e+7F .111e+7f .111e+7F " +
// Upper-case exponent, positive
"3.E+7f 3.E+7F 3.0E+7f 3.0E+7F .111E+7f .111E+7F " +
// Lower-case exponent, negative
"3.e-7f 3.e-7F 3.0e-7f 3.0e-7F .111e-7f .111e-7F " +
// Upper-case exponent, negative
"3.E-7f 3.E-7F 3.0E-7f 3.0E-7F .111E-7f .111E-7F";
Segment segment = createSegment(code);
CPlusPlusTokenMaker tm = new CPlusPlusTokenMaker();
Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
String[] keywords = code.split(" +");
for (int i = 0; i < keywords.length; i++) {
Assert.assertEquals(keywords[i], token.getLexeme());
Assert.assertEquals("Invalid floating point: " + token, TokenTypes.LITERAL_NUMBER_FLOAT, token.getType());
if (i < keywords.length - 1) {
token = token.getNextToken();
Assert.assertTrue("Not a whitespace token: " + token, token.isWhitespace());
Assert.assertTrue(token.is(TokenTypes.WHITESPACE, " "));
}
token = token.getNextToken();
}
Assert.assertTrue(token.getType() == TokenTypes.NULL);
}