mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-34452 "No declaration found" feedback added
This commit is contained in:
+7
-4
@@ -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());
|
||||
|
||||
@@ -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<PsiElement> {
|
||||
protected int getIconFlags() {
|
||||
return Iconable.ICON_FLAG_VISIBILITY;
|
||||
}
|
||||
@@ -33,4 +33,4 @@ public class DefaultPsiElementCellRenderer extends PsiElementListCellRenderer {
|
||||
return SymbolPresentationUtil.getSymbolContainerText(element);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,12 +99,11 @@ public abstract class PsiElementListCellRenderer<T extends PsiElement> 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user