Search in sources :

Example 6 with KeyFMap

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

the class ExportableUserDataHolderBase method exportUserData.

@NotNull
public final Map<Key, Object> exportUserData() {
    final Map<Key, Object> result = new HashMap<>();
    KeyFMap map = getUserMap();
    Key[] keys = map.getKeys();
    for (Key<?> k : keys) {
        final Object data = map.get(k);
        if (data != null) {
            result.put(k, data);
        }
    }
    return result;
}
Also used : KeyFMap(com.intellij.util.keyFMap.KeyFMap) HashMap(java.util.HashMap) Key(com.intellij.openapi.util.Key) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with KeyFMap

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

the class ExternalSystemExecuteTaskTask method doExecute.

@SuppressWarnings("unchecked")
@Override
protected void doExecute() throws Exception {
    final ExternalSystemFacadeManager manager = ServiceManager.getService(ExternalSystemFacadeManager.class);
    ExternalSystemExecutionSettings settings = ExternalSystemApiUtil.getExecutionSettings(getIdeProject(), getExternalProjectPath(), getExternalSystemId());
    KeyFMap keyFMap = getUserMap();
    for (Key key : keyFMap.getKeys()) {
        settings.putUserData(key, keyFMap.get(key));
    }
    RemoteExternalSystemFacade facade = manager.getFacade(getIdeProject(), getExternalProjectPath(), getExternalSystemId());
    RemoteExternalSystemTaskManager taskManager = facade.getTaskManager();
    List<String> taskNames = ContainerUtilRt.map2List(myTasksToExecute, ExternalTaskPojo::getName);
    final List<String> vmOptions = parseCmdParameters(myVmOptions);
    final List<String> arguments = parseCmdParameters(myArguments);
    settings.withVmOptions(vmOptions).withArguments(arguments);
    taskManager.executeTasks(getId(), taskNames, getExternalProjectPath(), settings, myJvmAgentSetup);
}
Also used : ExternalTaskPojo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo) KeyFMap(com.intellij.util.keyFMap.KeyFMap) RemoteExternalSystemTaskManager(com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemTaskManager) ExternalSystemFacadeManager(com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager) RemoteExternalSystemFacade(com.intellij.openapi.externalSystem.service.RemoteExternalSystemFacade) ExternalSystemExecutionSettings(com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings) Key(com.intellij.openapi.util.Key)

Example 8 with KeyFMap

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

the class UserDataHolderBase method putUserDataIfAbsent.

@Override
@NotNull
public <T> T putUserDataIfAbsent(@NotNull final Key<T> key, @NotNull final T value) {
    while (true) {
        KeyFMap map = getUserMap();
        T oldValue = map.get(key);
        if (oldValue != null) {
            return oldValue;
        }
        KeyFMap newMap = map.plus(key, value);
        if (newMap == map || changeUserMap(map, newMap)) {
            return value;
        }
    }
}
Also used : KeyFMap(com.intellij.util.keyFMap.KeyFMap) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with KeyFMap

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

the class UserDataHolderBase method putCopyableUserData.

public <T> void putCopyableUserData(@NotNull Key<T> key, T value) {
    while (true) {
        KeyFMap map = getUserMap();
        KeyFMap copyableMap = map.get(COPYABLE_USER_MAP_KEY);
        if (copyableMap == null) {
            copyableMap = KeyFMap.EMPTY_MAP;
        }
        KeyFMap newCopyableMap = value == null ? copyableMap.minus(key) : copyableMap.plus(key, value);
        KeyFMap newMap = newCopyableMap.isEmpty() ? map.minus(COPYABLE_USER_MAP_KEY) : map.plus(COPYABLE_USER_MAP_KEY, newCopyableMap);
        if (newMap == map || changeUserMap(map, newMap)) {
            return;
        }
    }
}
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