Merge branch 'master' into uta/rainbow
authorAlexey Utkin <alexey.utkin@jetbrains.com>
Thu, 11 Aug 2016 12:01:33 +0000 (15:01 +0300)
committerAlexey Utkin <alexey.utkin@jetbrains.com>
Thu, 11 Aug 2016 12:01:33 +0000 (15:01 +0300)
# Conflicts:
# platform/analysis-impl/src/com/intellij/codeInsight/daemon/RainbowVisitor.java
# platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java
# platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java

1  2 
java/java-impl/src/com/intellij/openapi/options/colors/pages/JavaColorSettingsPage.java
platform/analysis-impl/src/com/intellij/codeHighlighting/RainbowHighlighter.java
platform/analysis-impl/src/com/intellij/codeInsight/daemon/RainbowVisitor.java
platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java
platform/lang-impl/src/com/intellij/application/options/colors/ColorOptionsTree.java
platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java
platform/lang-impl/src/com/intellij/application/options/colors/NewColorAndFontPanel.java
platform/lang-impl/src/com/intellij/application/options/colors/OptionsPanelImpl.java
platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java
platform/lang-impl/src/com/intellij/application/options/colors/SimpleEditorPreview.java
platform/lang-impl/src/com/intellij/openapi/options/colors/pages/DefaultLanguageColorsPage.java

index 43b2f17de331fadb1e78a6b1eada9e272d6592a6,24e6ff095d4d20955f156dc6d5a07b0b842277fd..655a6a1d34a83dacb5cfe4693980c125425273e7
@@@ -82,16 -82,37 +82,19 @@@ public abstract class RainbowVisitor im
      return false;
    }
  
 -  protected HighlightInfo getInfo(@NotNull final PsiElement context,
 -                                  @NotNull final PsiElement rainbowElement,
 -                                  @NotNull final String id,
 -                                  @Nullable final TextAttributesKey colorKey) {
 +  protected HighlightInfo getInfo(@NotNull PsiElement context,
 +                                  @NotNull PsiElement rainbowElement,
 +                                  @NotNull String id,
 +                                  @Nullable TextAttributesKey colorKey) {
-     return getHighlighter()
-       .getInfo(getHighlighter().getColorIndex(
-                    USED_COLORS.getValue(context),
-                    id,
-                    RainbowHighlighter.getRainbowHash(id)),
-                rainbowElement,
-                colorKey);
+     //noinspection SynchronizationOnLocalVariableOrMethodParameter
+     synchronized (context) {
 -      HashMap<String, Integer> id2index = USED_COLORS.getValue(context);
 -      Integer colorIndex = id2index.get(id);
 -      if (colorIndex == null) {
 -        colorIndex = Math.abs(StringHash.murmur(id, 0x55AA));
 -
 -        Map<Integer, Integer> index2usage = new HashMap<Integer, Integer>();
 -        id2index.values().forEach(i -> {
 -          Integer useCount = index2usage.get(i);
 -          index2usage.put(i, useCount == null ? 1 : ++useCount);
 -        });
 -
 -        int colorsCount = getHighlighter().getColorsCount();
 -        out:
 -        for (int cutoff = 0; ; ++cutoff) {
 -          for (int i = 0; i < colorsCount; ++i) {
 -            colorIndex %= colorsCount;
 -            Integer useCount = index2usage.get(colorIndex % colorsCount);
 -            if (useCount == null) useCount = 0;
 -            if (useCount == cutoff) break out;
 -            ++colorIndex;
 -          }
 -        }
 -        id2index.put(id, colorIndex);
 -      }
 -      return getHighlighter().getInfo(colorIndex, rainbowElement, colorKey);
++      return getHighlighter()
++        .getInfo(getHighlighter().getColorIndex(
++          USED_COLORS.getValue(context),
++          id,
++          RainbowHighlighter.getRainbowHash(id)),
++                 rainbowElement,
++                 colorKey);
+     }
    }
  }
index bdd6d1c9a7dcd7ce04da1e368e1ce2007d0338eb,5bb1e1e11a40be20f0f796f9a16f8e8da5cf550d..7d03eaae6f3dc3008042c6297c64f6e64a8654e8
@@@ -501,8 -488,7 +501,8 @@@ public class ColorAndFontOptions extend
     }
  
    private void initAll() {
-     mySchemes = new THashMap<String, MyColorScheme>();
 +    myCurGlobalOption.copyFrom(myInitGlobalOption);
+     mySchemes = new THashMap<>();
      for (EditorColorsScheme allScheme : EditorColorsManager.getInstance().getAllSchemes()) {
        MyColorScheme schemeDelegate = new MyColorScheme(allScheme);
        initScheme(schemeDelegate);
index 6592921a26e449a2d689c0cbe8703ed1266b14ed,07507167eb6a5f1003c7b2f644da8423643dfbae..d9d216bcaf5c16876a9f875021f86d8343d230fd
@@@ -140,9 -138,9 +140,9 @@@ public class ColorOptionsTree extends T
  
    @Nullable
    private static List<String> extractPath(@NotNull EditorSchemeAttributeDescriptor descriptor) {
 -    if (descriptor instanceof ColorAndFontDescription) {
 +    if (descriptor instanceof EditorSchemeAttributeDescriptorWithPath) {
        String name = descriptor.toString();
-       List<String> path = new ArrayList<String>();
+       List<String> path = new ArrayList<>();
        int separatorStart = name.indexOf(NAME_SEPARATOR);
        int nextChunkStart = 0;
        while(separatorStart > 0) {
index 527b469ce6194f529eeae7638a98707589f70177,afe88048f6b482bef7a24e8ec3bcf6abde9ee32b..281c60335e829c5fa0712b4d21298e7b9b11cf44
@@@ -268,9 -242,10 +268,9 @@@ public class SimpleEditorPreview implem
      if (show && count <= 0) return Collections.emptyList();
      editor.getMarkupModel().removeAllHighlighters();
      boolean found = false;
-     List<HighlightData> highlights = new ArrayList<HighlightData>();
-     List<HighlightData> matchingHighlights = new ArrayList<HighlightData>();
+     List<HighlightData> highlights = new ArrayList<>();
+     List<HighlightData> matchingHighlights = new ArrayList<>();
 -    for (int i = 0; highlightDatum != null && i < highlightDatum.length; i++) {
 -      HighlightData highlightData = highlightDatum[i];
 +    for (HighlightData highlightData : myHighlightData) {
        String type = highlightData.getHighlightType();
        highlights.add(highlightData);
        if (show && type.equals(attrKey)) {
index d452ccefbdc261549a6fd0a06b21360cf26a24e5,6fe557e2cad255d4211d714ba2a0911d9956434e..d625b94e4ade0aa84c99807b1042899ab30f59c3
@@@ -41,9 -40,9 +41,9 @@@ import java.util.Map
   *
   * @author Rustam Vishnyakov
   */
 -public class DefaultLanguageColorsPage implements ColorSettingsPage, DisplayPrioritySortable {
 +public class DefaultLanguageColorsPage implements RainbowColorSettingsPage, DisplayPrioritySortable {
  
-   @NonNls private static final Map<String, TextAttributesKey> TAG_HIGHLIGHTING_MAP = new HashMap<String, TextAttributesKey>();
+   @NonNls private static final Map<String, TextAttributesKey> TAG_HIGHLIGHTING_MAP = new HashMap<>();
  
    private final static TextAttributesKey FAKE_BAD_CHAR =
      TextAttributesKey.createTextAttributesKey("FAKE_BAD_CHAR", HighlighterColors.BAD_CHARACTER);