void () { final EditorColorsScheme colorsScheme = (EditorColorsScheme)EditorColorsManager.getInstance().getScheme("Default").clone(); final Color newColorInPalette = EditorColorPaletteFactory.getInstance().getPalette(colorsScheme, Language.ANY) .withBackgroundColors() .withForegroundColors() .getClosestNonConflictingColor(Color.YELLOW); final TextAttributes newColorAttrInPallete = new TextAttributes(); newColorAttrInPallete.setForegroundColor(newColorInPalette); // rainbow color generator can reuse LOCAL_VARIABLE or PARAM foreground color colorsScheme.setAttributes(DefaultLanguageHighlighterColors.LOCAL_VARIABLE, newColorAttrInPallete); checkUsed(colorsScheme, newColorInPalette, true); // rainbow color generator can not reuse any other foreground color final TextAttributes bcOrigAttr = colorsScheme.getAttributes(DefaultLanguageHighlighterColors.BLOCK_COMMENT); checkUsed(colorsScheme, bcOrigAttr.getForegroundColor(), false); final TextAttributesKey generatedRainbowKey = RainbowHighlighter.getRainbowTempKeys(colorsScheme)[0]; // check that `generatedRainbowKey` is based on real `colorsScheme` scheme Color generatedColor = colorsScheme.getAttributes(generatedRainbowKey).getForegroundColor(); assertEquals(RainbowHighlighter.testRainbowGenerateColors(colorsScheme)[0], generatedColor); // make BLOCK_COMMENT the same as LOCAL_VARIABLE => has conflict with non-rainbow BLOCK_COMMENT color colorsScheme.setAttributes(DefaultLanguageHighlighterColors.BLOCK_COMMENT, newColorAttrInPallete); checkUsed(colorsScheme, newColorInPalette, false); // rainbow generated colors are cached: assertNotNull(colorsScheme.getAttributes(generatedRainbowKey)); // change in colorsScheme for non-mutable key drops generated cache colorsScheme.setAttributes(DefaultLanguageHighlighterColors.BLOCK_COMMENT, bcOrigAttr); // there are no rainbow generated colors: assertNull(colorsScheme.getAttributes(generatedRainbowKey)); // resolve conflict for BLACK color (checking overflow) final TextAttributes blackColorAttrInPalette = new TextAttributes(); blackColorAttrInPalette.setForegroundColor(Color.BLACK); colorsScheme.setAttributes(DefaultLanguageHighlighterColors.BLOCK_COMMENT, blackColorAttrInPalette); checkUsed(colorsScheme, Color.BLACK, false); // resolve conflict for WHITE color (checking overflow) final TextAttributes whiteColorAttrInPalette = new TextAttributes(); whiteColorAttrInPalette.setForegroundColor(Color.WHITE); colorsScheme.setAttributes(DefaultLanguageHighlighterColors.BLOCK_COMMENT, whiteColorAttrInPalette); checkUsed(colorsScheme, Color.WHITE, false); }