use of com.intellij.codeInsight.intention.impl.IntentionListStep in project intellij-community by JetBrains.
the class CodeInsightTestFixtureImpl method doGetAvailableIntentions.
@NotNull
private static List<IntentionAction> doGetAvailableIntentions(@NotNull Editor editor, @NotNull PsiFile file) {
ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo();
ShowIntentionsPass.getActionsToShow(editor, file, intentions, -1);
List<IntentionAction> result = new ArrayList<>();
IntentionListStep intentionListStep = new IntentionListStep(null, intentions, editor, file, file.getProject());
for (Map.Entry<IntentionAction, List<IntentionAction>> entry : intentionListStep.getActionsWithSubActions().entrySet()) {
result.add(entry.getKey());
result.addAll(entry.getValue());
}
List<HighlightInfo> infos = DaemonCodeAnalyzerEx.getInstanceEx(file.getProject()).getFileLevelHighlights(file.getProject(), file);
for (HighlightInfo info : infos) {
for (Pair<HighlightInfo.IntentionActionDescriptor, TextRange> pair : info.quickFixActionRanges) {
HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first;
if (actionInGroup.getAction().isAvailable(file.getProject(), editor, file)) {
result.add(actionInGroup.getAction());
List<IntentionAction> options = actionInGroup.getOptions(file, editor);
if (options != null) {
for (IntentionAction subAction : options) {
if (subAction.isAvailable(file.getProject(), editor, file)) {
result.add(subAction);
}
}
}
}
}
}
return result;
}
use of com.intellij.codeInsight.intention.impl.IntentionListStep in project intellij-community by JetBrains.
the class ResourceBundleEditorShowQuickFixesAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final ResourceBundleEditor editor = getEditor(e);
LOG.assertTrue(editor != null);
final ResourceBundlePropertyStructureViewElement element = (ResourceBundlePropertyStructureViewElement) editor.getSelectedElementIfOnlyOne();
LOG.assertTrue(element != null);
final PsiFile file = editor.getResourceBundle().getDefaultPropertiesFile().getContainingFile();
final ShowIntentionsPass.IntentionsInfo intentions = new ShowIntentionsPass.IntentionsInfo();
boolean isQuickFixListEmpty = true;
Pair<ResourceBundleEditorProblemDescriptor, HighlightDisplayKey>[] descriptorsAndSources = element.getProblemDescriptors();
for (Pair<ResourceBundleEditorProblemDescriptor, HighlightDisplayKey> p : descriptorsAndSources) {
final ResourceBundleEditorProblemDescriptor d = p.getFirst();
final HighlightDisplayKey sourceKey = p.getSecond();
QuickFix[] fixes = d.getFixes();
if (fixes != null) {
for (int i = 0; i < fixes.length; i++) {
intentions.inspectionFixesToShow.add(new HighlightInfo.IntentionActionDescriptor(new RBEQuickFixWrapper(d, i), null, null, AllIcons.Actions.IntentionBulb, sourceKey, null, null));
isQuickFixListEmpty = false;
}
}
}
if (isQuickFixListEmpty) {
return;
}
final Project project = e.getProject();
LOG.assertTrue(project != null);
JBPopupFactory.getInstance().createListPopup(new IntentionListStep(null, intentions, null, file, project)).showInBestPositionFor(e.getDataContext());
}
Aggregations