Package com.googlecode.netburstjbehaveidea

Source Code of com.googlecode.netburstjbehaveidea.StorySyntaxHighlighter

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);
    }
}
TOP

Related Classes of com.googlecode.netburstjbehaveidea.StorySyntaxHighlighter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.