From b648247f188ecc96b82537645e71697cfdc775df Mon Sep 17 00:00:00 2001 From: Nicolay Mitropolsky Date: Fri, 4 May 2018 18:06:00 +0300 Subject: [PATCH] MergeableLineMarkerInfo: removing assert on nullable element in `LineMarkerInfo` because actually it could be `null` if gutter outlasts the element it was put on (EA-119661) IDEA-CR-32349 --- .../daemon/MergeableLineMarkerInfo.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/platform/lang-api/src/com/intellij/codeInsight/daemon/MergeableLineMarkerInfo.java b/platform/lang-api/src/com/intellij/codeInsight/daemon/MergeableLineMarkerInfo.java index b9a7e1ac64b4..faa8fd913933 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/daemon/MergeableLineMarkerInfo.java +++ b/platform/lang-api/src/com/intellij/codeInsight/daemon/MergeableLineMarkerInfo.java @@ -1,6 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.daemon; +import com.intellij.ide.IdeBundle; import com.intellij.openapi.editor.markup.GutterIconRenderer; import com.intellij.openapi.ui.popup.IPopupChooserBuilder; import com.intellij.openapi.ui.popup.JBPopupFactory; @@ -144,11 +145,16 @@ public abstract class MergeableLineMarkerInfo extends Line icon = renderer.getIcon(); } PsiElement element = ((LineMarkerInfo)dom).getElement(); - assert element != null; - final String elementPresentation = - dom instanceof MergeableLineMarkerInfo - ? ((MergeableLineMarkerInfo)dom).getElementPresentation(element) - : element.getText(); + final String elementPresentation; + if (element == null) { + elementPresentation = IdeBundle.message("node.structureview.invalid"); + } + else if (dom instanceof MergeableLineMarkerInfo) { + elementPresentation = ((MergeableLineMarkerInfo)dom).getElementPresentation(element); + } + else { + elementPresentation = element.getText(); + } String text = StringUtil.first(elementPresentation, 100, true).replace('\n', ' '); final JBLabel label = new JBLabel(text, icon, SwingConstants.LEFT);