package com.jetbrains.rest;

import java.util.Map;

import javax.annotation.Nonnull;

import org.jetbrains.annotations.NonNls;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
import com.intellij.openapi.options.colors.AttributesDescriptor;
import com.intellij.openapi.options.colors.ColorDescriptor;
import com.intellij.openapi.options.colors.ColorSettingsPage;
import com.intellij.util.containers.HashMap;

/**
 * User : catherine
 */
public class RestColorsPage implements ColorSettingsPage {
  private static final AttributesDescriptor[] ATTRS = new AttributesDescriptor[]{
    new AttributesDescriptor("Comment", RestSyntaxHighlighter.REST_COMMENT),
    new AttributesDescriptor("Title", RestSyntaxHighlighter.REST_SECTION_HEADER),
    new AttributesDescriptor("Explicit markup", RestSyntaxHighlighter.REST_EXPLICIT),
    new AttributesDescriptor("Fields", RestSyntaxHighlighter.REST_FIELD),
    new AttributesDescriptor("Reference name", RestSyntaxHighlighter.REST_REF_NAME),
    new AttributesDescriptor("Inline literals", RestSyntaxHighlighter.REST_FIXED),
    new AttributesDescriptor("Bold text", RestSyntaxHighlighter.REST_BOLD),
    new AttributesDescriptor("Italic text", RestSyntaxHighlighter.REST_ITALIC),
    new AttributesDescriptor("Interpreted text", RestSyntaxHighlighter.REST_INTERPRETED),
    new AttributesDescriptor("Literal and line blocks", RestSyntaxHighlighter.REST_INLINE),
  };

  @NonNls private static final HashMap<String, TextAttributesKey> ourTagToDescriptorMap = new HashMap<String, TextAttributesKey>();


  @Nonnull
  public String getDisplayName() {
    return "ReST file";
  }

  @Nonnull
  public AttributesDescriptor[] getAttributeDescriptors() {
    return ATTRS;
  }

  @Nonnull
  public ColorDescriptor[] getColorDescriptors() {
    return ColorDescriptor.EMPTY_ARRAY;
  }

  @Nonnull
  public SyntaxHighlighter getHighlighter() {
    final SyntaxHighlighter highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(RestFileType.INSTANCE, null, null);
    assert highlighter != null;
    return highlighter;
  }

  @Nonnull
  public String getDemoText() {
    return
      ".. comment for documentation master file\n\n" +
      "===============\n" +
      " Section Title\n" +
      "===============\n\n" +
      ".. toctree::\n" +
      "   :maxdepth: 2\n\n" +
      "There is *some italics text*\n" +
      "and **bold one** " +
      "and ``inline literals``\n\n" +
      "A link_ in citation style.\n" +
      "\n" +
      ".. _link: http://www.google.com\n\n" +
      ".. rubric:: Footnotes\n" +
      ".. [*] footnote.\n" +
      ".. [REL09] Citation\n\n" +
      ":ref:`builders`\n\n" +
      "\n" +
      "::\n" +
      "\n" +
      "  Whitespace, newlines, blank lines, and\n" +
      "  all kinds of markup (like *this* or\n" +
      "  \\this) is preserved by literal blocks.\n\n" +
      "It was literal block.";
  }

  public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {
    return ourTagToDescriptorMap;
  }
}

@@ -26,106 +26,8 @@
 t;%0A%0A
-import java.util.Map;%0A%0Aimport javax.annotation.Nonnull;%0A%0Aimport org.jetbrains.annotations.NonNls;%0A
 impo
@@ -402,41 +402,119 @@
 ort 
-com.intellij.util.containers.Hash
+org.jetbrains.annotations.NonNls;%0A%0Aimport javax.annotation.Nonnull;%0Aimport java.util.HashMap;%0Aimport java.util.
 Map;

drop deprecated class usage