mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
http://ea.jetbrains.com/browser/ea_problems/16004?report=194214 call isAvailable() before getText()
This commit is contained in:
+1
-1
@@ -308,7 +308,7 @@ public class IntentionHintComponent extends JPanel implements Disposable, Scroll
|
||||
myPopupShown = true;
|
||||
}
|
||||
|
||||
void recreateMyPopup(IntentionListStep step) {
|
||||
private void recreateMyPopup(IntentionListStep step) {
|
||||
if (myPopup != null) {
|
||||
Disposer.dispose(myPopup);
|
||||
}
|
||||
|
||||
+7
-5
@@ -30,7 +30,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.*;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
@@ -99,9 +98,10 @@ class IntentionListStep implements ListPopupStep<IntentionActionWithTextCaching>
|
||||
else {
|
||||
element = InjectedLanguageUtil.findElementAtNoCommit(myFile, fileOffset);
|
||||
}
|
||||
boolean result = true;
|
||||
boolean result = removeInvalidActions(cachedActions, element);
|
||||
for (HighlightInfo.IntentionActionDescriptor descriptor : descriptors) {
|
||||
IntentionAction action = descriptor.getAction();
|
||||
if (!isAvailable(action, element)) continue;
|
||||
IntentionActionWithTextCaching cachedAction = new IntentionActionWithTextCaching(action, descriptor.getDisplayName(), descriptor.getIcon());
|
||||
result &= !cachedActions.add(cachedAction);
|
||||
if (element == null) continue;
|
||||
@@ -124,7 +124,6 @@ class IntentionListStep implements ListPopupStep<IntentionActionWithTextCaching>
|
||||
}
|
||||
}
|
||||
}
|
||||
result &= removeInvalidActions(cachedActions, element);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -134,8 +133,7 @@ class IntentionListStep implements ListPopupStep<IntentionActionWithTextCaching>
|
||||
while (iterator.hasNext()) {
|
||||
IntentionActionWithTextCaching cachedAction = iterator.next();
|
||||
IntentionAction action = cachedAction.getAction();
|
||||
Pair<PsiFile,Editor> place = ShowIntentionActionsHandler.availableFor(myFile, myEditor, action, element);
|
||||
if (place == null) {
|
||||
if (!isAvailable(action, element)) {
|
||||
iterator.remove();
|
||||
result = false;
|
||||
}
|
||||
@@ -143,6 +141,10 @@ class IntentionListStep implements ListPopupStep<IntentionActionWithTextCaching>
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isAvailable(IntentionAction action, PsiElement element) {
|
||||
return ShowIntentionActionsHandler.availableFor(myFile, myEditor, action, element) != null;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user