org.eclipse.xtext.ui.editor.syntaxcoloring.TokenScanner Java Examples
The following examples show how to use
org.eclipse.xtext.ui.editor.syntaxcoloring.TokenScanner.
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: TokenScannerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testFullRange() throws Exception { TokenScanner scanner = getTokenScanner(3, 4, 3, 2); scanner.setRange(null, 0, 12); scanner.nextToken(); assertEquals(3, scanner.getTokenLength()); assertEquals(0, scanner.getTokenOffset()); scanner.nextToken(); assertEquals(4, scanner.getTokenLength()); assertEquals(3, scanner.getTokenOffset()); scanner.nextToken(); assertEquals(3, scanner.getTokenLength()); assertEquals(7, scanner.getTokenOffset()); scanner.nextToken(); assertEquals(2, scanner.getTokenLength()); assertEquals(10, scanner.getTokenOffset()); assertEquals(Token.EOF, scanner.nextToken()); }
Example #2
Source File: TokenScannerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testBeginning() throws Exception { TokenScanner scanner = getTokenScanner(3, 4, 3, 2); scanner.setRange(null, 0, 7); scanner.nextToken(); assertEquals(3, scanner.getTokenLength()); assertEquals(0, scanner.getTokenOffset()); scanner.nextToken(); assertEquals(4, scanner.getTokenLength()); assertEquals(3, scanner.getTokenOffset()); assertEquals(Token.EOF, scanner.nextToken()); }
Example #3
Source File: TokenScannerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testMidRange() throws Exception { TokenScanner scanner = getTokenScanner(3, 4, 3, 2); scanner.setRange(null, 3, 7); scanner.nextToken(); assertEquals(4, scanner.getTokenLength()); assertEquals(3, scanner.getTokenOffset()); scanner.nextToken(); assertEquals(3, scanner.getTokenLength()); assertEquals(7, scanner.getTokenOffset()); assertEquals(Token.EOF, scanner.nextToken()); }
Example #4
Source File: TokenScannerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testTrailingRange() throws Exception { TokenScanner scanner = getTokenScanner(3, 4, 3, 2); scanner.setRange(null, 7, 5); scanner.nextToken(); assertEquals(3, scanner.getTokenLength()); assertEquals(7, scanner.getTokenOffset()); scanner.nextToken(); assertEquals(2, scanner.getTokenLength()); assertEquals(10, scanner.getTokenOffset()); assertEquals(Token.EOF, scanner.nextToken()); }
Example #5
Source File: TokenScannerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public TokenScanner getTokenScanner(int... lengths) throws Exception { final List<ILexerTokenRegion> tokens = Lists.newArrayList(); int offset = 0; for (final int length : lengths) { final int currentOffset = offset; tokens.add(new ILexerTokenRegion() { @Override public int getLength() { return length; } @Override public int getLexerTokenType() { return 4711; } @Override public int getOffset() { return currentOffset; } }); offset+=length; } TokenScanner tokenScanner = new TokenScanner() { @Override protected Iterable<ILexerTokenRegion> getTokens(IDocument document) { return tokens; } @Override protected IToken createToken(ILexerTokenRegion token) { return Token.UNDEFINED; } }; return tokenScanner; }
Example #6
Source File: DefaultUiModule.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public Class<? extends ITokenScanner> bindITokenScanner() { return TokenScanner.class; }