use of com.goide.sdk.GoSdkService in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoBeforeRunTaskProvider method canExecuteTask.
@Override
public boolean canExecuteTask(RunConfiguration configuration, GoCommandBeforeRunTask task) {
if (configuration instanceof GoRunConfigurationBase) {
Module module = ((GoRunConfigurationBase) configuration).getConfigurationModule().getModule();
GoSdkService sdkService = GoSdkService.getInstance(configuration.getProject());
if (sdkService.isGoModule(module)) {
return StringUtil.isNotEmpty(sdkService.getSdkHomePath(module)) && StringUtil.isNotEmpty(task.getCommand());
}
}
return false;
}
use of com.goide.sdk.GoSdkService in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoBeforeRunTaskProvider method executeTask.
@Override
public boolean executeTask(DataContext context, RunConfiguration configuration, ExecutionEnvironment env, GoCommandBeforeRunTask task) {
Semaphore done = new Semaphore();
Ref<Boolean> result = Ref.create(false);
GoRunConfigurationBase goRunConfiguration = (GoRunConfigurationBase) configuration;
Module module = goRunConfiguration.getConfigurationModule().getModule();
Project project = configuration.getProject();
String workingDirectory = goRunConfiguration.getWorkingDirectory();
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
if (StringUtil.isEmpty(task.getCommand()))
return;
if (project == null || project.isDisposed())
return;
GoSdkService sdkService = GoSdkService.getInstance(project);
if (!sdkService.isGoModule(module))
return;
done.down();
GoExecutor.in(module).withParameterString(task.getCommand()).withWorkDirectory(workingDirectory).showOutputOnError().showNotifications(false, true).withPresentableName("Executing `" + task + "`").withProcessListener(new ProcessAdapter() {
@Override
public void processTerminated(ProcessEvent event) {
done.up();
result.set(event.getExitCode() == 0);
}
}).executeWithProgress(false, result1 -> VirtualFileManager.getInstance().asyncRefresh(null));
}
});
done.waitFor();
return result.get();
}
Aggregations