mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ConfigurationContext.getOriginalConfiguration(null) returns original configuration without filtering by its ConfigurationType
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.execution.PsiLocation;
|
||||
import com.intellij.execution.RunManager;
|
||||
import com.intellij.execution.RunnerAndConfigurationSettings;
|
||||
import com.intellij.execution.configurations.ConfigurationType;
|
||||
import com.intellij.execution.configurations.ConfigurationTypeUtil;
|
||||
import com.intellij.execution.configurations.RuntimeConfiguration;
|
||||
import com.intellij.execution.junit.RuntimeConfigurationProducer;
|
||||
import com.intellij.ide.DataManager;
|
||||
@@ -188,9 +189,24 @@ public class ConfigurationContext {
|
||||
return DataManager.getInstance().getDataContext(myContextComponent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns original {@link RuntimeConfiguration} from this context.
|
||||
* For example, it could be some test framework runtime configuration that had been launched
|
||||
* and that had brought a result test tree on which a right-click action was performed.
|
||||
*
|
||||
* @param type {@link ConfigurationType} instance to filter original runtime configuration by its type
|
||||
* @return {@link RuntimeConfiguration} instance, it could be null
|
||||
*/
|
||||
@Nullable
|
||||
public RuntimeConfiguration getOriginalConfiguration(final ConfigurationType type) {
|
||||
return myRuntimeConfiguration != null && Comparing.strEqual(type.getId(), myRuntimeConfiguration.getType().getId()) ? myRuntimeConfiguration : null;
|
||||
public RuntimeConfiguration getOriginalConfiguration(@Nullable ConfigurationType type) {
|
||||
if (type == null) {
|
||||
return myRuntimeConfiguration;
|
||||
}
|
||||
if (myRuntimeConfiguration != null
|
||||
&& ConfigurationTypeUtil.equals(myRuntimeConfiguration.getType(), type)) {
|
||||
return myRuntimeConfiguration;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -38,4 +39,8 @@ public class ConfigurationTypeUtil {
|
||||
assert false : Arrays.toString(types) + " loader: " + configurationTypeClass.getClassLoader();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean equals(@NotNull ConfigurationType type1, @NotNull ConfigurationType type2) {
|
||||
return type1.getId().equals(type2.getId());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user