use of com.intellij.codeInspection.SuppressIntentionAction in project intellij-community by JetBrains.
the class SuppressableInspectionTreeNode method getOnlyAvailableSuppressActions.
@NotNull
private Set<SuppressIntentionAction> getOnlyAvailableSuppressActions(@NotNull Project project) {
final Set<SuppressIntentionAction> actions = getSuppressActions();
if (actions.isEmpty()) {
return Collections.emptySet();
}
final Pair<PsiElement, CommonProblemDescriptor> suppress = getSuppressContent();
final PsiElement suppressElement = suppress.getFirst();
if (suppressElement == null) {
return actions;
}
Set<SuppressIntentionAction> availableActions = null;
for (SuppressIntentionAction action : actions) {
if (action.isAvailable(project, null, suppressElement)) {
if (availableActions == null) {
availableActions = ContainerUtil.newConcurrentSet(TObjectHashingStrategy.IDENTITY);
}
availableActions.add(action);
}
}
return availableActions == null ? Collections.emptySet() : availableActions;
}
use of com.intellij.codeInspection.SuppressIntentionAction in project intellij-community by JetBrains.
the class SuppressActionWrapper method getChildren.
@Override
@NotNull
public AnAction[] getChildren(@Nullable final AnActionEvent e) {
final InspectionResultsView view = getView(e);
if (view == null)
return AnAction.EMPTY_ARRAY;
final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(true);
if (wrapper == null)
return AnAction.EMPTY_ARRAY;
final Set<SuppressIntentionAction> suppressActions = view.getSuppressActions(wrapper);
if (suppressActions.isEmpty())
return AnAction.EMPTY_ARRAY;
final AnAction[] actions = new AnAction[suppressActions.size() + 1];
int i = 0;
for (SuppressIntentionAction action : suppressActions) {
actions[i++] = new SuppressTreeAction(action);
}
actions[suppressActions.size()] = Separator.getInstance();
Arrays.sort(actions, new Comparator<AnAction>() {
@Override
public int compare(AnAction a1, AnAction a2) {
return getWeight(a1) - getWeight(a2);
}
public int getWeight(AnAction a) {
return a instanceof Separator ? 0 : ((SuppressTreeAction) a).isSuppressAll() ? 1 : -1;
}
});
return actions;
}
use of com.intellij.codeInspection.SuppressIntentionAction in project kotlin by JetBrains.
the class AbstractQuickFixTest method findActionWithText.
@Override
protected IntentionAction findActionWithText(String text) {
IntentionAction intention = super.findActionWithText(text);
if (intention != null)
return intention;
// Support warning suppression
int caretOffset = myEditor.getCaretModel().getOffset();
for (HighlightInfo highlight : doHighlighting()) {
if (highlight.startOffset <= caretOffset && caretOffset <= highlight.endOffset) {
ProblemGroup group = highlight.getProblemGroup();
if (group instanceof SuppressableProblemGroup) {
SuppressableProblemGroup problemGroup = (SuppressableProblemGroup) group;
PsiElement at = getFile().findElementAt(highlight.getActualStartOffset());
SuppressIntentionAction[] actions = problemGroup.getSuppressActions(at);
for (SuppressIntentionAction action : actions) {
if (action.getText().equals(text)) {
return action;
}
}
}
}
}
return null;
}
Aggregations