use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class OfflineInspectionRVContentProvider method excludeProblem.
private static void excludeProblem(final String externalName, final Map<String, Set<OfflineProblemDescriptor>> content) {
for (Iterator<String> iter = content.keySet().iterator(); iter.hasNext(); ) {
final String packageName = iter.next();
final Set<OfflineProblemDescriptor> excluded = new HashSet<>(content.get(packageName));
for (Iterator<OfflineProblemDescriptor> it = excluded.iterator(); it.hasNext(); ) {
final OfflineProblemDescriptor ex = it.next();
if (Comparing.strEqual(ex.getFQName(), externalName)) {
it.remove();
}
}
if (excluded.isEmpty()) {
iter.remove();
} else {
content.put(packageName, excluded);
}
}
}
use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class ScopeTreeViewPanel method getSelectedPsiElements.
@NotNull
private PsiElement[] getSelectedPsiElements() {
final TreePath[] treePaths = myTree.getSelectionPaths();
if (treePaths != null) {
Set<PsiElement> result = new HashSet<>();
for (TreePath path : treePaths) {
final Object component = path.getLastPathComponent();
if (component instanceof PackageDependenciesNode) {
PackageDependenciesNode node = (PackageDependenciesNode) component;
final PsiElement psiElement = node.getPsiElement();
if (psiElement != null && psiElement.isValid()) {
result.add(psiElement);
}
}
}
return PsiUtilCore.toPsiElementArray(result);
}
return PsiElement.EMPTY_ARRAY;
}
use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class SafeDeleteHandler method invoke.
public static void invoke(final Project project, PsiElement[] elements, @Nullable Module module, boolean checkDelegates, @Nullable final Runnable successRunnable) {
for (PsiElement element : elements) {
if (!SafeDeleteProcessor.validElement(element)) {
return;
}
}
final PsiElement[] temptoDelete = PsiTreeUtil.filterAncestors(elements);
Set<PsiElement> elementsSet = new HashSet<>(Arrays.asList(temptoDelete));
Set<PsiElement> fullElementsSet = new LinkedHashSet<>();
if (checkDelegates) {
for (PsiElement element : temptoDelete) {
boolean found = false;
for (SafeDeleteProcessorDelegate delegate : Extensions.getExtensions(SafeDeleteProcessorDelegate.EP_NAME)) {
if (delegate.handlesElement(element)) {
found = true;
Collection<? extends PsiElement> addElements = delegate instanceof SafeDeleteProcessorDelegateBase ? ((SafeDeleteProcessorDelegateBase) delegate).getElementsToSearch(element, module, elementsSet) : delegate.getElementsToSearch(element, elementsSet);
if (addElements == null)
return;
fullElementsSet.addAll(addElements);
break;
}
}
if (!found) {
fullElementsSet.add(element);
}
}
} else {
ContainerUtil.addAll(fullElementsSet, temptoDelete);
}
if (!CommonRefactoringUtil.checkReadOnlyStatusRecursively(project, fullElementsSet, true))
return;
final PsiElement[] elementsToDelete = PsiUtilCore.toPsiElementArray(fullElementsSet);
if (ApplicationManager.getApplication().isUnitTestMode()) {
RefactoringSettings settings = RefactoringSettings.getInstance();
SafeDeleteProcessor.createInstance(project, null, elementsToDelete, settings.SAFE_DELETE_SEARCH_IN_COMMENTS, settings.SAFE_DELETE_SEARCH_IN_NON_JAVA, true).run();
if (successRunnable != null)
successRunnable.run();
} else {
final SafeDeleteDialog.Callback callback = new SafeDeleteDialog.Callback() {
@Override
public void run(final SafeDeleteDialog dialog) {
SafeDeleteProcessor.createInstance(project, () -> {
if (successRunnable != null) {
successRunnable.run();
}
dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
}, elementsToDelete, dialog.isSearchInComments(), dialog.isSearchForTextOccurences(), true).run();
}
};
SafeDeleteDialog dialog = new SafeDeleteDialog(project, elementsToDelete, callback);
dialog.show();
}
}
use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class AbstractTreeUi method getChildrenFor.
//todo [kirillk] temporary consistency check
private Object[] getChildrenFor(final Object element) {
final Ref<Object[]> passOne = new Ref<>();
try (LockToken ignored = acquireLock()) {
execute(new TreeRunnable("AbstractTreeUi.getChildrenFor") {
@Override
public void perform() {
passOne.set(getTreeStructure().getChildElements(element));
}
});
} catch (IndexNotReadyException e) {
warnOnIndexNotReady(e);
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
if (!Registry.is("ide.tree.checkStructure"))
return passOne.get();
final Object[] passTwo = getTreeStructure().getChildElements(element);
final HashSet<Object> two = new HashSet<>(Arrays.asList(passTwo));
if (passOne.get().length != passTwo.length) {
LOG.error("AbstractTreeStructure.getChildren() must either provide same objects or new objects but with correct hashCode() and equals() methods. Wrong parent element=" + element);
} else {
for (Object eachInOne : passOne.get()) {
if (!two.contains(eachInOne)) {
LOG.error("AbstractTreeStructure.getChildren() must either provide same objects or new objects but with correct hashCode() and equals() methods. Wrong parent element=" + element);
break;
}
}
}
return passOne.get();
}
use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class SearchResults method updateExcluded.
private void updateExcluded() {
Set<RangeMarker> invalid = new HashSet<>();
for (RangeMarker marker : myExcluded) {
if (!marker.isValid()) {
invalid.add(marker);
marker.dispose();
}
}
myExcluded.removeAll(invalid);
}
Aggregations