• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TokenMaker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.fife.ui.rsyntaxtextarea.TokenMaker的典型用法代码示例。如果您正苦于以下问题:Java TokenMaker类的具体用法?Java TokenMaker怎么用?Java TokenMaker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TokenMaker类属于org.fife.ui.rsyntaxtextarea包,在下文中一共展示了TokenMaker类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testEolComments_URL

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的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());

	}

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:24,代码来源:DTokenMakerTest.java


示例2: testOperators

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testOperators() {

	String code = "^ @ : = < > + - / *";

	Segment segment = createSegment(code);
	TokenMaker tm = createTokenMaker();
	Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);

	String[] operators = code.split(" +");
	for (int i = 0; i < operators.length; i++) {
		Assert.assertEquals(operators[i], token.getLexeme());
		Assert.assertEquals(TokenTypes.OPERATOR, token.getType());
		if (i < operators.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);

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:25,代码来源:DelphiTokenMakerTest.java


示例3: testJS_StringLiterals_valid

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testJS_StringLiterals_valid() {

	String[] stringLiterals = {
		"\"\"", "\"hi\"", "\"\\x77\"", "\"\\u00fe\"", "\"\\\"\"",
		"\"My name is Robert and I \\", // String continued on another line
	};

	for (String code : stringLiterals) {
		Segment segment = createSegment(code);
		TokenMaker tm = createTokenMaker();
		Token token = tm.getTokenList(segment, HTMLTokenMaker.INTERNAL_IN_JS, 0);
		Assert.assertEquals(TokenTypes.LITERAL_STRING_DOUBLE_QUOTE, token.getType());
	}

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:17,代码来源:HTMLTokenMakerTest.java


示例4: testOperators

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testOperators() {

	String assignmentOperators = "+ - <= ^ ++ < * >= % -- > / != ? >> ! & == : >> ~ | && >>>";
	String nonAssignmentOperators = "= -= *= /= |= &= ^= += %= <<= >>= >>>=";
	String code = assignmentOperators + " " + nonAssignmentOperators;

	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(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);

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:27,代码来源:JavaTokenMakerTest.java


示例5: testJS_Functions

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testJS_Functions() {

	String code = "eval parseInt parseFloat escape unescape isNaN isFinite";

	Segment segment = createSegment(code);
	TokenMaker tm = createTokenMaker();
	Token token = tm.getTokenList(segment, TokenTypes.NULL, 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();
	}

	Assert.assertTrue(token.getType() == TokenTypes.NULL);

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:25,代码来源:ActionScriptTokenMakerTest.java


示例6: testJS_Operators

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testJS_Operators() {

	String assignmentOperators = "+ - <= ^ ++ < * >= % -- > / != ? >> ! & == : >> ~ && >>>";
	String nonAssignmentOperators = "= -= *= /= |= &= ^= += %= <<= >>= >>>=";
	String code = assignmentOperators + " " + nonAssignmentOperators;

	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);

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:27,代码来源:ActionScriptTokenMakerTest.java


示例7: testTS_CharLiterals_valid

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testTS_CharLiterals_valid() {

	String[] charLiterals = {
		"'a'", "'\\b'", "'\\t'", "'\\r'", "'\\f'", "'\\n'", "'\\u00fe'",
		"'\\u00FE'", "'\\111'", "'\\222'", "'\\333'",
		"'\\x77'", 
		"'\\11'", "'\\22'", "'\\33'",
		"'\\1'",
		"'My name is Robert and I \\", // Continued onto another line
	};

	for (String code : charLiterals) {
		Segment segment = createSegment(code);
		TokenMaker tm = createTokenMaker();
		Token token = tm.getTokenList(segment, TS_PREV_TOKEN_TYPE, 0);
		Assert.assertEquals(TokenTypes.LITERAL_CHAR, token.getType());
	}

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:21,代码来源:TypeScriptTokenMakerTest.java


示例8: testJS_StringLiterals_valid

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testJS_StringLiterals_valid() {

	String[] stringLiterals = {
		"\"\"", "\"hi\"", "\"\\u00fe\"", "\"\\\"\"",
	};

	for (String code : stringLiterals) {
		Segment segment = createSegment(code);
		TokenMaker tm = createTokenMaker();
		Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
		Assert.assertEquals("Not identified as string literal: " + token,
				TokenTypes.LITERAL_STRING_DOUBLE_QUOTE, token.getType());
	}

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:17,代码来源:ActionScriptTokenMakerTest.java


示例9: testHexLiterals

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testHexLiterals() {

	String[] hexLiterals = {
		"0x1", "0xfe", "0x333333333333 ",
		"0xf_e", "0x333_33_3", // Underscores
	};

	for (String code : hexLiterals) {
		Segment segment = createSegment(code);
		TokenMaker tm = createTokenMaker();
		Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
		Assert.assertEquals("Invalid hex literal: " + token, TokenTypes.LITERAL_NUMBER_HEXADECIMAL, token.getType());
	}

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:17,代码来源:RubyTokenMakerTest.java


示例10: testHeredoc_EOT

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testHeredoc_EOT() {

	// Note that the terminating "EOT" should be on another line in real
	// Ruby scripts, but our lexer does not discern that.
	String[] eofs = {
		"<<EOT Hello world EOT",
		"<< \"EOT\" Hello world EOT",
		"<<   \t\"EOT\" Hello world EOT",
		"<< 'EOT' Hello world EOT",
		"<<   \t'EOT' Hello world EOT",
	};

	for (String code : eofs) {
		Segment segment = createSegment(code);
		TokenMaker tm = createTokenMaker();
		Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
		Assert.assertTrue(token.is(TokenTypes.PREPROCESSOR, code));
	}

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:22,代码来源:RubyTokenMakerTest.java


示例11: testSeparators

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testSeparators() {

	String code = "( ) [ ] { }";

	Segment segment = createSegment(code);
	TokenMaker tm = createTokenMaker();
	Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);

	String[] separators = code.split(" +");
	for (int i = 0; i < separators.length; i++) {
		Assert.assertEquals(separators[i], token.getLexeme());
		Assert.assertEquals(TokenTypes.SEPARATOR, token.getType());
		// Just one extra test here
		Assert.assertTrue(token.isSingleChar(TokenTypes.SEPARATOR, separators[i].charAt(0)));
		if (i < separators.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);

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:27,代码来源:JavaTokenMakerTest.java


示例12: testBinaryLiterals

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testBinaryLiterals() {

	String code =
		"0b0 0b1 0B0 0B1 0b010 0B010 0b0_10 0B0_10";

	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(TokenTypes.LITERAL_NUMBER_DECIMAL_INT, 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);

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:26,代码来源:JavaTokenMakerTest.java


示例13: testTS_StringLiterals_valid

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testTS_StringLiterals_valid() {

	String[] stringLiterals = {
		"\"\"", "\"hi\"", "\"\\x77\"", "\"\\u00fe\"", "\"\\\"\"",
		"\"My name is Robert and I \\", // String continued on another line
	};

	for (String code : stringLiterals) {
		Segment segment = createSegment(code);
		TokenMaker tm = createTokenMaker();
		Token token = tm.getTokenList(segment, TS_PREV_TOKEN_TYPE, 0);
		Assert.assertEquals(TokenTypes.LITERAL_STRING_DOUBLE_QUOTE, token.getType());
	}

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:17,代码来源:TypeScriptTokenMakerTest.java


示例14: testJS_DataTypes

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testJS_DataTypes() {

	String code = "String Number int uint Boolean Null";

	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(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);

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:25,代码来源:ActionScriptTokenMakerTest.java


示例15: testLess_EolComments_URL

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testLess_EolComments_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());

	}

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:24,代码来源:LessTokenMakerTest.java


示例16: testStandardFunctions

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testStandardFunctions() {

	String[] functions = {
		// Currently none
	};

	for (String code : functions) {
		Segment segment = createSegment(code);
		TokenMaker tm = createTokenMaker();
		Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
		Assert.assertEquals("Not a standard function: " + token,
				TokenTypes.FUNCTION, token.getType());
	}

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:17,代码来源:DTokenMakerTest.java


示例17: testHexLiterals

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testHexLiterals() {

	String code = "0x1 0xf 0x333333333333 0X1 0Xf 0X33333333333 0xF 0XF " +
			"0x1 0xf 0x333333333333 0X1 0Xf 0X33333333333 0xF 0XF";

	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("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);

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:26,代码来源:NSISTokenMakerTest.java


示例18: testHeredoc_EOF

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testHeredoc_EOF() {

	// Note that the terminating "EOF" should be on another line in real
	// Ruby scripts, but our lexer does not discern that.
	String[] eofs = {
		"<<EOF Hello world EOF",
		"<< \"EOF\" Hello world EOF",
		"<<   \t\"EOF\" Hello world EOF",
		"<< 'EOF' Hello world EOF",
		"<<   \t'EOF' Hello world EOF",
	};

	for (String code : eofs) {
		Segment segment = createSegment(code);
		TokenMaker tm = createTokenMaker();
		Token token = tm.getTokenList(segment, TokenTypes.NULL, 0);
		Assert.assertTrue(token.is(TokenTypes.PREPROCESSOR, code));
	}

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:22,代码来源:RubyTokenMakerTest.java


示例19: testJS_BooleanLiterals

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testJS_BooleanLiterals() {

	String code = "true false";

	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(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);

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:25,代码来源:ActionScriptTokenMakerTest.java


示例20: testTS_Functions

import org.fife.ui.rsyntaxtextarea.TokenMaker; //导入依赖的package包/类
@Test
public void testTS_Functions() {

	String code = "eval parseInt parseFloat escape unescape isNaN isFinite";

	Segment segment = createSegment(code);
	TokenMaker tm = createTokenMaker();
	Token token = tm.getTokenList(segment, TS_PREV_TOKEN_TYPE, 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();
	}

	Assert.assertTrue(token.getType() == TokenTypes.NULL);

}
 
开发者ID:curiosag,项目名称:ftc,代码行数:25,代码来源:TypeScriptTokenMakerTest.java



注:本文中的org.fife.ui.rsyntaxtextarea.TokenMaker类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MaterialSpinner类代码示例发布时间:2022-05-23
下一篇:
Java Cardinality类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap