@Nullable annotation & NPE fix
authorVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Fri, 28 Nov 2014 14:58:06 +0000 (17:58 +0300)
committerVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Fri, 28 Nov 2014 14:58:06 +0000 (17:58 +0300)
platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java
platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/DefaultColorsScheme.java
platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java
platform/lang-impl/src/com/intellij/ide/bookmarks/Bookmark.java
platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java
platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java
platform/platform-impl/src/com/intellij/ui/EditorTextField.java
plugins/terminal/src/org/jetbrains/plugins/terminal/JBTerminalSystemSettingsProvider.java

index c54b44153f913f629075d77b69a80e76e9d69f76..d19658d588fbf70ad023344d206a18db7a7f6af0 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.openapi.options.Scheme;
 import com.intellij.openapi.util.JDOMExternalizable;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import java.awt.*;
 
@@ -36,6 +37,7 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, TextA
   @NotNull
   Color getDefaultForeground();
 
+  @Nullable
   Color getColor(ColorKey key);
   void setColor(ColorKey key, Color color);
 
index 54b6d061eee8c2c3d41bc8f9367300b3049dec1c..7c907d1c607b099090c86d96e42565dbc274c9ed 100644 (file)
@@ -53,6 +53,7 @@ public class DefaultColorsScheme extends AbstractColorsScheme implements ReadOnl
     return attrs;
   }
 
+  @Nullable
   @Override
   public Color getColor(ColorKey key) {
     if (key == null) return null;
index c4bf8be2ca4c7c9d8482ec072fa8a730061d5b97..1fc6e1fa4f0677c32c2b9931cd1ee08692c25bfc 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.options.ExternalInfo;
 import com.intellij.openapi.options.ExternalizableScheme;
 import com.intellij.openapi.util.Comparing;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import java.awt.*;
 
@@ -73,6 +74,7 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte
     return myAttributesMap.containsKey(key);
   }
 
+  @Nullable
   @Override
   public Color getColor(ColorKey key) {
     if (myColorsMap.containsKey(key)) {
index 7401472ef1714fe2f0975ad6b2f0e0a8b9ba9be2..fca1bd2086437ecd51af1f9211756208d88f425f 100644 (file)
@@ -359,7 +359,11 @@ public class Bookmark implements Navigatable {
   }
 
   private static boolean darkBackground() {
-    return ColorUtil.isDark(EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.GUTTER_BACKGROUND));
+    Color gutterBackground = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.GUTTER_BACKGROUND);
+    if (gutterBackground == null) {
+      gutterBackground = EditorColors.GUTTER_BACKGROUND.getDefaultColor();
+    }
+    return ColorUtil.isDark(gutterBackground);
   }
 
   private static class MyGutterIconRenderer extends GutterIconRenderer {
index de856c86aee5daf12cbd61889f23830ad2e9f9f8..1089d5e54e3e4c9ffd2121328b16a09e76f93ff0 100644 (file)
@@ -72,6 +72,7 @@ public abstract class DelegateColorScheme implements EditorColorsScheme {
     return myDelegate.getDefaultForeground();
   }
 
+  @Nullable
   @Override
   public Color getColor(ColorKey key) {
     return myDelegate.getColor(key);
index a4e0e7a4be1d78deebecf963704347550ff5c855..40eb995f1dbdb810d75ef0a4063eb0219be00155 100644 (file)
@@ -6068,6 +6068,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
       myOwnAttributes.put(key, attributes);
     }
 
+    @Nullable
     @Override
     public Color getColor(ColorKey key) {
       if (myOwnColors.containsKey(key)) return myOwnColors.get(key);
index 5c1bffb8ee561200aac30d75695e8df1b82901e6..45e41537f67376027246560e4572422b29525d6f 100644 (file)
@@ -493,6 +493,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
     colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null);
     if (!isEnabled()) {
       editor.setColorsScheme(new DelegateColorScheme(colorsScheme) {
+        @Nullable
         @Override
         public Color getColor(ColorKey key) {
           return super.getColor(key);
index dbc4ee5c13b6fe0b2df32ac84168880a9e0723e6..b805b7863780ec1a0433046c792b9c26e7d1a34d 100644 (file)
@@ -308,6 +308,7 @@ public class JBTerminalSystemSettingsProvider extends DefaultTabbedSettingsProvi
       return getGlobal().getDefaultForeground();
     }
 
+    @Nullable
     @Override
     public Color getColor(ColorKey key) {
       if (myOwnColors.containsKey(key)) return myOwnColors.get(key);