mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
|
||||
public class ColorGenerator {
|
||||
@NotNull
|
||||
public static List<Color> generateLinearColorSequence(@NotNull List<Color> anchorColors, int colorsBetweenAnchors) {
|
||||
public static List<Color> generateLinearColorSequence(@NotNull List<? extends Color> anchorColors, int colorsBetweenAnchors) {
|
||||
assert colorsBetweenAnchors >= 0;
|
||||
if (anchorColors.isEmpty()) return Collections.singletonList(JBColor.GRAY);
|
||||
if (anchorColors.size() == 1) return Collections.singletonList(anchorColors.get(0));
|
||||
@@ -47,7 +47,7 @@ public class ColorGenerator {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<Color> generateLinearColorSequence(@NotNull Color color1, @NotNull Color color2, int colorsBetweenAnchors) {
|
||||
static List<Color> generateLinearColorSequence(@NotNull Color color1, @NotNull Color color2, int colorsBetweenAnchors) {
|
||||
assert colorsBetweenAnchors >= 0;
|
||||
|
||||
List<Color> result = new ArrayList<>(colorsBetweenAnchors + 2);
|
||||
@@ -69,7 +69,7 @@ public class ColorGenerator {
|
||||
}
|
||||
|
||||
private static int ratio(int val1, int val2, float ratio) {
|
||||
int value = (int)(val1 + ((val2 - val1) * ratio));
|
||||
int value = (int)(val1 + (val2 - val1) * ratio);
|
||||
return Math.max(Math.min(value, 255), 0);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-13
@@ -8,6 +8,7 @@ import com.intellij.codeHighlighting.RainbowHighlighter;
|
||||
import com.intellij.codeInsight.daemon.UsedColors;
|
||||
import com.intellij.ide.highlighter.HighlighterFactory;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.EditorSchemeAttributeDescriptor;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
@@ -39,8 +40,6 @@ import java.awt.event.MouseMotionAdapter;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import static com.intellij.openapi.editor.colors.CodeInsightColors.BLINKING_HIGHLIGHTS_ATTRIBUTES;
|
||||
|
||||
public class SimpleEditorPreview implements PreviewPanel {
|
||||
private static final Map<String, TextAttributesKey> INLINE_ELEMENTS = new HashMap<>();
|
||||
static {
|
||||
@@ -100,12 +99,6 @@ public class SimpleEditorPreview implements PreviewPanel {
|
||||
return myEditor;
|
||||
}
|
||||
|
||||
public void setDemoText(final String text) {
|
||||
myEditor.getSelectionModel().removeSelection();
|
||||
myHighlightData.clear();
|
||||
myEditor.getDocument().setText(myHighlightsExtractor.extractHighlights(text, myHighlightData));
|
||||
}
|
||||
|
||||
private void navigate(boolean select, @NotNull final LogicalPosition pos) {
|
||||
int offset = myEditor.logicalPositionToOffset(pos);
|
||||
final SyntaxHighlighter highlighter = myPage.getHighlighter();
|
||||
@@ -217,7 +210,7 @@ public class SimpleEditorPreview implements PreviewPanel {
|
||||
}
|
||||
}
|
||||
|
||||
void scrollHighlightInView(@Nullable final List<HighlightData> highlightDatas) {
|
||||
private void scrollHighlightInView(@Nullable final List<? extends HighlightData> highlightDatas) {
|
||||
if (highlightDatas == null) return;
|
||||
|
||||
boolean needScroll = true;
|
||||
@@ -242,7 +235,7 @@ public class SimpleEditorPreview implements PreviewPanel {
|
||||
.contains(myEditor.logicalPositionToXY(myEditor.offsetToLogicalPosition(startOffset)));
|
||||
}
|
||||
|
||||
public void stopBlinking() {
|
||||
private void stopBlinking() {
|
||||
myBlinkingAlarm.cancelAllRequests();
|
||||
}
|
||||
|
||||
@@ -275,8 +268,9 @@ public class SimpleEditorPreview implements PreviewPanel {
|
||||
TextAttributesKey[] tokenHighlights = highlighter.getTokenHighlights(tokenType);
|
||||
for (final TextAttributesKey tokenHighlight : tokenHighlights) {
|
||||
String type = tokenHighlight.getExternalName();
|
||||
if (type != null && type.equals(attrKey)) {
|
||||
HighlightData highlightData = new HighlightData(iterator.getStart(), iterator.getEnd(), BLINKING_HIGHLIGHTS_ATTRIBUTES);
|
||||
if (type.equals(attrKey)) {
|
||||
HighlightData highlightData = new HighlightData(iterator.getStart(), iterator.getEnd(),
|
||||
CodeInsightColors.BLINKING_HIGHLIGHTS_ATTRIBUTES);
|
||||
highlights.add(highlightData);
|
||||
matchingHighlights.add(highlightData);
|
||||
}
|
||||
@@ -327,7 +321,7 @@ public class SimpleEditorPreview implements PreviewPanel {
|
||||
myEditor.getContentComponent().setCursor(cursor);
|
||||
}
|
||||
|
||||
public void setupRainbow(@NotNull EditorColorsScheme colorsScheme, @NotNull RainbowColorSettingsPage page) {
|
||||
void setupRainbow(@NotNull EditorColorsScheme colorsScheme, @NotNull RainbowColorSettingsPage page) {
|
||||
final List<HighlightData> initialMarkup = new ArrayList<>();
|
||||
myHighlightsExtractor.extractHighlights(page.getDemoText(), initialMarkup);
|
||||
final List<HighlightData> rainbowMarkup = setupRainbowHighlighting(
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class EditorColorPaletteTest extends LightPlatformTestCase {
|
||||
// rainbow generated colors are cached:
|
||||
assertNotNull(colorsScheme.getAttributes(generatedRainbowKey));
|
||||
|
||||
// chage in colorsScheme for non-mutable key drops generated cache
|
||||
// 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));
|
||||
|
||||
Reference in New Issue
Block a user