diff --git a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java index f5cd8511e5cb..a03eb5f0a2c2 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/navigation/actions/GotoDeclarationAction.java @@ -146,7 +146,9 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code } if (elements.length > 1) { final TextRange range = reference.getRangeInElement(); - final String refText = range.substring(reference.getElement().getText()); + final String elementText = reference.getElement().getText(); + LOG.assertTrue(range.getStartOffset() >= 0 && range.getEndOffset() <= elementText.length(), reference); + final String refText = range.substring(elementText); String title = MessageFormat.format(titlePattern, refText); NavigationUtil.getPsiElementPopup(elements, new DefaultPsiElementCellRenderer(), title, processor).showInBestPositionFor(editor); return true;