This commit is contained in:
Vladimir Krivosheev
2016-09-29 08:57:36 +02:00
parent bd5d0901fe
commit 8a44ee07b6
3 changed files with 9 additions and 20 deletions
@@ -792,7 +792,6 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme, Serial
return getFallbackAttributes(fallbackKey.getFallbackAttributeKey());
}
/**
* Looks for explicitly specified attributes either in the scheme or its parent scheme. No fallback keys are used.
*
@@ -808,7 +807,6 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme, Serial
return myParentScheme instanceof AbstractColorsScheme ? ((AbstractColorsScheme)myParentScheme).getDirectlyDefinedAttributes(key) : null;
}
protected static boolean containsValue(@Nullable TextAttributes attributes) {
return attributes != null && attributes.containsValue();
}
@@ -31,6 +31,7 @@ import java.util.Arrays;
import java.util.Collections;
import static com.intellij.openapi.editor.colors.FontPreferencesTest.*;
import static com.intellij.testFramework.Assertions.assertThat;
import static java.util.Collections.singletonList;
@SuppressWarnings("Duplicates")
@@ -198,17 +199,13 @@ public class EditorColorsSchemeImplTest extends EditorColorSchemeTestCase {
assertSame(result.second, fallbackAttrs);
}
public void testSaveNoInheritanceAndDefaults() throws Exception {
TextAttributes identifierAttrs = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME)
.getAttributes(DefaultLanguageHighlighterColors.IDENTIFIER);
TextAttributes declarationAttrs = identifierAttrs.clone();
Pair<EditorColorsScheme, TextAttributes> result =
doTestWriteRead(DefaultLanguageHighlighterColors.FUNCTION_DECLARATION, declarationAttrs);
TextAttributes fallbackAttrs = result.first.getAttributes(
DefaultLanguageHighlighterColors.FUNCTION_DECLARATION.getFallbackAttributeKey()
);
assertEquals(result.second, fallbackAttrs);
assertNotSame(result.second, fallbackAttrs);
public void testSaveNoInheritanceAndDefaults() {
TextAttributes declarationAttrs = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME)
.getAttributes(DefaultLanguageHighlighterColors.IDENTIFIER).clone();
Pair<EditorColorsScheme, TextAttributes> result = doTestWriteRead(DefaultLanguageHighlighterColors.FUNCTION_DECLARATION, declarationAttrs);
TextAttributes fallbackAttrs = result.first.getAttributes(DefaultLanguageHighlighterColors.FUNCTION_DECLARATION.getFallbackAttributeKey());
assertThat(result.second).isEqualTo(fallbackAttrs);
assertThat(result.second).isNotSameAs(fallbackAttrs);
}
public void testSaveInheritanceForEmptyAttrs() throws Exception {
@@ -225,7 +222,6 @@ public class EditorColorsSchemeImplTest extends EditorColorSchemeTestCase {
assertSame(fallbackAttrs, result.second);
}
public void testUpgradeFromVer141() throws Exception {
TextAttributesKey constKey = DefaultLanguageHighlighterColors.CONSTANT;
TextAttributesKey fallbackKey = constKey.getFallbackAttributeKey();
@@ -279,7 +275,6 @@ public class EditorColorsSchemeImplTest extends EditorColorSchemeTestCase {
TextAttributesKey.removeTextAttributesKey("C");
TextAttributesKey.removeTextAttributesKey("D");
}
}
public void testIdea152156() throws Exception {
@@ -311,6 +306,4 @@ public class EditorColorsSchemeImplTest extends EditorColorSchemeTestCase {
TextAttributesKey.removeTextAttributesKey(testKey.getExternalName());
}
}
}
@@ -22,7 +22,6 @@ import com.intellij.openapi.editor.colors.impl.AbstractColorsScheme;
import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.testFramework.LightPlatformTestCase;
import org.jdom.Element;
import org.jdom.input.DOMBuilder;
@@ -56,8 +55,7 @@ public abstract class EditorColorSchemeTestCase extends LightPlatformTestCase {
}
@NotNull
protected Pair<EditorColorsScheme, TextAttributes> doTestWriteRead(TextAttributesKey key, TextAttributes attributes)
throws WriteExternalException {
protected Pair<EditorColorsScheme, TextAttributes> doTestWriteRead(@NotNull TextAttributesKey key, @NotNull TextAttributes attributes) {
EditorColorsScheme defaultScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
EditorColorsScheme sourceScheme = (EditorColorsScheme)defaultScheme.clone();