/** Created by IntelliJ IDEA. User: jon Date: Apr 3, 2010 Time: 1:55:00 AM */
public class MoonHighlightingData {
  @NonNls static final String KEYWORD_ID = "MOON_KEYWORD";
  @NonNls static final String COMMENT_ID = "MOON_COMMENT";
  @NonNls static final String LONGCOMMENT_ID = "MOON_LONGCOMMENT";
  @NonNls static final String NUMBER_ID = "MOON_NUMBER";
  @NonNls static final String STRING_ID = "MOON_STRING";
  @NonNls static final String LONGSTRING_ID = "MOON_LONGSTRING";
  @NonNls static final String LONGSTRING_BRACES_ID = "MOON_LONGSTRING_BRACES";
  @NonNls static final String LONGCOMMENT_BRACES_ID = "MOON_LONGCOMMENT_BRACES";
  @NonNls static final String BRACES_ID = "MOON_BRACES";
  @NonNls static final String PARENTHS_ID = "MOON_PARENTHS";
  @NonNls static final String BRACKETS_ID = "MOON_BRACKETS";
  @NonNls static final String BAD_CHARACTER_ID = "MOON_BAD_CHARACTER";
  @NonNls static final String IDENTIFIER_ID = "MOON_IDENTIFIER";
  @NonNls static final String VAR_ID = "MOON_VAR";
  @NonNls static final String COMMA_ID = "MOON_COMMA";
  @NonNls static final String SEMICOLON_ID = "MOON_SEMICOLON";
  @NonNls static final String SELF_ID = "MOON_SELF";
  @NonNls static final String DEFINED_CONSTANTS_ID = "MOON_DEFINED_CONSTANTS";
  @NonNls static final String LOCAL_VAR_ID = "MOON_LOCAL_VAR";
  @NonNls static final String GLOBAL_VAR_ID = "MOON_GLOBAL_VAR";
  @NonNls static final String FIELD_ID = "MOON_FIELD";
  @NonNls static final String TAIL_CALL_ID = "MOON_TAIL_CALL";
  @NonNls static final String PARAMETER_ID = "MOON_PARAMETER";
  @NonNls static final String UPVAL_ID = "MOON_UPVAL";

  @NonNls static final String LUADOC_ID = "MOON_LUADOC";
  @NonNls static final String LUADOC_TAG_ID = "MOON_LUADOC_TAG";
  @NonNls static final String LUADOC_VALUE_ID = "MOON_LUADOC_VALUE";

  @NonNls static final String OPERATION_SIGN_ID = "MOON_OPERATION_SIGN";

  private static final TextAttributes LUADOC_ATTR =
      SyntaxHighlighterColors.DOC_COMMENT.getDefaultAttributes().clone();
  public static final TextAttributesKey LUADOC =
      TextAttributesKey.createTextAttributesKey(LUADOC_ID, LUADOC_ATTR);

  private static TextAttributes LUADOC_TAG_ATTR =
      SyntaxHighlighterColors.DOC_COMMENT_TAG.getDefaultAttributes().clone();
  public static TextAttributesKey LUADOC_TAG =
      TextAttributesKey.createTextAttributesKey(LUADOC_TAG_ID, LUADOC_TAG_ATTR);

  private static TextAttributes LUADOC_VALUE_ATTR =
      SyntaxHighlighterColors.DOC_COMMENT.getDefaultAttributes().clone();
  public static TextAttributesKey LUADOC_VALUE =
      TextAttributesKey.createTextAttributesKey(LUADOC_VALUE_ID, LUADOC_VALUE_ATTR);

  private static final TextAttributes UPVAL_ATTR =
      HighlighterColors.TEXT.getDefaultAttributes().clone();
  public static final TextAttributesKey UPVAL =
      TextAttributesKey.createTextAttributesKey(UPVAL_ID, UPVAL_ATTR);

  private static final TextAttributes LOCAL_VAR_ATTR =
      HighlighterColors.TEXT.getDefaultAttributes().clone();
  public static final TextAttributesKey LOCAL_VAR =
      TextAttributesKey.createTextAttributesKey(LOCAL_VAR_ID, LOCAL_VAR_ATTR);

  private static final TextAttributes PARAMETER_ATTR =
      HighlighterColors.TEXT.getDefaultAttributes().clone();
  public static final TextAttributesKey PARAMETER =
      TextAttributesKey.createTextAttributesKey(PARAMETER_ID, PARAMETER_ATTR);

  private static final TextAttributes GLOBAL_VAR_ATTR =
      HighlighterColors.TEXT.getDefaultAttributes().clone();
  public static final TextAttributesKey GLOBAL_VAR =
      TextAttributesKey.createTextAttributesKey(GLOBAL_VAR_ID, GLOBAL_VAR_ATTR);

  public static final TextAttributesKey FIELD =
      TextAttributesKey.createTextAttributesKey(
          FIELD_ID, HighlighterColors.TEXT.getDefaultAttributes().clone());

  static final TextAttributes TAIL_CALL_ATTR =
      HighlighterColors.TEXT.getDefaultAttributes().clone();

  public static final TextAttributesKey TAIL_CALL =
      TextAttributesKey.createTextAttributesKey(TAIL_CALL_ID, TAIL_CALL_ATTR);

  public static final TextAttributesKey KEYWORD =
      TextAttributesKey.createTextAttributesKey(
          KEYWORD_ID, SyntaxHighlighterColors.KEYWORD.getDefaultAttributes().clone());

  public static final TextAttributesKey COMMENT =
      TextAttributesKey.createTextAttributesKey(
          COMMENT_ID, SyntaxHighlighterColors.LINE_COMMENT.getDefaultAttributes().clone());
  public static final TextAttributesKey LONGCOMMENT =
      TextAttributesKey.createTextAttributesKey(
          LONGCOMMENT_ID,
          SyntaxHighlighterColors.JAVA_BLOCK_COMMENT.getDefaultAttributes().clone());

  static final TextAttributes LONGCOMMENT_BRACES_ATTR =
      SyntaxHighlighterColors.JAVA_BLOCK_COMMENT.getDefaultAttributes().clone();

  public static final TextAttributesKey LONGCOMMENT_BRACES =
      TextAttributesKey.createTextAttributesKey(LONGCOMMENT_BRACES_ID, LONGCOMMENT_BRACES_ATTR);

  public static final TextAttributesKey NUMBER =
      TextAttributesKey.createTextAttributesKey(
          NUMBER_ID, SyntaxHighlighterColors.NUMBER.getDefaultAttributes().clone());
  public static final TextAttributesKey STRING =
      TextAttributesKey.createTextAttributesKey(
          STRING_ID, SyntaxHighlighterColors.STRING.getDefaultAttributes().clone());

  private static final TextAttributes LONGSTRING_ATTR =
      SyntaxHighlighterColors.STRING.getDefaultAttributes().clone();
  private static final TextAttributes LONGSTRING_BRACES_ATTR =
      SyntaxHighlighterColors.STRING.getDefaultAttributes().clone();
  public static final TextAttributesKey LONGSTRING =
      TextAttributesKey.createTextAttributesKey(LONGSTRING_ID, LONGSTRING_ATTR);
  public static final TextAttributesKey LONGSTRING_BRACES =
      TextAttributesKey.createTextAttributesKey(LONGSTRING_BRACES_ID, LONGSTRING_BRACES_ATTR);
  public static final TextAttributesKey BRACKETS =
      TextAttributesKey.createTextAttributesKey(
          BRACKETS_ID, SyntaxHighlighterColors.BRACKETS.getDefaultAttributes().clone());
  public static final TextAttributesKey BRACES =
      TextAttributesKey.createTextAttributesKey(
          BRACES_ID, SyntaxHighlighterColors.BRACES.getDefaultAttributes().clone());
  public static final TextAttributesKey PARENTHS =
      TextAttributesKey.createTextAttributesKey(
          PARENTHS_ID, SyntaxHighlighterColors.PARENTHS.getDefaultAttributes().clone());
  public static final TextAttributesKey BAD_CHARACTER =
      TextAttributesKey.createTextAttributesKey(
          BAD_CHARACTER_ID, HighlighterColors.BAD_CHARACTER.getDefaultAttributes().clone());

  public static final TextAttributesKey COMMA =
      TextAttributesKey.createTextAttributesKey(
          COMMA_ID, SyntaxHighlighterColors.COMMA.getDefaultAttributes().clone());

  private static final TextAttributes DEFINED_CONSTANTS_ATTR =
      SyntaxHighlighterColors.KEYWORD.getDefaultAttributes().clone();

  public static final TextAttributesKey DEFINED_CONSTANTS =
      TextAttributesKey.createTextAttributesKey(DEFINED_CONSTANTS_ID, DEFINED_CONSTANTS_ATTR);

  public static final TextAttributesKey OPERATION_SIGN =
      TextAttributesKey.createTextAttributesKey(
          OPERATION_SIGN_ID, SyntaxHighlighterColors.OPERATION_SIGN.getDefaultAttributes().clone());

  static {
    DEFINED_CONSTANTS_ATTR.setForegroundColor(Color.MAGENTA);
    UPVAL_ATTR.setFontType(SimpleTextAttributes.STYLE_ITALIC);
    LONGSTRING_ATTR.setBackgroundColor(new Color(0xD0, 0xD0, 0xD0));
    GLOBAL_VAR_ATTR.setForegroundColor(new Color(128, 0, 0));
    LOCAL_VAR_ATTR.setForegroundColor(new Color(0, 153, 153));
    PARAMETER_ATTR.setForegroundColor(new Color(153, 102, 255));
    LUADOC_ATTR.setForegroundColor(new Color(64, 95, 189));
    LUADOC_TAG_ATTR.setForegroundColor(new Color(64, 95, 189));
    LUADOC_VALUE_ATTR.setForegroundColor(new Color(64, 95, 189));
  }
}
public class NeonSyntaxHighlighter extends SyntaxHighlighterBase {

  public static final String UNKNOWN_ID = "Bad character";
  public static final TextAttributesKey UNKNOWN =
      TextAttributesKey.createTextAttributesKey(
          UNKNOWN_ID, HighlighterColors.BAD_CHARACTER.getDefaultAttributes().clone());

  public static final String COMMENT_ID = "Comment";
  public static final TextAttributesKey COMMENT =
      TextAttributesKey.createTextAttributesKey(
          COMMENT_ID, SyntaxHighlighterColors.LINE_COMMENT.getDefaultAttributes().clone());

  public static final String IDENTIFIER_ID = "Identifier";
  public static final TextAttributesKey IDENTIFIER =
      TextAttributesKey.createTextAttributesKey(
          IDENTIFIER_ID, SyntaxHighlighterColors.KEYWORD.getDefaultAttributes().clone());

  public static final String INTERPUNCTION_ID = "Interpunction";
  public static final TextAttributesKey INTERPUNCTION =
      TextAttributesKey.createTextAttributesKey(
          INTERPUNCTION_ID, SyntaxHighlighterColors.DOT.getDefaultAttributes().clone());

  public static final String NUMBER_ID = "Number";
  public static final TextAttributesKey NUMBER =
      TextAttributesKey.createTextAttributesKey(
          NUMBER_ID, SyntaxHighlighterColors.NUMBER.getDefaultAttributes().clone());

  public static final String KEYWORD_ID = "Keyword";
  public static final TextAttributesKey KEYWORD =
      TextAttributesKey.createTextAttributesKey(
          KEYWORD_ID, SyntaxHighlighterColors.KEYWORD.getDefaultAttributes().clone());

  // Groups of IElementType's
  public static final TokenSet sBAD = TokenSet.create(NEON_UNKNOWN);
  public static final TokenSet sCOMMENTS = TokenSet.create(NEON_COMMENT);
  public static final TokenSet sIDENTIFIERS =
      TokenSet.create(NEON_KEY); // , NEON_IDENTIFIER, NEON_LITERAL);
  public static final TokenSet sINTERPUNCTION =
      TokenSet.create(
          NEON_BLOCK_INHERITENCE,
          NEON_LPAREN,
          NEON_RPAREN,
          NEON_LBRACE_CURLY,
          NEON_RBRACE_CURLY,
          NEON_LBRACE_SQUARE,
          NEON_RBRACE_SQUARE,
          NEON_ITEM_DELIMITER,
          NEON_ASSIGNMENT);
  public static final TokenSet sNUMBERS = TokenSet.create(NEON_NUMBER);

  // Static container
  private static final Map<IElementType, TextAttributesKey> ATTRIBUTES =
      new HashMap<IElementType, TextAttributesKey>();

  // Fill in the map
  static {
    fillMap(ATTRIBUTES, sBAD, UNKNOWN);
    fillMap(ATTRIBUTES, sCOMMENTS, COMMENT);
    fillMap(ATTRIBUTES, sIDENTIFIERS, IDENTIFIER);
    fillMap(ATTRIBUTES, sINTERPUNCTION, INTERPUNCTION);
    fillMap(ATTRIBUTES, sNUMBERS, NUMBER);
  }

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

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