This commit is contained in:
Alexey Kudravtsev
2016-09-07 14:12:33 +03:00
parent 8b2f420ab3
commit e009bd0460
5 changed files with 12 additions and 13 deletions
@@ -195,7 +195,7 @@ public interface PsiClass
@NotNull PsiMethod[] getAllMethods();
/**
* Returns the list of inner classes for the class and all its superclasses..
* Returns the list of inner classes for the class and all its superclasses.
*
* @return the list of inner classes.
*/
@@ -114,7 +114,7 @@ public class PsiTestUtil {
return vDir;
}
public static void removeAllRoots(Module module, Sdk jdk) {
public static void removeAllRoots(@NotNull Module module, Sdk jdk) {
ModuleRootModificationUtil.updateModel(module, model -> {
model.clear();
model.setSdk(jdk);
@@ -30,7 +30,7 @@ import java.util.*;
public class SmartFMap<K,V> implements Map<K,V> {
private static final SmartFMap EMPTY = new SmartFMap(ArrayUtil.EMPTY_OBJECT_ARRAY);
private static final int ARRAY_THRESHOLD = 8;
private final Object myMap;
private final Object myMap; // Object[] for map sizes up to ARRAY_THRESHOLD or Map
private SmartFMap(Object map) {
myMap = map;
@@ -41,12 +41,12 @@ public class SmartFMap<K,V> implements Map<K,V> {
}
public SmartFMap<K, V> plus(@NotNull K key, V value) {
return new SmartFMap<K, V>(doPlus(myMap, key, value, false));
return new SmartFMap<K, V>(doPlus(myMap, key, value));
}
private static Object doPlus(Object oldMap, Object key, Object value, boolean inPlace) {
private static Object doPlus(Object oldMap, Object key, Object value) {
if (oldMap instanceof Map) {
Map newMap = inPlace ? (Map)oldMap : new THashMap((Map)oldMap);
Map newMap = new THashMap((Map)oldMap);
newMap.put(key, value);
return newMap;
}
@@ -54,10 +54,8 @@ public class SmartFMap<K,V> implements Map<K,V> {
Object[] array = (Object[])oldMap;
for (int i = 0; i < array.length; i += 2) {
if (key.equals(array[i])) {
Object[] newArray = inPlace ? array : new Object[array.length];
if (!inPlace) {
System.arraycopy(array, 0, newArray, 0, array.length);
}
Object[] newArray = new Object[array.length];
System.arraycopy(array, 0, newArray, 0, array.length);
newArray[i + 1] = value;
return newArray;
}
@@ -58,7 +58,6 @@ public class MessageBusConnectionImpl implements MessageBusConnection {
}
@Override
@SuppressWarnings("unchecked")
public <L> void subscribe(@NotNull Topic<L> topic) throws IllegalStateException {
if (myDefaultHandler == null) {
throw new IllegalStateException("Connection must have default handler installed prior to any anonymous subscriptions. "
@@ -69,6 +68,7 @@ public class MessageBusConnectionImpl implements MessageBusConnection {
topic.getListenerClass() + "', actual: '" + myDefaultHandler.getClass() + "'");
}
//noinspection unchecked
subscribe(topic, (L)myDefaultHandler);
}
@@ -134,7 +134,7 @@ public class MessageBusConnectionImpl implements MessageBusConnection {
}
}
void scheduleMessageDelivery(Message message) {
void scheduleMessageDelivery(@NotNull Message message) {
myPendingMessages.get().offer(message);
}
@@ -142,6 +142,7 @@ public class MessageBusConnectionImpl implements MessageBusConnection {
return mySubscriptions.toString();
}
@NotNull
MessageBusImpl getBus() {
return myBus;
}
@@ -383,7 +383,7 @@ public class MessageBusImpl implements MessageBus {
while (true);
}
void notifyOnSubscription(@NotNull MessageBusConnectionImpl connection, @NotNull Topic topic) {
void notifyOnSubscription(@NotNull MessageBusConnectionImpl connection, @NotNull Topic<?> topic) {
checkNotDisposed();
List<MessageBusConnectionImpl> topicSubscribers = mySubscribers.get(topic);
if (topicSubscribers == null) {