https://ea.jetbrains.com/browser/ea_problems/60655
authorVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Wed, 24 Sep 2014 08:20:38 +0000 (12:20 +0400)
committerVassiliy.Kudryashov <Vassiliy.Kudryashov@jetbrains.com>
Wed, 24 Sep 2014 08:21:46 +0000 (12:21 +0400)
NPE: HintManagerImpl._getHintPosition

platform/platform-impl/src/com/intellij/codeInsight/hint/HintManagerImpl.java

index 6c7a28854914a1e64829ce7fc49eb6011c242325..3d2a61020be4c0f54f5baee817737de48bc80504 100644 (file)
@@ -626,26 +626,34 @@ public class HintManagerImpl extends HintManager implements Disposable {
     int col2 = pos2.column;
 
     Point location;
     int col2 = pos2.column;
 
     Point location;
-    JLayeredPane layeredPane = editor.getComponent().getRootPane().getLayeredPane();
+    @NotNull JComponent externalComponent = editor.getComponent();
+    JRootPane rootPane = externalComponent.getRootPane();
+    if (rootPane != null) {
+      externalComponent = rootPane;
+      JLayeredPane layeredPane = rootPane.getLayeredPane();
+      if (layeredPane != null) {
+        externalComponent = layeredPane;
+      }
+    }
     JComponent internalComponent = editor.getContentComponent();
     if (constraint == RIGHT_UNDER) {
       Point p = editor.logicalPositionToXY(new LogicalPosition(line2, col2));
       if (!showByBalloon) {
         p.y += editor.getLineHeight();
       }
     JComponent internalComponent = editor.getContentComponent();
     if (constraint == RIGHT_UNDER) {
       Point p = editor.logicalPositionToXY(new LogicalPosition(line2, col2));
       if (!showByBalloon) {
         p.y += editor.getLineHeight();
       }
-      location = SwingUtilities.convertPoint(internalComponent, p, layeredPane);
+      location = SwingUtilities.convertPoint(internalComponent, p, externalComponent);
     }
     else {
       Point p = editor.logicalPositionToXY(new LogicalPosition(line1, col1));
       if (constraint == UNDER) {
         p.y += editor.getLineHeight();
       }
     }
     else {
       Point p = editor.logicalPositionToXY(new LogicalPosition(line1, col1));
       if (constraint == UNDER) {
         p.y += editor.getLineHeight();
       }
-      location = SwingUtilities.convertPoint(internalComponent, p, layeredPane);
+      location = SwingUtilities.convertPoint(internalComponent, p, externalComponent);
     }
 
     if (constraint == ABOVE && !showByBalloon) {
       location.y -= hintSize.height;
     }
 
     if (constraint == ABOVE && !showByBalloon) {
       location.y -= hintSize.height;
-      int diff = location.x + hintSize.width - layeredPane.getWidth();
+      int diff = location.x + hintSize.width - externalComponent.getWidth();
       if (diff > 0) {
         location.x = Math.max(location.x - diff, 0);
       }
       if (diff > 0) {
         location.x = Math.max(location.x - diff, 0);
       }