mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix redundant collection operations & some other warnings
GitOrigin-RevId: 92ea4a931aefd529d8f8a81ff07e06e1294d8608
This commit is contained in:
committed by
intellij-monorepo-bot
parent
78ea5f2606
commit
e39a654356
+1
-1
@@ -505,7 +505,7 @@ public class ConvertToInstanceMethodProcessor extends BaseRefactoringProcessor {
|
||||
if (!(aClass instanceof PsiTypeParameter)) return null;
|
||||
final PsiTypeParameter methodTypeParameter = (PsiTypeParameter)aClass;
|
||||
if (methodTypeParameter.getOwner() != containingElement) return null;
|
||||
if (result.keySet().contains(methodTypeParameter)) return null;
|
||||
if (result.containsKey(methodTypeParameter)) return null;
|
||||
result.put(methodTypeParameter, classTypeParameter);
|
||||
}
|
||||
return result;
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public abstract class AutomaticUsageRenamer<T> {
|
||||
}
|
||||
|
||||
protected boolean isNameAlreadySuggested(String newName) {
|
||||
return myRenames.values().contains(newName);
|
||||
return myRenames.containsValue(newName);
|
||||
}
|
||||
|
||||
public List<? extends T> getElements() {
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ public class ConvertFieldToAtomicIntention extends PsiElementBaseIntentionAction
|
||||
if (psiTypeClass != null) {
|
||||
final String qualifiedName = psiTypeClass.getQualifiedName();
|
||||
if (qualifiedName != null) { //is already atomic
|
||||
if (myFromToMap.values().contains(qualifiedName) ||
|
||||
if (myFromToMap.containsValue(qualifiedName) ||
|
||||
qualifiedName.equals(AtomicReference.class.getName()) ||
|
||||
qualifiedName.equals(AtomicReferenceArray.class.getName())) {
|
||||
return false;
|
||||
|
||||
@@ -91,7 +91,7 @@ public class JsonSpellcheckerStrategy extends SpellcheckingStrategy {
|
||||
final Collection<JsonSchemaObject> schemas = new JsonSchemaResolver(project, rootSchema, position).resolve();
|
||||
if (schemas.isEmpty()) return false;
|
||||
|
||||
return schemas.stream().anyMatch(s -> s.getProperties().keySet().contains(value)
|
||||
return schemas.stream().anyMatch(s -> s.getProperties().containsKey(value)
|
||||
|| s.getMatchingPatternPropertySchema(value) != null);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public final class FavoritesManager implements PersistentStateComponent<Element>
|
||||
@Override
|
||||
public boolean canClose(String inputString) {
|
||||
inputString = inputString.trim();
|
||||
if (myName2FavoritesRoots.keySet().contains(inputString) || getProviders().keySet().contains(inputString)) {
|
||||
if (myName2FavoritesRoots.containsKey(inputString) || getProviders().containsKey(inputString)) {
|
||||
Messages.showErrorDialog(project, IdeBundle.message("error.favorites.list.already.exists", inputString.trim()),
|
||||
IdeBundle.message("title.unable.to.add.favorites.list"));
|
||||
return false;
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package com.intellij.refactoring.classMembers;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
@@ -39,7 +40,7 @@ public class MemberInfoTooltipManager<T extends PsiElement, M extends MemberInfo
|
||||
}
|
||||
|
||||
public String getTooltip(M member) {
|
||||
if(myTooltips.keySet().contains(member)) {
|
||||
if(myTooltips.containsKey(member)) {
|
||||
return myTooltips.get(member);
|
||||
}
|
||||
String tooltip = myProvider.getTooltip(member);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class HackyDataContext implements DataContext {
|
||||
|
||||
@Override
|
||||
public Object getData(@NotNull @NonNls String dataId) {
|
||||
if (values.keySet().contains(dataId)) {
|
||||
if (values.containsKey(dataId)) {
|
||||
return values.get(dataId);
|
||||
}
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ final class DialogAwareDataContext implements DataContext {
|
||||
|
||||
@Override
|
||||
public Object getData(@NotNull @NonNls String dataId) {
|
||||
if (values.keySet().contains(dataId)) {
|
||||
if (values.containsKey(dataId)) {
|
||||
return values.get(dataId);
|
||||
}
|
||||
final Editor editor = (Editor)values.get(EDITOR.getName());
|
||||
|
||||
@@ -28,7 +28,7 @@ public abstract class FlatteningIterator<Group, Value> implements Iterator<Value
|
||||
|
||||
public FlatteningIterator(Iterator<? extends Group> groups) {
|
||||
valuesIterator = groups;
|
||||
groupIterator = Collections.<Value>emptyList().iterator();
|
||||
groupIterator = Collections.emptyIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -539,7 +539,7 @@ public class XSDModelLoader implements ModelLoader {
|
||||
fd1.comment = "array of " + fd1.elementType;
|
||||
}
|
||||
fd1.realIndex = td.fdMap.size();
|
||||
boolean merge = globalMerge || globalChoice.containsKey(p) && globalChoice.values().contains(fd1.name);
|
||||
boolean merge = globalMerge || globalChoice.containsKey(p) && globalChoice.containsValue(fd1.name);
|
||||
td.duplicates = Util.addToNameMap(td.fdMap, fd1, merge) || td.duplicates;
|
||||
globalChoice.put(p, fd1.name);
|
||||
} else if (p.getTerm() instanceof XSModelGroup) {
|
||||
|
||||
@@ -47,11 +47,10 @@ class IdeaSuite extends Suite {
|
||||
public Description getDescription() {
|
||||
Description description = Description.createSuiteDescription(myName, getTestClass().getAnnotations());
|
||||
try {
|
||||
final Method getFilteredChildrenMethod = ParentRunner.class.getDeclaredMethod("getFilteredChildren", new Class[0]);
|
||||
final Method getFilteredChildrenMethod = ParentRunner.class.getDeclaredMethod("getFilteredChildren");
|
||||
getFilteredChildrenMethod.setAccessible(true);
|
||||
Collection filteredChildren = (Collection)getFilteredChildrenMethod.invoke(this, new Object[0]);
|
||||
for (Iterator iterator = filteredChildren.iterator(); iterator.hasNext();) {
|
||||
Object child = iterator.next();
|
||||
Collection<?> filteredChildren = (Collection<?>)getFilteredChildrenMethod.invoke(this);
|
||||
for (Object child : filteredChildren) {
|
||||
description.addChild(describeChild((Runner)child));
|
||||
}
|
||||
}
|
||||
@@ -65,20 +64,19 @@ class IdeaSuite extends Suite {
|
||||
final Description superDescription = super.describeChild(child);
|
||||
if (child instanceof ClassAwareSuiteMethod) {
|
||||
final Description description = Description.createSuiteDescription(((ClassAwareSuiteMethod)child).getKlass());
|
||||
ArrayList children = superDescription.getChildren();
|
||||
for (int i = 0, size = children.size(); i < size; i++) {
|
||||
description.addChild((Description)children.get(i));
|
||||
ArrayList<Description> children = superDescription.getChildren();
|
||||
for (Description desc : children) {
|
||||
description.addChild(desc);
|
||||
}
|
||||
return description;
|
||||
}
|
||||
return superDescription;
|
||||
}
|
||||
|
||||
protected List getChildren() {
|
||||
final List children = new ArrayList(super.getChildren());
|
||||
protected List<Runner> getChildren() {
|
||||
final List<Runner> children = new ArrayList<Runner>(super.getChildren());
|
||||
boolean containsSuiteInside = false;
|
||||
for (Iterator iterator = children.iterator(); iterator.hasNext(); ) {
|
||||
Object child = iterator.next();
|
||||
for (Runner child : children) {
|
||||
if (isSuite(child)) {
|
||||
containsSuiteInside = true;
|
||||
break;
|
||||
@@ -86,26 +84,24 @@ class IdeaSuite extends Suite {
|
||||
}
|
||||
if (!containsSuiteInside) return children;
|
||||
try {
|
||||
final Set allNames = new HashSet();
|
||||
for (Iterator iterator = children.iterator(); iterator.hasNext();) {
|
||||
final Object child = iterator.next();
|
||||
allNames.add(describeChild((Runner)child).getDisplayName());
|
||||
final Set<String> allNames = new HashSet<String>();
|
||||
for (Runner child : children) {
|
||||
allNames.add(describeChild(child).getDisplayName());
|
||||
}
|
||||
for (Iterator iterator = children.iterator(); iterator.hasNext();) {
|
||||
final Object child = iterator.next();
|
||||
for (Runner child : children) {
|
||||
if (isSuite(child)) {
|
||||
skipSuiteComponents(allNames, child);
|
||||
}
|
||||
}
|
||||
|
||||
for (Iterator iterator = children.iterator(); iterator.hasNext(); ) {
|
||||
Object child = iterator.next();
|
||||
if (!isSuite(child) && !allNames.contains(describeChild((Runner)child).getDisplayName())) {
|
||||
for (Iterator<Runner> iterator = children.iterator(); iterator.hasNext(); ) {
|
||||
Runner child = iterator.next();
|
||||
if (!isSuite(child) && !allNames.contains(describeChild(child).getDisplayName())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable e){ }
|
||||
catch (Throwable ignored){ }
|
||||
return children;
|
||||
}
|
||||
|
||||
@@ -113,31 +109,27 @@ class IdeaSuite extends Suite {
|
||||
return child instanceof Suite && !(child instanceof Parameterized) || child instanceof SuiteMethod;
|
||||
}
|
||||
|
||||
private void skipSuiteComponents(Set allNames, Object child) {
|
||||
private void skipSuiteComponents(Set<String> allNames, Object child) {
|
||||
try {
|
||||
if (child instanceof Suite) {
|
||||
final Method getChildrenMethod = Suite.class.getDeclaredMethod("getChildren", new Class[0]);
|
||||
final Method getChildrenMethod = Suite.class.getDeclaredMethod("getChildren");
|
||||
getChildrenMethod.setAccessible(true);
|
||||
final List tests = (List)getChildrenMethod.invoke(child, new Object[0]);
|
||||
for (Iterator suiteIterator = tests.iterator(); suiteIterator.hasNext();) {
|
||||
final String displayName = describeChild((Runner)suiteIterator.next()).getDisplayName();
|
||||
if (allNames.contains(displayName)) {
|
||||
allNames.remove(displayName);
|
||||
}
|
||||
final List<?> tests = (List<?>)getChildrenMethod.invoke(child);
|
||||
for (Object test : tests) {
|
||||
final String displayName = describeChild((Runner)test).getDisplayName();
|
||||
allNames.remove(displayName);
|
||||
}
|
||||
} else if (child instanceof SuiteMethod) {
|
||||
final Method getChildrenMethod = JUnit38ClassRunner.class.getDeclaredMethod("getTest", new Class[0]);
|
||||
final Method getChildrenMethod = JUnit38ClassRunner.class.getDeclaredMethod("getTest");
|
||||
getChildrenMethod.setAccessible(true);
|
||||
final Test test = (Test)getChildrenMethod.invoke(child, new Object[0]);
|
||||
final Test test = (Test)getChildrenMethod.invoke(child);
|
||||
if (test instanceof TestSuite) {
|
||||
final Enumeration tests = ((TestSuite)test).tests();
|
||||
final Enumeration<Test> tests = ((TestSuite)test).tests();
|
||||
while (tests.hasMoreElements()) {
|
||||
final Test t = (Test)tests.nextElement();
|
||||
final Test t = tests.nextElement();
|
||||
if (t instanceof TestSuite) {
|
||||
final String testDescription = ((TestSuite)t).getName();
|
||||
if (allNames.contains(testDescription)) {
|
||||
allNames.remove(testDescription);
|
||||
}
|
||||
allNames.remove(testDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-10
@@ -28,20 +28,15 @@ import com.intellij.xml.impl.BasicXmlAttributeDescriptor;
|
||||
import com.intellij.xml.util.XmlEnumeratedValueReference;
|
||||
import gnu.trove.THashSet;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.kohsuke.rngom.digested.DAttributePattern;
|
||||
import org.xml.sax.Locator;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import java.util.*;
|
||||
|
||||
public class RngXmlAttributeDescriptor extends BasicXmlAttributeDescriptor {
|
||||
@NonNls
|
||||
private static final QName UNKNOWN = new QName("", "#unknown");
|
||||
@@ -110,12 +105,12 @@ public class RngXmlAttributeDescriptor extends BasicXmlAttributeDescriptor {
|
||||
|
||||
@Override
|
||||
public boolean hasIdType() {
|
||||
return myValues.values().contains("ID");
|
||||
return myValues.containsValue("ID");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasIdRefType() {
|
||||
return myValues.values().contains("IDREF");
|
||||
return myValues.containsValue("IDREF");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user