use of org.eclipse.n4js.ui.contentassist.antlr.lexer.InternalN4JSLexer in project n4js by eclipse.
the class NodeModelTokenSource method toPrefixToken.
/**
* Produce an Antlr token for the prefix of the given leaf that overlaps the requested region
*
* @see #endOffset
*/
private Token toPrefixToken(ILeafNode leaf) {
Lexer lexer = new InternalN4JSLexer();
String text = leaf.getText();
String prefix = text.substring(0, endOffset - leaf.getTotalOffset());
ANTLRStringStream stream = new ANTLRStringStream(prefix);
lexer.setCharStream(stream);
Token nextToken = lexer.nextToken();
// copy to get rid of the reference to the stream again
return new CommonToken(nextToken.getType(), nextToken.getText());
}
Aggregations