mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
migrate more usages of deprecated com.intellij.util.containers.HashMap/Set to java.util
This commit is contained in:
@@ -40,7 +40,6 @@ import com.intellij.openapi.roots.libraries.LibraryUtil;
|
||||
import com.intellij.openapi.startup.StartupActivity;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.maven.utils.library.RepositoryLibraryDescription;
|
||||
import org.jetbrains.idea.maven.utils.library.RepositoryLibraryProperties;
|
||||
@@ -71,7 +70,7 @@ public class RepositoryLibrarySynchronizer implements StartupActivity, DumbAware
|
||||
}
|
||||
|
||||
private static Collection<Library> collectLibraries(final @NotNull Project project, final @NotNull Predicate<Library> predicate) {
|
||||
final HashSet<Library> result = new HashSet<>();
|
||||
final Set<Library> result = new HashSet<>();
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
if (project.isDisposed()) return;
|
||||
|
||||
|
||||
+3
-2
@@ -16,6 +16,7 @@ import javax.swing.event.TableModelListener;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Nikolay.Tropin
|
||||
@@ -29,8 +30,8 @@ public abstract class AbstractGenerateEqualsWizard <C extends PsiElement, M exte
|
||||
protected final AbstractMemberSelectionPanel<M, I> myEqualsPanel;
|
||||
protected final AbstractMemberSelectionPanel<M, I> myHashCodePanel;
|
||||
protected final AbstractMemberSelectionPanel<M, I> myNonNullPanel;
|
||||
protected final HashMap<M, I> myFieldsToHashCode;
|
||||
protected final HashMap<M, I> myFieldsToNonNull;
|
||||
protected final Map<M, I> myFieldsToHashCode;
|
||||
protected final Map<M, I> myFieldsToNonNull;
|
||||
|
||||
private int myNonNullStepCode;
|
||||
private int myEqualsStepCode;
|
||||
|
||||
+4
-5
@@ -34,7 +34,6 @@ import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.indexing.FindSymbolParameters;
|
||||
import com.intellij.util.indexing.IdFilter;
|
||||
import gnu.trove.THashSet;
|
||||
@@ -50,10 +49,10 @@ public class DefaultSymbolNavigationContributor implements ChooseByNameContribut
|
||||
@NotNull
|
||||
public String[] getNames(Project project, boolean includeNonProjectItems) {
|
||||
PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
|
||||
HashSet<String> set = new HashSet<>();
|
||||
cache.getAllMethodNames(set);
|
||||
cache.getAllFieldNames(set);
|
||||
cache.getAllClassNames(set);
|
||||
Set<String> set = new HashSet<>();
|
||||
Collections.addAll(set, cache.getAllMethodNames());
|
||||
Collections.addAll(set, cache.getAllFieldNames());
|
||||
Collections.addAll(set, cache.getAllClassNames());
|
||||
return ArrayUtil.toStringArray(set);
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -26,7 +26,7 @@ import com.intellij.psi.search.PsiShortNamesCache;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -69,10 +69,8 @@ public class AutomaticTestRenamerFactory implements AutomaticRenamerFactory {
|
||||
String klassName = aClass.getName();
|
||||
Pattern pattern = Pattern.compile(".*" + klassName + ".*");
|
||||
|
||||
HashSet<String> names = new HashSet<>();
|
||||
cache.getAllClassNames(names);
|
||||
int count = 0;
|
||||
for (String eachName : names) {
|
||||
for (String eachName : ContainerUtil.newHashSet(cache.getAllClassNames())) {
|
||||
if (pattern.matcher(eachName).matches()) {
|
||||
if (count ++ > 1000) break;
|
||||
for (PsiClass eachClass : cache.getClassesByName(eachName, moduleScope)) {
|
||||
|
||||
@@ -30,14 +30,11 @@ import com.intellij.psi.search.PsiShortNamesCache;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.Processors;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class JavaTestFinder implements TestFinder {
|
||||
@@ -114,9 +111,7 @@ public class JavaTestFinder implements TestFinder {
|
||||
String klassName = klass.getName();
|
||||
Pattern pattern = Pattern.compile(".*" + StringUtil.escapeToRegexp(klassName) + ".*", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
HashSet<String> names = new HashSet<>();
|
||||
cache.getAllClassNames(names);
|
||||
for (String eachName : names) {
|
||||
for (String eachName : ContainerUtil.newHashSet(cache.getAllClassNames())) {
|
||||
if (pattern.matcher(eachName).matches()) {
|
||||
for (PsiClass eachClass : cache.getClassesByName(eachName, scope)) {
|
||||
if (isTestClass(eachClass, klass)) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiField;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
@@ -31,6 +32,8 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Allows to retrieve files and Java classes, methods and fields in a project by non-qualified names.
|
||||
*/
|
||||
@@ -100,8 +103,12 @@ public abstract class PsiShortNamesCache {
|
||||
* to the specified set.
|
||||
*
|
||||
* @param dest the set to add the names to.
|
||||
* @see #processAllClassNames
|
||||
*/
|
||||
public abstract void getAllClassNames(@NotNull HashSet<String> dest);
|
||||
@Deprecated
|
||||
public void getAllClassNames(@NotNull HashSet<String> dest) {
|
||||
processAllClassNames(new CommonProcessors.CollectProcessor<>(dest));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of all methods with the specified name in the specified scope.
|
||||
@@ -147,8 +154,12 @@ public abstract class PsiShortNamesCache {
|
||||
* to the specified set.
|
||||
*
|
||||
* @param set the set to add the names to.
|
||||
* @see #processAllMethodNames
|
||||
*/
|
||||
public abstract void getAllMethodNames(@NotNull HashSet<String> set);
|
||||
@Deprecated
|
||||
public void getAllMethodNames(@NotNull HashSet<String> set) {
|
||||
Collections.addAll(set, getAllMethodNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of all fields with the specified name in the specified scope.
|
||||
@@ -174,8 +185,12 @@ public abstract class PsiShortNamesCache {
|
||||
* to the specified set.
|
||||
*
|
||||
* @param set the set to add the names to.
|
||||
* @see #processAllFieldNames
|
||||
*/
|
||||
public abstract void getAllFieldNames(@NotNull HashSet<String> set);
|
||||
@Deprecated
|
||||
public void getAllFieldNames(@NotNull HashSet<String> set) {
|
||||
Collections.addAll(set, getAllFieldNames());
|
||||
}
|
||||
|
||||
public boolean processFieldsWithName(@NotNull String name,
|
||||
@NotNull Processor<? super PsiField> processor,
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.indexing.IdFilter;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -137,13 +136,6 @@ public class CompositeShortNamesCache extends PsiShortNamesCache {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllClassNames(@NotNull HashSet<String> dest) {
|
||||
for (PsiShortNamesCache cache : myCaches) {
|
||||
cache.getAllClassNames(dest);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiMethod[] getMethodsByName(@NotNull String name, @NotNull GlobalSearchScope scope) {
|
||||
@@ -220,13 +212,6 @@ public class CompositeShortNamesCache extends PsiShortNamesCache {
|
||||
return result != null ? result : ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllMethodNames(@NotNull HashSet<String> set) {
|
||||
for (PsiShortNamesCache cache : myCaches) {
|
||||
cache.getAllMethodNames(set);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiField[] getFieldsByName(@NotNull String name, @NotNull GlobalSearchScope scope) {
|
||||
@@ -257,13 +242,6 @@ public class CompositeShortNamesCache extends PsiShortNamesCache {
|
||||
return result == null ? ArrayUtil.EMPTY_STRING_ARRAY : result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllFieldNames(@NotNull HashSet<String> set) {
|
||||
for (PsiShortNamesCache cache : myCaches) {
|
||||
cache.getAllFieldNames(set);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processFieldsWithName(@NotNull String key,
|
||||
@NotNull Processor<? super PsiField> processor,
|
||||
|
||||
@@ -27,8 +27,10 @@ import com.intellij.psi.search.FilenameIndex;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.PsiShortNamesCache;
|
||||
import com.intellij.psi.stubs.StubIndex;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.CommonProcessors;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.indexing.IdFilter;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
@@ -116,11 +118,6 @@ public class PsiShortNamesCacheImpl extends PsiShortNamesCache {
|
||||
return ArrayUtil.toStringArray(JavaShortClassNameIndex.getInstance().getAllKeys(myManager.getProject()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllClassNames(@NotNull HashSet<String> set) {
|
||||
processAllClassNames(Processors.cancelableCollectProcessor(set));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processAllClassNames(Processor<String> processor) {
|
||||
return JavaShortClassNameIndex.getInstance().processAllKeys(myManager.getProject(), processor);
|
||||
@@ -174,11 +171,6 @@ public class PsiShortNamesCacheImpl extends PsiShortNamesCache {
|
||||
return ArrayUtil.toStringArray(JavaMethodNameIndex.getInstance().getAllKeys(myManager.getProject()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllMethodNames(@NotNull HashSet<String> set) {
|
||||
JavaMethodNameIndex.getInstance().processAllKeys(myManager.getProject(), Processors.cancelableCollectProcessor(set));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiField[] getFieldsByNameIfNotMoreThan(@NotNull String name, @NotNull GlobalSearchScope scope, int maxCount) {
|
||||
@@ -206,11 +198,6 @@ public class PsiShortNamesCacheImpl extends PsiShortNamesCache {
|
||||
return ArrayUtil.toStringArray(JavaFieldNameIndex.getInstance().getAllKeys(myManager.getProject()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllFieldNames(@NotNull HashSet<String> set) {
|
||||
JavaFieldNameIndex.getInstance().processAllKeys(myManager.getProject(), Processors.cancelableCollectProcessor(set));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processFieldsWithName(@NotNull String name,
|
||||
@NotNull Processor<? super PsiField> processor,
|
||||
|
||||
-17
@@ -26,7 +26,6 @@ import com.intellij.psi.search.PsiShortNamesCache;
|
||||
import com.intellij.psi.stubs.StubIndex;
|
||||
import com.intellij.util.*;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import com.intellij.util.indexing.IdFilter;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -107,12 +106,6 @@ public class GroovyShortNamesCache extends PsiShortNamesCache {
|
||||
return ArrayUtil.toStringArray(StubIndex.getInstance().getAllKeys(GrScriptClassNameIndex.KEY, myProject));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getAllClassNames(@NotNull HashSet<String> dest) {
|
||||
dest.addAll(StubIndex.getInstance().getAllKeys(GrScriptClassNameIndex.KEY, myProject));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiMethod[] getMethodsByName(@NonNls @NotNull String name, @NotNull GlobalSearchScope scope) {
|
||||
@@ -163,11 +156,6 @@ public class GroovyShortNamesCache extends PsiShortNamesCache {
|
||||
return ArrayUtil.toStringArray(keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllMethodNames(@NotNull HashSet<String> set) {
|
||||
set.addAll(StubIndex.getInstance().getAllKeys(GrMethodNameIndex.KEY, myProject));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiField[] getFieldsByName(@NotNull @NonNls String name, @NotNull GlobalSearchScope scope) {
|
||||
@@ -184,11 +172,6 @@ public class GroovyShortNamesCache extends PsiShortNamesCache {
|
||||
return ArrayUtil.toStringArray(fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllFieldNames(@NotNull HashSet<String> set) {
|
||||
set.addAll(StubIndex.getInstance().getAllKeys(GrFieldNameIndex.KEY, myProject));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processFieldsWithName(@NotNull String name,
|
||||
@NotNull Processor<? super PsiField> processor,
|
||||
|
||||
Reference in New Issue
Block a user