mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -26,7 +26,7 @@ import com.intellij.psi.util.PsiMatcherImpl;
|
||||
import com.intellij.psi.util.PsiMatchers;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.containers.BidirectionalMap;
|
||||
import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -34,6 +34,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -47,7 +48,6 @@ public class RefCountHolder {
|
||||
|
||||
private final Map<PsiNamedElement, Boolean> myDclsUsedMap = new ConcurrentHashMap<PsiNamedElement, Boolean>();
|
||||
private final Map<PsiReference, PsiImportStatementBase> myImportStatements = new ConcurrentHashMap<PsiReference, PsiImportStatementBase>();
|
||||
private final Map<PsiElement,Boolean> myPossiblyDuplicateElements = new ConcurrentHashMap<PsiElement, Boolean>();
|
||||
private final AtomicReference<ProgressIndicator> myState = new AtomicReference<ProgressIndicator>(VIRGIN);
|
||||
private static final ProgressIndicator VIRGIN = new DaemonProgressIndicator(); // just created or cleared
|
||||
private static final ProgressIndicator READY = new DaemonProgressIndicator();
|
||||
@@ -124,7 +124,6 @@ public class RefCountHolder {
|
||||
}
|
||||
myImportStatements.clear();
|
||||
myDclsUsedMap.clear();
|
||||
myPossiblyDuplicateElements.clear();
|
||||
}
|
||||
|
||||
public void registerLocallyReferenced(@NotNull PsiNamedElement result) {
|
||||
@@ -181,16 +180,16 @@ public class RefCountHolder {
|
||||
}
|
||||
}
|
||||
removeInvalidFrom(myDclsUsedMap.keySet());
|
||||
removeInvalidFrom(myPossiblyDuplicateElements.keySet());
|
||||
}
|
||||
private static void removeInvalidFrom(Iterable<? extends PsiElement> collection) {
|
||||
|
||||
private static void removeInvalidFrom(@NotNull Collection<? extends PsiElement> collection) {
|
||||
for (Iterator<? extends PsiElement> it = collection.iterator(); it.hasNext();) {
|
||||
PsiElement element = it.next();
|
||||
if (!element.isValid()) it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReferenced(PsiNamedElement element) {
|
||||
public boolean isReferenced(@NotNull PsiNamedElement element) {
|
||||
List<PsiReference> array;
|
||||
synchronized (myLocalRefsMap) {
|
||||
array = myLocalRefsMap.getKeysByValue(element);
|
||||
@@ -201,13 +200,13 @@ public class RefCountHolder {
|
||||
return usedStatus == Boolean.TRUE;
|
||||
}
|
||||
|
||||
private static boolean isParameterUsedRecursively(final PsiElement element, final List<PsiReference> array) {
|
||||
private static boolean isParameterUsedRecursively(@NotNull PsiElement element, @NotNull List<PsiReference> array) {
|
||||
if (!(element instanceof PsiParameter)) return false;
|
||||
PsiParameter parameter = (PsiParameter)element;
|
||||
PsiElement scope = parameter.getDeclarationScope();
|
||||
if (!(scope instanceof PsiMethod)) return false;
|
||||
PsiMethod method = (PsiMethod)scope;
|
||||
int paramIndex = ArrayUtil.find(method.getParameterList().getParameters(), parameter);
|
||||
int paramIndex = ArrayUtilRt.find(method.getParameterList().getParameters(), parameter);
|
||||
|
||||
for (PsiReference reference : array) {
|
||||
if (!(reference instanceof PsiElement)) return false;
|
||||
@@ -223,7 +222,7 @@ public class RefCountHolder {
|
||||
if (method != methodExpression.resolve()) return false;
|
||||
PsiExpressionList argumentList = methodCallExpression.getArgumentList();
|
||||
PsiExpression[] arguments = argumentList.getExpressions();
|
||||
int argumentIndex = ArrayUtil.find(arguments, argument);
|
||||
int argumentIndex = ArrayUtilRt.find(arguments, argument);
|
||||
if (paramIndex != argumentIndex) return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.util.containers;
|
||||
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
@@ -24,6 +25,7 @@ public class BidirectionalMap<K,V> implements Map<K,V>{
|
||||
private final Map<K,V> myKeyToValueMap = new THashMap<K,V>();
|
||||
private final Map<V,List<K>> myValueToKeysMap = new THashMap<V,List<K>>();
|
||||
|
||||
@Override
|
||||
public V put(K key, V value){
|
||||
V oldValue = myKeyToValueMap.put(key, value);
|
||||
if (oldValue != null){
|
||||
@@ -41,6 +43,7 @@ public class BidirectionalMap<K,V> implements Map<K,V>{
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
myKeyToValueMap.clear();
|
||||
myValueToKeysMap.clear();
|
||||
@@ -51,27 +54,34 @@ public class BidirectionalMap<K,V> implements Map<K,V>{
|
||||
return myValueToKeysMap.get(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
return myKeyToValueMap.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size(){
|
||||
return myKeyToValueMap.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(){
|
||||
return myKeyToValueMap.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key){
|
||||
return myKeyToValueMap.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"SuspiciousMethodCalls"})
|
||||
public boolean containsValue(Object value){
|
||||
return myValueToKeysMap.containsKey(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(Object key) {
|
||||
return myKeyToValueMap.get(key);
|
||||
}
|
||||
@@ -85,6 +95,7 @@ public class BidirectionalMap<K,V> implements Map<K,V>{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"SuspiciousMethodCalls"})
|
||||
public V remove(Object key){
|
||||
final V value = myKeyToValueMap.remove(key);
|
||||
@@ -96,16 +107,21 @@ public class BidirectionalMap<K,V> implements Map<K,V>{
|
||||
return value;
|
||||
}
|
||||
|
||||
public void putAll(Map<? extends K, ? extends V> t){
|
||||
@Override
|
||||
public void putAll(@NotNull Map<? extends K, ? extends V> t){
|
||||
for (final K k1 : t.keySet()) {
|
||||
put(k1, t.get(k1));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<V> values(){
|
||||
return myValueToKeysMap.keySet();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<Entry<K, V>> entrySet(){
|
||||
return myKeyToValueMap.entrySet();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user