use of org.eclipse.xtext.ui.editor.model.ITokenTypeToPartitionTypeMapper in project xtext-eclipse by eclipse.
the class PartitionTokenScannerTest method getPartitionTokenScanner.
public PartitionTokenScanner getPartitionTokenScanner(ILexerTokenRegion... tokenDescs) throws Exception {
final List<ILexerTokenRegion> tokens = Arrays.asList(tokenDescs);
int offset = 0;
for (ILexerTokenRegion token : tokens) {
((LexerTokenRegion) token).setOffset(offset);
offset += token.getLength();
}
PartitionTokenScanner tokenScanner = new PartitionTokenScanner() {
@Override
protected Iterable<ILexerTokenRegion> getTokens(IDocument document) {
return tokens;
}
@Override
protected boolean shouldMergePartitions(String contentType) {
return "3".equals(contentType);
}
};
tokenScanner.setMapper(new ITokenTypeToPartitionTypeMapper() {
@Override
public String[] getSupportedPartitionTypes() {
throw new UnsupportedOperationException();
}
@Override
public String getPartitionType(int antlrTokenType) {
return "" + antlrTokenType;
}
});
return tokenScanner;
}
Aggregations