Java Code Examples for org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken#setStartOffset()

The following examples show how to use org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken#setStartOffset() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AntlrDatatypeRuleTokenTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testMergeFirstDatatypeRuleToken() {
	AntlrDatatypeRuleToken tokenToMerge = new AntlrDatatypeRuleToken();
	tokenToMerge.setText("text");
	tokenToMerge.setStartOffset(6);
	AntlrDatatypeRuleToken token = new AntlrDatatypeRuleToken();
	token.merge(tokenToMerge);
	assertEquals("text", token.getText());
	assertEquals(10, token.getExpectedOffset());
}
 
Example 2
Source File: AntlrDatatypeRuleTokenTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testMergeSecondToken() {
	CommonToken tokenToMerge = new CommonToken(TOKEN_TYPE, "ext");
	tokenToMerge.setStartIndex(6);
	AntlrDatatypeRuleToken token = new AntlrDatatypeRuleToken();
	token.setStartOffset(tokenToMerge.getStartIndex() - 1);
	token.setExpectedOffset(tokenToMerge.getStartIndex());
	token.setText("t");
	token.merge(tokenToMerge);
	assertEquals("text", token.getText());
	assertEquals(9, token.getExpectedOffset());
}
 
Example 3
Source File: AntlrDatatypeRuleTokenTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testMergeSecondDatatypeRuleToken() {
	AntlrDatatypeRuleToken tokenToMerge = new AntlrDatatypeRuleToken();
	tokenToMerge.setText("ext");
	tokenToMerge.setStartOffset(9);
	AntlrDatatypeRuleToken token = new AntlrDatatypeRuleToken();
	token.setStartOffset(tokenToMerge.getStartOffset() - 1);
	token.setExpectedOffset(tokenToMerge.getStartOffset());
	token.setText("t");
	token.merge(tokenToMerge);
	assertEquals("text", token.getText());
	assertEquals(12, token.getExpectedOffset());
}
 
Example 4
Source File: AntlrDatatypeRuleTokenTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testMergeSecondTokenUnmatched() {
	CommonToken tokenToMerge = new CommonToken(TOKEN_TYPE, "ext");
	tokenToMerge.setStartIndex(6);
	AntlrDatatypeRuleToken token = new AntlrDatatypeRuleToken();
	token.setStartOffset(tokenToMerge.getStartIndex() - 4);
	token.setExpectedOffset(tokenToMerge.getStartIndex() - 3);
	token.setText("t");
	token.merge(tokenToMerge);
	assertEquals("t ext", token.getText());
	assertEquals(9, token.getExpectedOffset());
}
 
Example 5
Source File: AntlrDatatypeRuleTokenTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testMergeSecondDatatypeRuleTokenUnmatched() {
	AntlrDatatypeRuleToken tokenToMerge = new AntlrDatatypeRuleToken();
	tokenToMerge.setText("ext");
	tokenToMerge.setStartOffset(9);
	AntlrDatatypeRuleToken token = new AntlrDatatypeRuleToken();
	token.setStartOffset(tokenToMerge.getStartOffset() - 4);
	token.setExpectedOffset(tokenToMerge.getStartOffset() - 3);
	token.setText("t");
	token.merge(tokenToMerge);
	assertEquals("t ext", token.getText());
	assertEquals(12, token.getExpectedOffset());
}
 
Example 6
Source File: AntlrDatatypeRuleTokenTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testMergeEmptyToken() {
	AntlrDatatypeRuleToken emptyToken = new AntlrDatatypeRuleToken();
	AntlrDatatypeRuleToken token = new AntlrDatatypeRuleToken();
	token.setStartOffset(1);
	token.setExpectedOffset(2);
	token.setText("t");
	token.merge(emptyToken);
	assertEquals("t", token.getText());
	assertEquals(2, token.getExpectedOffset());
}
 
Example 7
Source File: AntlrDatatypeRuleTokenTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testMergeEmptyTokenWithOffset() {
	AntlrDatatypeRuleToken emptyToken = new AntlrDatatypeRuleToken();
	emptyToken.setStartOffset(9);
	AntlrDatatypeRuleToken token = new AntlrDatatypeRuleToken();
	token.setStartOffset(1);
	token.setExpectedOffset(2);
	token.setText("t");
	token.merge(emptyToken);
	assertEquals("t", token.getText());
	assertEquals(2, token.getExpectedOffset());
}