ContainerUtil.newHashSet -> new HashSet<>

This commit is contained in:
Tagir Valeev
2019-03-13 16:32:54 +07:00
parent c0ba70d70c
commit 7abc8c2cb3
45 changed files with 96 additions and 91 deletions
@@ -1333,7 +1333,7 @@ public class HighlightUtil extends HighlightUtilBase {
final int idx = ArrayUtilRt.find(allCatchSections, catchSection);
if (idx <= 0) return null;
final Collection<PsiClassType> thrownTypes = ContainerUtil.newHashSet(thrownInTryStatement);
final Collection<PsiClassType> thrownTypes = new java.util.HashSet<>(thrownInTryStatement);
final PsiManager manager = containingFile.getManager();
final GlobalSearchScope parameterResolveScope = parameter.getResolveScope();
thrownTypes.add(PsiType.getJavaLangError(manager, parameterResolveScope));
@@ -1350,7 +1350,7 @@ public class HighlightUtil extends HighlightUtilBase {
final Collection<PsiClassType> caught =
ContainerUtil.findAll(thrownTypes, type -> catchType.isAssignableFrom(type) || type.isAssignableFrom(catchType));
if (caught.isEmpty()) continue;
final Collection<PsiClassType> caughtCopy = ContainerUtil.newHashSet(caught);
final Collection<PsiClassType> caughtCopy = new java.util.HashSet<>(caught);
// exclude all which are caught by previous catch sections
for (int i = 0; i < idx; i++) {
@@ -195,7 +195,7 @@ class StateMerger {
@NotNull Set<Fact> memberFacts,
@NotNull DfaMemoryStateImpl state) {
Set<DfaConstValue> otherInequalities = ContainerUtil.newLinkedHashSet();
Set<DfaValue> eqValues = ContainerUtil.newHashSet(state.getEquivalentValues(removedFact.myArg));
Set<DfaValue> eqValues = new HashSet<>(state.getEquivalentValues(removedFact.myArg));
for (Fact candidate : memberFacts) {
if (!(candidate instanceof EqualityFact)) continue;
EqualityFact equality = (EqualityFact)candidate;
@@ -82,7 +82,7 @@ public class JavaPsiImplementationHelperImpl extends JavaPsiImplementationHelper
ProjectFileIndex idx = ProjectRootManager.getInstance(myProject).getFileIndex();
if (vFile != null && idx.isInLibrarySource(vFile)) {
GlobalSearchScope librariesScope = LibraryScopeCache.getInstance(myProject).getLibrariesOnlyScope();
Set<OrderEntry> originalEntries = ContainerUtil.newHashSet(idx.getOrderEntriesForFile(vFile));
Set<OrderEntry> originalEntries = new HashSet<>(idx.getOrderEntriesForFile(vFile));
for (T candidate : candidateFinder.apply(librariesScope)) {
PsiFile candidateFile = candidate.getContainingFile();
if (candidateFile != null) {
@@ -359,7 +359,7 @@ public abstract class NullableNotNullManager {
@NotNull
protected Set<String> getAllNullabilityAnnotationsWithNickNames() {
Set<String> qNames = ContainerUtil.newHashSet(getNullablesWithNickNames());
Set<String> qNames = new HashSet<>(getNullablesWithNickNames());
qNames.addAll(getNotNullsWithNickNames());
return Collections.unmodifiableSet(qNames);
}
@@ -27,9 +27,9 @@ import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiClassOwner;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiPackage;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
public class PackageScope extends GlobalSearchScope {
@@ -48,8 +48,7 @@ public class PackageScope extends GlobalSearchScope {
Project project = myPackage.getProject();
myPackageQualifiedName = myPackage.getQualifiedName();
myDirs = ContainerUtil.newHashSet(
PackageIndex.getInstance(project).getDirsByPackageName(myPackageQualifiedName, true).findAll());
myDirs = new HashSet<>(PackageIndex.getInstance(project).getDirsByPackageName(myPackageQualifiedName, true).findAll());
myIncludeLibraries = includeLibraries;
myPartOfPackagePrefix = JavaPsiFacade.getInstance(getProject()).isPartOfPackagePrefix(myPackageQualifiedName);
@@ -8,7 +8,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Splitter;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.JBUI;
import org.jetbrains.annotations.NotNull;
@@ -17,6 +16,7 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;
import java.util.HashSet;
public class NullableNotNullDialog extends DialogWrapper {
private final Project myProject;
@@ -43,7 +43,7 @@ public class NullableNotNullDialog extends DialogWrapper {
"NotNull",
manager.getDefaultNotNull(),
manager.getNotNulls(), NullableNotNullManager.DEFAULT_NOT_NULLS,
ContainerUtil.newHashSet(manager.getInstrumentedNotNulls()), showInstrumentationOptions, true);
new HashSet<>(manager.getInstrumentedNotNulls()), showInstrumentationOptions, true);
init();
setTitle("Nullable/NotNull Configuration");
@@ -317,7 +317,7 @@ class JsonSchemaAnnotatorChecker {
for (Map.Entry<String, List<String>> entry : dependencies.entrySet()) {
if (set.contains(entry.getKey())) {
final List<String> list = entry.getValue();
HashSet<String> deps = ContainerUtil.newHashSet(list);
HashSet<String> deps = new HashSet<>(list);
deps.removeAll(set);
if (!deps.isEmpty()) {
JsonValidationError.MissingMultiplePropsIssueData data = createMissingPropertiesData(schema, deps);
@@ -870,7 +870,7 @@ class JsonSchemaAnnotatorChecker {
// also check maybe some currently not checked properties like format are different with schemes
// todo note that JsonSchemaObject#equals is broken by design, so normally it shouldn't be used until rewritten
// but for now we use it here to avoid similar schemas being marked as duplicates
if (ContainerUtil.newHashSet(correct).size() > 1 && !schemesDifferWithNotCheckedProperties(correct)) {
if (new HashSet<>(correct).size() > 1 && !schemesDifferWithNotCheckedProperties(correct)) {
error("Validates to more than one variant", value.getDelegate(), JsonErrorPriority.MEDIUM_PRIORITY);
}
}
@@ -511,7 +511,7 @@ public class JsonSchemaObject {
private void addAdditionalPropsNotAllowedFor(String url, String pointer) {
Set<String> newSet = myAdditionalPropertiesNotAllowedFor == null
? ContainerUtil.newHashSet()
: ContainerUtil.newHashSet(myAdditionalPropertiesNotAllowedFor);
: new HashSet<>(myAdditionalPropertiesNotAllowedFor);
newSet.add(url + pointer);
myAdditionalPropertiesNotAllowedFor = newSet;
}
@@ -20,10 +20,10 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -34,7 +34,7 @@ public class NonClasspathDirectoriesScope extends GlobalSearchScope {
private final Set<VirtualFile> myRoots;
public NonClasspathDirectoriesScope(@NotNull Collection<VirtualFile> roots) {
myRoots = ContainerUtil.newHashSet(roots);
myRoots = new HashSet<>(roots);
}
@Override
@@ -45,9 +45,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import static com.intellij.diff.util.DiffUtil.isUserDataFlagSet;
import static com.intellij.util.containers.ContainerUtil.list;
@@ -110,7 +108,7 @@ public class TextDiffViewerUtil {
public static void installDocumentListeners(@NotNull DocumentListener listener,
@NotNull List<? extends Document> documents,
@NotNull Disposable disposable) {
for (Document document : ContainerUtil.newHashSet(documents)) {
for (Document document : new HashSet<>((Collection<? extends Document>)documents)) {
document.addDocumentListener(listener, disposable);
}
}
@@ -160,7 +158,7 @@ public class TextDiffViewerUtil {
});
if (properties.size() < 2) return true;
return ContainerUtil.newHashSet(properties).size() == 1;
return new HashSet<>(properties).size() == 1;
}
//
@@ -433,7 +433,7 @@ public class ExternalProjectDataSelectorDialog extends DialogWrapper {
@NotNull
private static Set<Key<?>> getPublicKeys() {
Set<Key<?>> result = ContainerUtil.newHashSet(DATA_KEYS);
Set<Key<?>> result = new HashSet<>(DATA_KEYS);
for (ExternalProjectStructureCustomizer customizer : ExternalProjectStructureCustomizer.EP_NAME.getExtensions()) {
result.addAll(customizer.getPublicDataKeys());
}
@@ -442,7 +442,7 @@ public class ExternalProjectDataSelectorDialog extends DialogWrapper {
@NotNull
private static Set<Key<?>> getIgnorableKeys() {
Set<Key<?>> result = ContainerUtil.newHashSet(DATA_KEYS);
Set<Key<?>> result = new HashSet<>(DATA_KEYS);
for (ExternalProjectStructureCustomizer customizer : ExternalProjectStructureCustomizer.EP_NAME.getExtensions()) {
result.addAll(customizer.getIgnorableDataKeys());
}
@@ -41,7 +41,7 @@ public abstract class PostfixTemplatesUtils {
*/
@NotNull
public static Set<PostfixTemplate> getAvailableTemplates(@NotNull PostfixTemplateProvider provider) {
Set<PostfixTemplate> result = ContainerUtil.newHashSet(provider.getTemplates());
Set<PostfixTemplate> result = new HashSet<>(provider.getTemplates());
for (PostfixTemplate template : PostfixTemplateStorage.getInstance().getTemplates(provider)) {
if (template instanceof PostfixChangedBuiltinTemplate) {
result.remove(((PostfixChangedBuiltinTemplate)template).getBuiltinTemplate());
@@ -30,6 +30,7 @@ import javax.swing.*;
import javax.swing.event.DocumentEvent;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
/**
@@ -128,8 +129,8 @@ public class ConsoleConfigurable implements SearchableConfigurable, Configurable
@Override
public boolean isModified() {
EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
boolean isModified = !ContainerUtil.newHashSet(myNegativePanel.getListItems()).equals(ContainerUtil.newHashSet(mySettings.getNegativePatterns()));
isModified |= !ContainerUtil.newHashSet(myPositivePanel.getListItems()).equals(ContainerUtil.newHashSet(mySettings.getPositivePatterns()));
boolean isModified = !ContainerUtil.newHashSet(myNegativePanel.getListItems()).equals(new HashSet<>(mySettings.getNegativePatterns()));
isModified |= !ContainerUtil.newHashSet(myPositivePanel.getListItems()).equals(new HashSet<>(mySettings.getPositivePatterns()));
isModified |= isModified(myCbUseSoftWrapsAtConsole, editorSettings.isUseSoftWraps(SoftWrapAppliancePlaces.CONSOLE));
UISettings uiSettings = UISettings.getInstance();
isModified |= isModified(myCommandsHistoryLimitField, uiSettings.getConsoleCommandHistoryLimit());
@@ -16,14 +16,10 @@
package com.intellij.formatting;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.*;
public class AlignmentImpl extends Alignment {
private static final List<LeafBlockWrapper> EMPTY = Collections.emptyList();
@@ -137,7 +133,7 @@ public class AlignmentImpl extends Alignment {
}
public Set<LeafBlockWrapper> getOffsetResponsibleBlocks() {
return ContainerUtil.newHashSet(myOffsetRespBlocks);
return new HashSet<>(myOffsetRespBlocks);
}
@NotNull
@@ -38,6 +38,7 @@ import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.EventListener;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -303,7 +304,7 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
public static boolean isExcludedOrUnderExcludedDirectory(@Nullable Project project,
@NotNull ContentEntry entry,
@NotNull VirtualFile file) {
Set<String> excludedUrls = ContainerUtil.newHashSet(entry.getExcludeFolderUrls());
Set<String> excludedUrls = new HashSet<>(entry.getExcludeFolderUrls());
if (project != null) {
for (DirectoryIndexExcludePolicy policy : DirectoryIndexExcludePolicy.getExtensions(project)) {
ContainerUtil.addAll(excludedUrls, policy.getExcludeUrlsForProject());
@@ -42,7 +42,9 @@ import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.datatransfer.Transferable;
import java.awt.event.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
import java.util.*;
import java.util.stream.Stream;
@@ -485,7 +487,7 @@ public class InspectionsConfigTreeTable extends TreeTable {
result.put(currentScope, currentSeverity);
}
else {
Set<String> toolsToCheck = ContainerUtil.newHashSet(allScopes.keySet());
Set<String> toolsToCheck = new HashSet<>(allScopes.keySet());
toolsToCheck.removeAll(currentSeverityAndOccurrences.getOccurrences().keySet());
boolean doContinue = false;
final Map<String, HighlightSeverity> lowerScopeOccurrences = myScopeToAverageSeverityMap.get(myDefaultScopeName).getOccurrences();
@@ -34,10 +34,8 @@ import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* @author Roman.Shein
@@ -294,7 +292,7 @@ public class ExtractedSettingsDialog extends DialogWrapper {
protected JComponent buildExtractedSettingsTree() {
Collection<Value> unusedValues = ContainerUtil.newHashSet(myValues);
Collection<Value> unusedValues = new HashSet<>(myValues);
myRoot = new DefaultMutableTreeNode();
for (Map.Entry<LanguageCodeStyleSettingsProvider.SettingsType,
Map<CodeStyleSettingPresentation.SettingsGroup, List<CodeStyleSettingPresentation>>> typeEntry : myNameProvider.mySettings.entrySet()) {
@@ -236,7 +236,7 @@ public abstract class PerFileConfigurableBase<T> implements SearchableConfigurab
}
private void doAddFiles(@NotNull List<? extends VirtualFile> files) {
Set<VirtualFile> chosen = ContainerUtil.newHashSet(files);
Set<VirtualFile> chosen = new HashSet<>(files);
if (chosen.isEmpty()) return;
Set<Object> set = myModel.data.stream().map(o -> o.first).collect(Collectors.toSet());
for (VirtualFile file : chosen) {
@@ -756,7 +756,7 @@ public class Switcher extends AnAction implements DumbAware {
List<VirtualFile> recentFiles = EditorHistoryManager.getInstance(project).getFileList();
VirtualFile[] openFiles = FileEditorManager.getInstance(project).getOpenFiles();
Set<VirtualFile> recentFilesSet = ContainerUtil.newHashSet(recentFiles);
Set<VirtualFile> recentFilesSet = new HashSet<>(recentFiles);
Set<VirtualFile> openFilesSet = ContainerUtil.newHashSet(openFiles);
// Add missing FileEditor tabs right after the last one, that is available via "Recent Files"
@@ -21,11 +21,11 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.*;
import java.util.*;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
@@ -149,7 +149,7 @@ public class FileWatcher {
Set<String> result = null;
for (Collection<String> roots : manualWatchRoots) {
if (result == null) {
result = ContainerUtil.newHashSet(roots);
result = new HashSet<>(roots);
}
else {
result.retainAll(roots);
@@ -218,7 +218,7 @@ public class FileWatcher {
@Override
public void notifyManualWatchRoots(@NotNull Collection<String> roots) {
myManualWatchRoots.add(roots.isEmpty() ? Collections.emptySet() : ContainerUtil.newHashSet(roots));
myManualWatchRoots.add(roots.isEmpty() ? Collections.emptySet() : new HashSet<>(roots));
notifyOnEvent(OTHER);
}
@@ -32,7 +32,6 @@ import com.intellij.ui.components.panels.VerticalBox;
import com.intellij.ui.docking.*;
import com.intellij.ui.tabs.newImpl.JBTabsImpl;
import com.intellij.util.IconUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.update.UiNotifyConnector;
import org.jdom.Element;
@@ -47,8 +46,8 @@ import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List;
import java.util.*;
@State(name = "DockManager", storages = @Storage(StoragePathMacros.WORKSPACE_FILE))
@@ -111,7 +110,7 @@ public class DockManagerImpl extends DockManager implements PersistentStateCompo
@Override
public Set<DockContainer> getContainers() {
return Collections.unmodifiableSet(ContainerUtil.newHashSet(myContainers));
return Collections.unmodifiableSet(new HashSet<>(myContainers));
}
@Override
@@ -14,7 +14,6 @@ import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.speedSearch.ListWithFilter;
import com.intellij.util.BooleanFunction;
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -26,6 +25,7 @@ import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseListener;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -66,7 +66,7 @@ class PopupListAdapter<T> implements PopupChooserBuilder.PopupComponentAdapter<T
public void setItemsChosenCallback(Consumer<? super Set<T>> callback) {
myBuilder.setItemChoosenCallback(() -> {
List<T> list = myList.getSelectedValuesList();
callback.consume(list != null ? ContainerUtil.newHashSet(list) : Collections.emptySet());
callback.consume(list != null ? new HashSet<>(list) : Collections.emptySet());
});
}
@@ -339,7 +339,7 @@ public class SwingHelper {
public static void setHistory(@NotNull TextFieldWithHistory textFieldWithHistory,
@NotNull List<String> history,
boolean mergeWithPrevHistory) {
Set<String> newHistorySet = ContainerUtil.newHashSet(history);
Set<String> newHistorySet = new HashSet<>(history);
List<String> prevHistory = textFieldWithHistory.getHistory();
List<String> mergedHistory = ContainerUtil.newArrayListWithCapacity(history.size());
if (mergeWithPrevHistory) {
@@ -306,6 +306,16 @@ public class ContainerUtil extends ContainerUtilRt {
return ContainerUtilRt.newHashSet(iterable);
}
/**
* @deprecated simply use {@code new HashSet<>(collection)}.
*/
@NotNull
@Contract(pure=true)
@Deprecated
public static <T> HashSet<T> newHashSet(@NotNull Collection<? extends T> collection) {
return new HashSet<>(collection);
}
@NotNull
public static <T> HashSet<T> newHashSet(@NotNull Iterator<? extends T> iterator) {
return ContainerUtilRt.newHashSet(iterator);
@@ -59,7 +59,7 @@ public class RollbackAction extends AnAction implements DumbAware, UpdateInBackg
private static boolean hasReversibleFiles(@NotNull AnActionEvent e) {
ChangeListManager manager = ChangeListManager.getInstance(e.getRequiredData(CommonDataKeys.PROJECT));
Set<VirtualFile> modifiedWithoutEditing = ContainerUtil.newHashSet(manager.getModifiedWithoutEditing());
Set<VirtualFile> modifiedWithoutEditing = new HashSet<>(manager.getModifiedWithoutEditing());
return notNullize(e.getData(VcsDataKeys.VIRTUAL_FILE_STREAM)).anyMatch(
file -> manager.haveChangesUnder(file) != ThreeState.NO || manager.isFileAffected(file) || modifiedWithoutEditing.contains(file));
@@ -68,7 +68,7 @@ public class RollbackAction extends AnAction implements DumbAware, UpdateInBackg
private static boolean currentChangelistNotEmpty(Project project) {
ChangeListManager clManager = ChangeListManager.getInstance(project);
ChangeList list = clManager.getDefaultChangeList();
return list != null && !list.getChanges().isEmpty();
return !list.getChanges().isEmpty();
}
@Override
@@ -842,7 +842,7 @@ public class ChangesCacheFile {
if (!revisionDependentFiles.isEmpty()) {
// lots of same files could be collected - make set of unique files
HashSet<VirtualFile> uniqueFiles = ContainerUtil.newHashSet(revisionDependentFiles.values());
HashSet<VirtualFile> uniqueFiles = new HashSet<>(revisionDependentFiles.values());
// bulk-get all needed revisions at once
Map<VirtualFile, VcsRevisionNumber> revisions = myDiffProvider instanceof DiffProviderEx
? ((DiffProviderEx)myDiffProvider).getCurrentRevisions(uniqueFiles)
@@ -219,7 +219,7 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
}
}
boolean isDefaultChangeListFullyIncluded = newHashSet(changes).containsAll(defaultList.getChanges());
boolean isDefaultChangeListFullyIncluded = new HashSet<>(changes).containsAll(defaultList.getChanges());
DialogCommitWorkflow workflow =
new DialogCommitWorkflow(project, included, initialSelection, executors, showVcsCommit, forceCommitInVcs, affectedVcses,
isDefaultChangeListFullyIncluded, comment, customResultHandler);
@@ -22,7 +22,10 @@ import com.intellij.openapi.vcs.VcsDirectoryMapping;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.util.containers.ContainerUtil;
import java.util.*;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.intellij.util.containers.ContainerUtil.newHashMap;
import static com.intellij.util.containers.ContainerUtil.newLinkedList;
@@ -79,7 +82,7 @@ public class FileWatchRequestModifier implements Runnable {
myDirectoryMappingWatches.put(mapping, request);
}
else {
LOG.error("root=" + request.getRootPath() + " toAdd=" + ContainerUtil.newHashSet(toAdd.keySet()));
LOG.error("root=" + request.getRootPath() + " toAdd=" + toAdd.keySet());
}
}
}
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -150,6 +151,6 @@ public class LinearGraphUtils {
@NotNull
public static Set<Integer> convertIdsToNodeIndexes(@NotNull final LinearGraph graph, @NotNull Collection<Integer> ids) {
List<Integer> result = ContainerUtil.mapNotNull(ids, id -> graph.getNodeIndex(id));
return ContainerUtil.newHashSet(result);
return new HashSet<>(result);
}
}
@@ -67,8 +67,8 @@ public class VcsLogFeaturesCollector extends ProjectUsagesCollector {
}
}
Set<Integer> currentColumns = ContainerUtil.newHashSet(properties.get(CommonUiProperties.COLUMN_ORDER));
Set<Integer> defaultColumns = ContainerUtil.newHashSet(defaultProperties.get(CommonUiProperties.COLUMN_ORDER));
Set<Integer> currentColumns = new HashSet<>(properties.get(CommonUiProperties.COLUMN_ORDER));
Set<Integer> defaultColumns = new HashSet<>(defaultProperties.get(CommonUiProperties.COLUMN_ORDER));
for (int column : GraphTableModel.DYNAMIC_COLUMNS) {
if (currentColumns.contains(column) != defaultColumns.contains(column)) {
usages.add(StatisticsUtilKt.getBooleanUsage(StringUtil.toLowerCase(GraphTableModel.COLUMN_NAMES[column]) + "Column",
@@ -49,10 +49,8 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.*;
import static com.intellij.vcs.log.ui.frame.CommitPresentationUtil.buildPresentation;
@@ -194,8 +192,7 @@ public class DetailsPanel extends JPanel implements EditorColorsListener, Dispos
myResolveIndicator = BackgroundTaskUtil.executeOnPooledThread(this, () -> {
MultiMap<String, CommitId> resolvedHashes = MultiMap.createSmart();
Set<String> fullHashes =
ContainerUtil.newHashSet(ContainerUtil.filter(unResolvedHashes, h -> h.length() == VcsLogUtil.FULL_HASH_LENGTH));
Set<String> fullHashes = new HashSet<>(ContainerUtil.filter(unResolvedHashes, h -> h.length() == VcsLogUtil.FULL_HASH_LENGTH));
for (String fullHash : fullHashes) {
Hash hash = HashImpl.build(fullHash);
for (VirtualFile root : myLogData.getRoots()) {
@@ -19,12 +19,13 @@ import com.intellij.util.NotNullFunction;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.vcs.log.*;
import com.intellij.vcs.log.data.VcsLogData;
import com.intellij.vcs.log.visible.filters.VcsLogUserFilterImpl;
import com.intellij.vcs.log.util.VcsUserUtil;
import com.intellij.vcs.log.visible.filters.VcsLogUserFilterImpl;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public class MyCommitsHighlighter implements VcsLogHighlighter {
@@ -58,8 +59,8 @@ public class MyCommitsHighlighter implements VcsLogHighlighter {
// returns true if only one user commits to this repository
private boolean isSingleUser() {
NotNullFunction<VcsUser, String> nameToString = user -> VcsUserUtil.getNameInStandardForm(VcsUserUtil.getShortPresentation(user));
Set<String> allUserNames = ContainerUtil.newHashSet(ContainerUtil.map(myLogData.getAllUsers(), nameToString));
Set<String> currentUserNames = ContainerUtil.newHashSet(ContainerUtil.map(myLogData.getCurrentUser().values(), nameToString));
Set<String> allUserNames = new HashSet<>(ContainerUtil.map(myLogData.getAllUsers(), nameToString));
Set<String> currentUserNames = new HashSet<>(ContainerUtil.map(myLogData.getCurrentUser().values(), nameToString));
return allUserNames.size() == currentUserNames.size() && currentUserNames.containsAll(allUserNames);
}
@@ -146,7 +146,7 @@ public abstract class VcsLogUserFilterTest {
@NotNull MultiMap<VcsUser, String> commits,
@NotNull List<? extends VcsCommitMetadata> metadata, @NotNull StringBuilder builder)
throws VcsException {
Set<String> expectedCommits = ContainerUtil.newHashSet(commits.get(user));
Set<String> expectedCommits = new HashSet<>(commits.get(user));
for (VcsUser synonym : synonymUsers) {
expectedCommits.addAll(commits.get(synonym));
}
@@ -211,7 +211,7 @@ public abstract class VcsLogUserFilterTest {
}
private static <T> boolean hasSameElements(@NotNull Collection<? extends T> collection, @NotNull Collection<T> expected) {
return ContainerUtil.newHashSet(expected).equals(ContainerUtil.newHashSet(collection));
return new HashSet<>(expected).equals(new HashSet<>(collection));
}
@NotNull
@@ -166,7 +166,7 @@ public abstract class AttachToProcessActionBase extends AnAction {
for (XAttachHostProvider hostProvider : XAttachHostProvider.EP.getExtensionList()) {
indicator.checkCanceled();
//noinspection unchecked
Set<XAttachHost> hosts = ContainerUtil.newHashSet(hostProvider.getAvailableHosts(project));
Set<XAttachHost> hosts = new HashSet<>(hostProvider.getAvailableHosts(project));
for (XAttachHost host : hosts) {
//noinspection unchecked
@@ -322,7 +322,7 @@ public class Configuration extends SimpleModificationTracker implements Persiste
});
};
for (String key : ContainerUtil.newTreeSet(myInjections.keySet())) {
Set<BaseInjection> injections = ContainerUtil.newHashSet(myInjections.get(key));
Set<BaseInjection> injections = new HashSet<>(myInjections.get(key));
injections.removeAll(getDefaultInjections());
for (BaseInjection injection : ContainerUtil.sorted(injections, comparator)) {
element.addContent(injection.getState());
@@ -397,7 +397,7 @@ public class GitRebaseProcess {
@Contract("_, !null -> !null")
private static <T> T getItemIfAllTheSame(@NotNull Collection<T> collection, @Nullable T defaultItem) {
return newHashSet(collection).size() == 1 ? getFirstItem(collection) : defaultItem;
return new HashSet<>(collection).size() == 1 ? getFirstItem(collection) : defaultItem;
}
private void notifyNotAllConflictsResolved(@NotNull GitRepository conflictingRepository,
@@ -41,10 +41,7 @@ import org.jetbrains.plugins.gradle.service.project.ProjectResolverContext;
import org.jetbrains.plugins.gradle.util.GradleConstants;
import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import static com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.findAllRecursively;
import static com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.toCanonicalPath;
@@ -90,7 +87,7 @@ public class JavaEEGradleProjectResolverExtension extends AbstractProjectResolve
ExternalProject externalProject = resolverCtx.getExtraProject(gradleModule, ExternalProject.class);
if (externalProject != null) {
if (externalProject.getArtifactsByConfiguration().get("archives") != null) {
final Set<File> archivesArtifacts = ContainerUtil.newHashSet(externalProject.getArtifactsByConfiguration().get("archives"));
final Set<File> archivesArtifacts = new HashSet<>(externalProject.getArtifactsByConfiguration().get("archives"));
final Set<File> testsArtifacts = externalProject.getArtifactsByConfiguration().get("tests");
if (testsArtifacts != null) {
archivesArtifacts.removeAll(testsArtifacts);
@@ -25,6 +25,7 @@ import org.jetbrains.plugins.gradle.util.GradleConstants;
import javax.swing.event.HyperlinkEvent;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -53,7 +54,7 @@ public class MavenRepositoriesHolder {
UNINDEXED_MAVEN_REPOSITORIES_NOTIFICATION_GROUP, NotificationSource.PROJECT_SYNC, GradleConstants.SYSTEM_ID);
}
else {
myNotIndexedUrls = ContainerUtil.newHashSet(repositories);
myNotIndexedUrls = new HashSet<>(repositories);
}
}
@@ -125,7 +126,7 @@ public class MavenRepositoriesHolder {
}
public void update(Set<MavenRemoteRepository> remoteRepositories) {
myRemoteRepositories = ContainerUtil.newHashSet(remoteRepositories);
myRemoteRepositories = new HashSet<>(remoteRepositories);
}
public Set<MavenRemoteRepository> getRemoteRepositories() {
@@ -661,7 +661,7 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
ContentRootData mergedContentRoot = null;
String rootPath = toCanonicalPath(root.getAbsolutePath());
Set<String> paths = ContainerUtil.newHashSet(sourceSetRoots.keySet());
Set<String> paths = new HashSet<>(sourceSetRoots.keySet());
for (String path : paths) {
if (FileUtil.isAncestor(rootPath, path, true)) {
Collection<ContentRootData> values = sourceSetRoots.remove(path);
@@ -41,7 +41,6 @@ import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
import java.util.*;
import static com.intellij.util.containers.ContainerUtil.emptyList;
import static com.intellij.util.containers.ContainerUtil.newHashSet;
import static org.jetbrains.plugins.groovy.lang.sam.SamConversionKt.findSingleAbstractMethod;
import static org.jetbrains.plugins.groovy.lang.sam.SamConversionKt.isSamConversionAllowed;
@@ -83,7 +82,7 @@ public class SubstitutorComputer {
myExitPoints = VolatileNotNullLazyValue.createValue(() -> {
if (canBeExitPoint(place)) {
GrControlFlowOwner flowOwner = ControlFlowUtils.findControlFlowOwner(place);
return newHashSet(ControlFlowUtils.collectReturns(flowOwner));
return new HashSet<>(ControlFlowUtils.collectReturns(flowOwner));
}
else {
return emptyList();
@@ -45,6 +45,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyFileType;
import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -162,7 +163,7 @@ public class PatternEditorContextMembersProvider extends NonCodeMembersContribut
return true;
}, searcher.getPattern(), UsageSearchContext.IN_FOREIGN_LANGUAGES, scope, searcher.isCaseSensitive());
}
return ContainerUtil.newHashSet(roots);
return new HashSet<>(roots);
}
}
@@ -77,7 +77,7 @@ public class SuspiciousLocalesLanguagesInspection extends BaseLocalInspectionToo
@Override
public void writeSettings(@NotNull Element node) throws WriteExternalException {
if (!myAdditionalLanguages.isEmpty()) {
final ArrayList<String> uniqueLanguages = ContainerUtil.newArrayList(ContainerUtil.newHashSet(myAdditionalLanguages));
final ArrayList<String> uniqueLanguages = ContainerUtil.newArrayList(new HashSet<>(myAdditionalLanguages));
Collections.sort(uniqueLanguages);
final String locales = StringUtil.join(uniqueLanguages, ",");
node.setAttribute(ADDITIONAL_LANGUAGES_ATTR_NAME, locales);
@@ -43,6 +43,7 @@ import org.jetbrains.idea.maven.utils.MavenSimpleProjectComponent;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -121,7 +122,7 @@ public class MavenProjectIndicesManager extends MavenSimpleProjectComponent impl
private Set<Pair<String, String>> collectRemoteRepositoriesIdsAndUrls() {
Set<Pair<String, String>> result = new THashSet<>();
Set<MavenRemoteRepository> remoteRepositories = ContainerUtil.newHashSet(getMavenProjectManager().getRemoteRepositories());
Set<MavenRemoteRepository> remoteRepositories = new HashSet<>(getMavenProjectManager().getRemoteRepositories());
for (MavenRepositoryProvider repositoryProvider : MavenRepositoryProvider.EP_NAME.getExtensions()) {
ContainerUtil.addAll(remoteRepositories, repositoryProvider.getRemoteRepositories(myProject));
}
@@ -18,6 +18,7 @@ package org.jetbrains.idea.svn;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
public class NestedCopiesHolder {
@@ -29,7 +30,7 @@ public class NestedCopiesHolder {
}
public synchronized Set<NestedCopyInfo> getAndClear() {
Set<NestedCopyInfo> copy = ContainerUtil.newHashSet(mySet);
Set<NestedCopyInfo> copy = new HashSet<>(mySet);
mySet.clear();
return copy;
@@ -16,7 +16,6 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.*;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -100,7 +99,7 @@ public class DefaultXmlSuppressionProvider extends XmlSuppressionProvider implem
if (id == null) {
return true;
}
@NonNls final HashSet<String> parts = ContainerUtil.newHashSet(StringUtil.getWordsIn(text));
@NonNls final HashSet<String> parts = new HashSet<>(StringUtil.getWordsIn(text));
return parts.contains(id) || parts.contains(XmlSuppressableInspectionTool.ALL);
}