package com.googlecode.netburstjbehaveidea;
import com.intellij.lexer.FlexAdapter;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public final class StorySyntaxHighlighter extends SyntaxHighlighterBase {
private final Map<IElementType, TextAttributesKey> colors = new HashMap<IElementType, TextAttributesKey>();
private final Map<IElementType, TextAttributesKey> backgrounds = new HashMap<IElementType, TextAttributesKey>();
public StorySyntaxHighlighter() {
// colors.put(StoryParserTypes.STEP, TextAttributesKey.createTextAttributesKey(
// "JFLEX.STRING", SyntaxHighlighterColors.KEYWORD.getDefaultAttributes()
// ));
}
@NotNull
public Lexer getHighlightingLexer() {
return new FlexAdapter(new StoryLexerBasedOnJFlex());
}
@NotNull
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
return pack(getAttributeKeys(tokenType, backgrounds), getAttributeKeys(tokenType, colors));
}
private TextAttributesKey getAttributeKeys(IElementType tokenType, Map<IElementType, TextAttributesKey> map) {
TextAttributesKey attributes = map.get(tokenType);
// if (attributes == null && tokenType instanceof StoryElementType) {
// return map.get(((StoryElementType) tokenType).getParsedType());
// }
return map.get(tokenType);
}
}