Search in sources :

Example 1 with KeyFMap

use of com.intellij.util.keyFMap.KeyFMap in project intellij-community by JetBrains.

the class MapReference method equals.

@Override
public boolean equals(Object obj) {
    if (obj == this)
        return true;
    if (!(obj instanceof MapReference) || myHash != ((MapReference) obj).myHash)
        return false;
    KeyFMap o1 = get();
    KeyFMap o2 = ((MapReference) obj).get();
    if (o1 == null || o2 == null)
        return false;
    if (o1 instanceof OneElementFMap && o2 instanceof OneElementFMap) {
        OneElementFMap m1 = (OneElementFMap) o1;
        OneElementFMap m2 = (OneElementFMap) o2;
        return m1.getKey() == m2.getKey() && m1.getValue() == m2.getValue();
    }
    if (o1 instanceof PairElementsFMap && o2 instanceof PairElementsFMap) {
        PairElementsFMap m1 = (PairElementsFMap) o1;
        PairElementsFMap m2 = (PairElementsFMap) o2;
        return m1.getKey1() == m2.getKey1() && m1.getKey2() == m2.getKey2() && m1.getValue1() == m2.getValue1() && m1.getValue2() == m2.getValue2();
    }
    if (o1 instanceof ArrayBackedFMap && o2 instanceof ArrayBackedFMap) {
        ArrayBackedFMap m1 = (ArrayBackedFMap) o1;
        ArrayBackedFMap m2 = (ArrayBackedFMap) o2;
        return Arrays.equals(m1.getKeyIds(), m2.getKeyIds()) && containSameElements(m1.getValues(), m2.getValues());
    }
    return false;
}
Also used : KeyFMap(com.intellij.util.keyFMap.KeyFMap) ArrayBackedFMap(com.intellij.util.keyFMap.ArrayBackedFMap) PairElementsFMap(com.intellij.util.keyFMap.PairElementsFMap) OneElementFMap(com.intellij.util.keyFMap.OneElementFMap)

Example 2 with KeyFMap

use of com.intellij.util.keyFMap.KeyFMap in project intellij-community by JetBrains.

the class MapReference method internUserData.

static KeyFMap internUserData(@NotNull KeyFMap map) {
    if (shouldIntern(map)) {
        MapReference key = new MapReference(map);
        synchronized (ourCache) {
            KeyFMap cached = SoftReference.dereference(ourCache.get(key));
            if (cached != null)
                return cached;
            ourCache.put(key, key);
        }
        return map;
    }
    return map;
}
Also used : KeyFMap(com.intellij.util.keyFMap.KeyFMap)

Example 3 with KeyFMap

use of com.intellij.util.keyFMap.KeyFMap in project intellij-community by JetBrains.

the class UserDataHolderBase method replace.

@Override
public <T> boolean replace(@NotNull Key<T> key, @Nullable T oldValue, @Nullable T newValue) {
    while (true) {
        KeyFMap map = getUserMap();
        if (map.get(key) != oldValue) {
            return false;
        }
        KeyFMap newMap = newValue == null ? map.minus(key) : map.plus(key, newValue);
        if (newMap == map || changeUserMap(map, newMap)) {
            return true;
        }
    }
}
Also used : KeyFMap(com.intellij.util.keyFMap.KeyFMap)

Example 4 with KeyFMap

use of com.intellij.util.keyFMap.KeyFMap in project intellij-community by JetBrains.

the class UserDataHolderBase method getUserDataString.

@TestOnly
public String getUserDataString() {
    final KeyFMap userMap = getUserMap();
    final KeyFMap copyableMap = getUserData(COPYABLE_USER_MAP_KEY);
    return userMap + (copyableMap == null ? "" : copyableMap.toString());
}
Also used : KeyFMap(com.intellij.util.keyFMap.KeyFMap) TestOnly(org.jetbrains.annotations.TestOnly)

Example 5 with KeyFMap

use of com.intellij.util.keyFMap.KeyFMap in project intellij-community by JetBrains.

the class UserDataHolderBase method putUserData.

@Override
public <T> void putUserData(@NotNull Key<T> key, @Nullable T value) {
    while (true) {
        KeyFMap map = getUserMap();
        KeyFMap newMap = value == null ? map.minus(key) : map.plus(key, value);
        if (newMap == map || changeUserMap(map, newMap)) {
            break;
        }
    }
}
Also used : KeyFMap(com.intellij.util.keyFMap.KeyFMap)

Aggregations

KeyFMap (com.intellij.util.keyFMap.KeyFMap)9 Key (com.intellij.openapi.util.Key)2 NotNull (org.jetbrains.annotations.NotNull)2 ExternalTaskPojo (com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo)1 ExternalSystemExecutionSettings (com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings)1 ExternalSystemFacadeManager (com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager)1 RemoteExternalSystemFacade (com.intellij.openapi.externalSystem.service.RemoteExternalSystemFacade)1 RemoteExternalSystemTaskManager (com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemTaskManager)1 ArrayBackedFMap (com.intellij.util.keyFMap.ArrayBackedFMap)1 OneElementFMap (com.intellij.util.keyFMap.OneElementFMap)1 PairElementsFMap (com.intellij.util.keyFMap.PairElementsFMap)1 HashMap (java.util.HashMap)1 TestOnly (org.jetbrains.annotations.TestOnly)1