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 4978f3180d57..9d62e35ad33b 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 @@ -20,6 +20,7 @@ import com.intellij.codeInsight.CodeInsightActionHandler; import com.intellij.codeInsight.CodeInsightBundle; import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.codeInsight.actions.BaseCodeInsightAction; +import com.intellij.codeInsight.hint.HintManager; import com.intellij.codeInsight.navigation.NavigationUtil; import com.intellij.featureStatistics.FeatureUsageTracker; import com.intellij.ide.util.DefaultPsiElementCellRenderer; @@ -65,10 +66,9 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) { PsiDocumentManager.getInstance(project).commitAllDocuments(); - PsiElement element; try { int offset = editor.getCaretModel().getOffset(); - element = findTargetElement(project, editor, offset); + PsiElement element = findTargetElement(project, editor, offset); if (element == null) { FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.declaration"); chooseAmbiguousTarget(editor, offset); @@ -109,7 +109,10 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code return true; } }; - chooseAmbiguousTarget(editor, offset,navigateProcessor, CodeInsightBundle.message("declaration.navigation.title")); + boolean found = chooseAmbiguousTarget(editor, offset, navigateProcessor, CodeInsightBundle.message("declaration.navigation.title")); + if (!found) { + HintManager.getInstance().showErrorHint(editor, "Cannot find declaration to go to"); + } } // returns true if processor is run or is going to be run after showing popup @@ -127,7 +130,7 @@ public class GotoDeclarationAction extends BaseCodeInsightAction implements Code processor.execute(element); return true; } - else if (candidates.size() > 1) { + if (candidates.size() > 1) { PsiElement[] elements = candidates.toArray(new PsiElement[candidates.size()]); final TextRange range = reference.getRangeInElement(); final String refText = range.substring(reference.getElement().getText()); diff --git a/platform/lang-impl/src/com/intellij/ide/util/DefaultPsiElementCellRenderer.java b/platform/lang-impl/src/com/intellij/ide/util/DefaultPsiElementCellRenderer.java index 4581b24eb125..ea90cb413355 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/DefaultPsiElementCellRenderer.java +++ b/platform/lang-impl/src/com/intellij/ide/util/DefaultPsiElementCellRenderer.java @@ -20,7 +20,7 @@ import com.intellij.openapi.util.Iconable; import com.intellij.psi.PsiElement; import com.intellij.psi.presentation.java.SymbolPresentationUtil; -public class DefaultPsiElementCellRenderer extends PsiElementListCellRenderer { +public class DefaultPsiElementCellRenderer extends PsiElementListCellRenderer { protected int getIconFlags() { return Iconable.ICON_FLAG_VISIBILITY; } @@ -33,4 +33,4 @@ public class DefaultPsiElementCellRenderer extends PsiElementListCellRenderer { return SymbolPresentationUtil.getSymbolContainerText(element); } -} \ No newline at end of file +} diff --git a/platform/lang-impl/src/com/intellij/ide/util/PsiElementListCellRenderer.java b/platform/lang-impl/src/com/intellij/ide/util/PsiElementListCellRenderer.java index 278cd1f1e4e2..893b28f93dac 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/PsiElementListCellRenderer.java +++ b/platform/lang-impl/src/com/intellij/ide/util/PsiElementListCellRenderer.java @@ -99,12 +99,11 @@ public abstract class PsiElementListCellRenderer extends J } } - SimpleTextAttributes nameAttributes; if (isProblemFile) { attributes = TextAttributes.merge(new TextAttributes(color, null, Color.red, EffectType.WAVE_UNDERSCORE, Font.PLAIN),attributes); } - nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes):null; + SimpleTextAttributes nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : null; if (nameAttributes == null) nameAttributes = new SimpleTextAttributes(Font.PLAIN, color);