Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed https://github.com/Ashald/EnvFile/issues/27 #28

Merged
merged 2 commits into from
Mar 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.JavaParameters;
import com.intellij.execution.configurations.RunConfigurationBase;
import com.intellij.execution.configurations.RunnerSettings;
import com.intellij.openapi.options.ConfigurationException;
Expand Down Expand Up @@ -107,11 +108,9 @@ public static void writeExternal(@NotNull RunConfigurationBase configuration, @N
}
}

public static void patchCommandLine(@NotNull RunConfigurationBase configuration, @Nullable RunnerSettings runnerSettings, @NotNull GeneralCommandLine cmdLine) throws ExecutionException {
EnvFileSettings state = configuration.getUserData(USER_DATA_KEY);
public static void patchEnvironmentVariables(@NotNull RunConfigurationBase runConfigurationBase, Map<String, String> environmentVariables) throws ExecutionException {
EnvFileSettings state = runConfigurationBase.getUserData(USER_DATA_KEY);
if (state != null && state.isEnabled()) {
Map<String, String> source = cmdLine.getEnvironment();

Map<String, String> env = new HashMap<String, String>();
for (EnvFileEntry entry : state.getEntries()) {
try {
Expand All @@ -123,9 +122,9 @@ public static void patchCommandLine(@NotNull RunConfigurationBase configuration,
}
}

env.putAll(source);
source.clear();
source.putAll(env);
env.putAll(environmentVariables);
environmentVariables.clear();
environmentVariables.putAll(env);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.intellij.execution.ExecutionException;
import com.intellij.execution.RunConfigurationExtension;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.JavaParameters;
import com.intellij.execution.configurations.RunConfigurationBase;
import com.intellij.execution.configurations.RunnerSettings;
Expand Down Expand Up @@ -44,15 +43,14 @@ protected void readExternal(@NotNull RunConfigurationBase runConfiguration, @Not
EnvFileConfigurationEditor.readExternal(runConfiguration, element);
}


@Override
protected void validateConfiguration(@NotNull RunConfigurationBase configuration, boolean isExecution) throws Exception {
EnvFileConfigurationEditor.validateConfiguration(configuration, isExecution);
}

@Override
protected void patchCommandLine(@NotNull RunConfigurationBase configuration, RunnerSettings runnerSettings, @NotNull GeneralCommandLine cmdLine, @NotNull String runnerId) throws ExecutionException {
EnvFileConfigurationEditor.patchCommandLine(configuration, runnerSettings, cmdLine);
public <T extends RunConfigurationBase> void updateJavaParameters(T configuration, JavaParameters params, RunnerSettings runnerSettings) throws ExecutionException {
EnvFileConfigurationEditor.patchEnvironmentVariables(configuration, params.getEnv());
}

//
Expand All @@ -67,11 +65,4 @@ protected boolean isEnabledFor(@NotNull RunConfigurationBase applicableConfigura
return true;
}

//

@Override
public <T extends RunConfigurationBase> void updateJavaParameters(T configuration, JavaParameters params, RunnerSettings runnerSettings) throws ExecutionException {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected void validateConfiguration(@NotNull AbstractPythonRunConfiguration con

@Override
protected void patchCommandLine(@NotNull AbstractPythonRunConfiguration configuration, @Nullable RunnerSettings runnerSettings, @NotNull GeneralCommandLine cmdLine, @NotNull String runnerId) throws ExecutionException {
EnvFileConfigurationEditor.patchCommandLine(configuration, runnerSettings, cmdLine);
EnvFileConfigurationEditor.patchEnvironmentVariables(configuration, cmdLine.getEnvironment());
}

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected void validateConfiguration(@NotNull AbstractRubyRunConfiguration confi

@Override
protected void patchCommandLine(@NotNull AbstractRubyRunConfiguration configuration, @Nullable RunnerSettings runnerSettings, @NotNull GeneralCommandLine cmdLine, @NotNull String runnerId) throws ExecutionException {
EnvFileConfigurationEditor.patchCommandLine(configuration, runnerSettings, cmdLine);
EnvFileConfigurationEditor.patchEnvironmentVariables(configuration, cmdLine.getEnvironment());
}

//
Expand Down