Lexical syntax highlighting [message #479001] |
Fri, 07 August 2009 18:21  |
Eclipse User |
|
|
|
Originally posted by: c.krause.cwi.nl
Hi,
sorry I know this is covered in the docu, but I do not fully understand
how I can hook up my own custom lexical highlighter. Is there any
example that shows how exactly I should hook up the
ILexicalHighlightingConfiguration and the AbstractTokenScanner +
AbstractAntlrTokenToAttributeIdMapper?
The token scanner I should hook up via bindITokenScanner() in my
XXXUIModule, right? And then I override getTokenIdMapper() in there?
How about the ILexicalHighlightingConfiguration?
Cheers,
Christian
|
|
|
|
|
|
|
Re: Lexical syntax highlighting [message #552736 is a reply to message #552731] |
Fri, 13 August 2010 06:31   |
Eclipse User |
|
|
|
Alex, this is what I am trying to do. IOn the Lexical highlighting I define a new style:
public class MyHighLightingConfiguration extends DefaultHighlightingConfiguration{
public static final String LAYOUT_ID = "layout";
public void configure(IHighlightingConfigurationAcceptor acceptor) {
super.configure(acceptor);
acceptor.acceptDefaultHighlighting(LAYOUT_ID, "Layout", layoutTextStyle());
}
public TextStyle layoutTextStyle() {
TextStyle textStyle = new TextStyle();
textStyle.setColor(new RGB(0, 0, 255));
textStyle.setStyle(SWT.ITALIC);
return textStyle;
}
}
And in the token id scanner I try to use it:
public class MyAntlrTokenToAttributeIdMapper extends DefaultAntlrTokenToAttributeIdMapper {
@Override
protected String calculateId(String tokenName, int tokenType) {
if( "container".equals(tokenName)) {
return MyHighLightingConfiguration.LAYOUT_ID;
}
return super.calculateId(tokenName, tokenType);
}
}
And in the module I bind them:
public Class<? extends IHighlightingConfiguration> bindILexicalHighlightingConfiguration() {
return MyHighLightingConfiguration.class;
}
public Class<? extends AbstractAntlrTokenToAttributeIdMapper> bindAbstractAntlrTokenToAttributeIdMapper() {
return MyAntlrTokenToAttributeIdMapper.class ;
}
Nothing happens, I still get the default keyword color for the "container" keyword.
If I take out the call to 'super' in MyHighlightingConfiguration all keyword syntax coloring dissappears, so the binding works ok.
-- Jos
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03363 seconds