org.eclipse.xtext.ui.editor.model.ITokenTypeToPartitionTypeMapper Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.model.ITokenTypeToPartitionTypeMapper. 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: PartitionTokenScannerTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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;

}
 
Example #2
Source File: DotHtmlLabelUiModule.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ITokenTypeToPartitionTypeMapper> bindITokenTypeToPartitionTypeMapper() {
	return DotHtmlLabelTerminalsTokenTypeToPartitionMapper.class;
}
 
Example #3
Source File: DotUiModule.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ITokenTypeToPartitionTypeMapper> bindITokenTypeToPartitionTypeMapper() {
	return DotTerminalsTokenTypeToPartitionMapper.class;
}