/*
 * Copyright 2000-2008 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.jetbrains.python.buildout.config;

import com.google.common.collect.Maps;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
import com.intellij.openapi.editor.SyntaxHighlighterColors;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
import com.intellij.psi.tree.IElementType;
import com.jetbrains.python.buildout.config.lexer.BuildoutCfgFlexLexer;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

import java.util.Map;

/**
 * @author: traff
 */
public class BuildoutCfgSyntaxHighlighter extends SyntaxHighlighterBase implements BuildoutCfgTokenTypes {
  @NonNls
  static final String COMMENT_ID = "BUILDOUT_COMMENT";
  @NonNls
  static final String TEXT_ID = "BUILDOUT_TEXT";
  @NonNls
  static final String BRACKETS_ID = "BUILDOUT_BRACKETS";


  public static final TextAttributesKey BUILDOUT_SECTION_NAME =
    TextAttributesKey.createTextAttributesKey("BUILDOUT.SECTION_NAME", SyntaxHighlighterColors.NUMBER);

  public static final TextAttributesKey BUILDOUT_KEY = TextAttributesKey.createTextAttributesKey(
    "BUILDOUT.KEY",
    DefaultLanguageHighlighterColors.KEYWORD
  );

  public static final TextAttributesKey BUILDOUT_VALUE = TextAttributesKey.createTextAttributesKey(
    "BUILDOUT.VALUE",
    DefaultLanguageHighlighterColors.STRING
  );

  public static final TextAttributesKey BUILDOUT_COMMENT = TextAttributesKey.createTextAttributesKey(
    "BUILDOUT.LINE_COMMENT",
    DefaultLanguageHighlighterColors.LINE_COMMENT
  );

  public static final TextAttributesKey BUILDOUT_KEY_VALUE_SEPARATOR = TextAttributesKey.createTextAttributesKey(
    "BUILDOUT.KEY_VALUE_SEPARATOR",
    DefaultLanguageHighlighterColors.OPERATION_SIGN
  );
  public static final TextAttributesKey BUILDOUT_VALID_STRING_ESCAPE = TextAttributesKey.createTextAttributesKey(
    "BUILDOUT.VALID_STRING_ESCAPE",
    DefaultLanguageHighlighterColors.VALID_STRING_ESCAPE
  );
  public static final TextAttributesKey BUILDOUT_INVALID_STRING_ESCAPE = TextAttributesKey.createTextAttributesKey(
    "BUILDOUT.INVALID_STRING_ESCAPE",
    DefaultLanguageHighlighterColors.INVALID_STRING_ESCAPE
  );


  private static final Map<IElementType, TextAttributesKey> ATTRIBUTES = Maps.newHashMap();

  static {
    ATTRIBUTES.put(COMMENT, BUILDOUT_COMMENT);
    ATTRIBUTES.put(SECTION_NAME, BUILDOUT_SECTION_NAME);
    ATTRIBUTES.put(KEY_VALUE_SEPARATOR, BUILDOUT_KEY_VALUE_SEPARATOR);
    ATTRIBUTES.put(KEY_CHARACTERS, BUILDOUT_KEY);
    ATTRIBUTES.put(VALUE_CHARACTERS, BUILDOUT_VALUE);
  }


  @NotNull
  public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
    return SyntaxHighlighterBase.pack(ATTRIBUTES.get(tokenType));
  }

  @NotNull
  public Lexer getHighlightingLexer() {
    return new BuildoutCfgFlexLexer();
  }
}

@@ -787,68 +787,8 @@
 rs;%0A
-import com.intellij.openapi.editor.SyntaxHighlighterColors;%0A
 impo
@@ -1516,20 +1516,16 @@
 N_NAME =
-%0A   
  TextAtt
@@ -1559,16 +1559,21 @@
 utesKey(
+%0A    
 %22BUILDOU
@@ -1588,23 +1588,36 @@
 N_NAME%22,
- Syntax
+%0A    DefaultLanguage
 Highligh
@@ -1632,16 +1632,19 @@
 s.NUMBER
+%0A  
 );%0A%0A  pu

remove usage of SyntaxHighlighterColors