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);
+ }
}
}
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)) {
*
* @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);