Merge branch 'master' into uta/rainbow
[idea/community.git] / java / java-impl / src / com / intellij / openapi / options / colors / pages / JavaColorSettingsPage.java
index 0069c98c26b3fb4d6d243fa5c2d0c8bec79097ca..853206b4d5d230b63d069f469c70c4111cecd2b1 100644 (file)
@@ -18,6 +18,8 @@ package com.intellij.openapi.options.colors.pages;
 import com.intellij.application.options.colors.InspectionColorSettingsPage;
 import com.intellij.ide.highlighter.JavaFileHighlighter;
 import com.intellij.ide.highlighter.JavaHighlightingColors;
+import com.intellij.lang.Language;
+import com.intellij.lang.java.JavaLanguage;
 import com.intellij.openapi.editor.colors.CodeInsightColors;
 import com.intellij.openapi.editor.colors.TextAttributesKey;
 import com.intellij.openapi.fileTypes.StdFileTypes;
@@ -25,18 +27,19 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter;
 import com.intellij.openapi.options.OptionsBundle;
 import com.intellij.openapi.options.colors.AttributesDescriptor;
 import com.intellij.openapi.options.colors.ColorDescriptor;
-import com.intellij.openapi.options.colors.ColorSettingsPage;
+import com.intellij.openapi.options.colors.RainbowColorSettingsPage;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.codeStyle.DisplayPriority;
 import com.intellij.psi.codeStyle.DisplayPrioritySortable;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 import java.util.HashMap;
 import java.util.Map;
 
-public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColorSettingsPage, DisplayPrioritySortable {
+public class JavaColorSettingsPage implements RainbowColorSettingsPage, InspectionColorSettingsPage, DisplayPrioritySortable {
   private static final AttributesDescriptor[] ourDescriptors = {
     new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.keyword"), JavaHighlightingColors.KEYWORD),
     new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.number"), JavaHighlightingColors.NUMBER),
@@ -208,4 +211,51 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor
   public DisplayPriority getPriority() {
     return DisplayPriority.KEY_LANGUAGE_SETTINGS;
   }
+
+  @Override
+  public boolean isRainbowType(TextAttributesKey type) {
+    return JavaHighlightingColors.LOCAL_VARIABLE_ATTRIBUTES.equals(type)
+        || JavaHighlightingColors.REASSIGNED_LOCAL_VARIABLE_ATTRIBUTES.equals(type)
+        || JavaHighlightingColors.PARAMETER_ATTRIBUTES.equals(type)
+        || JavaHighlightingColors.REASSIGNED_PARAMETER_ATTRIBUTES.equals(type)
+
+        || JavaHighlightingColors.DOC_COMMENT_TAG_VALUE.equals(type);
+  }
+
+  @NotNull
+  @Override
+  public String getRainbowDemoText() {
+    return
+      "import <class>java.util.Date</class>;\n" +
+      "class <class>SomeClass</class> {\n" +
+      "  public int <field>field</field>;\n" +
+      "  <constructorDeclaration>SomeClass</constructorDeclaration>(<interface>AnInterface</interface> <param>param</param>) {\n" +
+      "\n" +
+      "  }\n" +
+      "  /**\n" +
+      "   * Doc comment\n" +
+      "   * @param <javadocTagValue>param1</javadocTagValue> function param\n" +
+      "   * @param <javadocTagValue>param2</javadocTagValue>\n" +
+      "   * @param <javadocTagValue>param3</javadocTagValue>\n" +
+      "   * @param <javadocTagValue>param4</javadocTagValue>\n" +
+      "   * @param <javadocTagValue>param5</javadocTagValue>\n" +
+      "   */\n" +
+      "  void <methodDeclaration>method</methodDeclaration>(int <param>param1</param>,\n" +
+      "              int <param>param2</param>,\n" +
+      "              int <param>param3</param>,\n" +
+      "              int <param>param4</param>,\n" +
+      "              int <param>param5</param>) {\n" +
+      "    int <localVar>localVar1</localVar>, <localVar>localVar2</localVar>, <localVar>localVar3</localVar>, <localVar>localVar4</localVar>, <localVar>localVar5</localVar>;\n" +
+      "\n" +
+      "    <localVar>localVar3</localVar> = <param>param2</param>;\n" +
+      "    this.<field>field</field> = <localVar>localVar3</localVar> + <param>param1</param> + <param>param5</param>;\n" +
+      "  }\n" +
+      "}\n";
+  }
+
+  @Nullable
+  @Override
+  public Language getLanguage() {
+    return JavaLanguage.INSTANCE;
+  }
 }