use of com.intellij.execution.configurations.RunProfile in project go-lang-idea-plugin by go-lang-plugin-org.
the class DlvStackFrame method findFile.
@Nullable
private VirtualFile findFile() {
String url = myLocation.file;
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(url);
if (file == null && SystemInfo.isWindows) {
Project project = myProcess.getSession().getProject();
RunProfile profile = myProcess.getSession().getRunProfile();
Module module = profile instanceof ModuleBasedConfiguration ? ((ModuleBasedConfiguration) profile).getConfigurationModule().getModule() : null;
String sdkHomePath = GoSdkService.getInstance(project).getSdkHomePath(module);
if (sdkHomePath == null)
return null;
String newUrl = StringUtil.replaceIgnoreCase(url, "c:/go", sdkHomePath);
return LocalFileSystem.getInstance().findFileByPath(newUrl);
}
return file;
}
use of com.intellij.execution.configurations.RunProfile in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoTestConsoleProperties method initScope.
@NotNull
@Override
protected GlobalSearchScope initScope() {
RunProfile configuration = getConfiguration();
if (configuration instanceof GoTestRunConfiguration) {
Project project = ((GoTestRunConfiguration) configuration).getProject();
Module module = ((GoTestRunConfiguration) configuration).getConfigurationModule().getModule();
switch(((GoTestRunConfiguration) configuration).getKind()) {
case DIRECTORY:
String directoryUrl = VfsUtilCore.pathToUrl(((GoTestRunConfiguration) configuration).getDirectoryPath());
VirtualFile directory = VirtualFileManager.getInstance().findFileByUrl(directoryUrl);
if (directory != null) {
return GlobalSearchScopesCore.directoryScope(project, directory, true);
}
break;
case PACKAGE:
VirtualFile packageDir = GoPackageUtil.findByImportPath(((GoTestRunConfiguration) configuration).getPackage(), project, module);
PsiDirectory psiDirectory = packageDir != null ? PsiManager.getInstance(project).findDirectory(packageDir) : null;
if (psiDirectory != null) {
return GoPackageUtil.packageScope(psiDirectory, null);
}
break;
case FILE:
String fileUrl = VfsUtilCore.pathToUrl(((GoTestRunConfiguration) configuration).getFilePath());
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(fileUrl);
if (file != null) {
return GlobalSearchScope.fileScope(project, file);
}
break;
}
}
if (configuration instanceof GoRunConfigurationBase) {
GlobalSearchScope scope = GlobalSearchScope.EMPTY_SCOPE;
for (Module module : ((GoRunConfigurationBase) configuration).getModules()) {
scope = new GoUtil.TestsScope(GoUtil.goPathResolveScope(module, null));
}
return scope;
}
return super.initScope();
}
use of com.intellij.execution.configurations.RunProfile in project intellij-community by JetBrains.
the class RemoteProcessSupport method startProcess.
private void startProcess(Target target, Parameters configuration, @NotNull Pair<Target, Parameters> key) {
ProgramRunner runner = new DefaultProgramRunner() {
@Override
@NotNull
public String getRunnerId() {
return "MyRunner";
}
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
return true;
}
};
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
ProcessHandler processHandler;
try {
RunProfileState state = getRunProfileState(target, configuration, executor);
ExecutionResult result = state.execute(executor, runner);
//noinspection ConstantConditions
processHandler = result.getProcessHandler();
} catch (Exception e) {
dropProcessInfo(key, e instanceof ExecutionException ? e.getMessage() : ExceptionUtil.getUserStackTrace(e, LOG), null);
return;
}
processHandler.addProcessListener(getProcessListener(key));
processHandler.startNotify();
}
use of com.intellij.execution.configurations.RunProfile in project intellij-community by JetBrains.
the class StopAction method update.
@Override
public void update(final AnActionEvent e) {
boolean enable = false;
Icon icon = getTemplatePresentation().getIcon();
String description = getTemplatePresentation().getDescription();
Presentation presentation = e.getPresentation();
if (isPlaceGlobal(e)) {
List<RunContentDescriptor> stoppableDescriptors = getActiveStoppableDescriptors(e.getDataContext());
List<Pair<TaskInfo, ProgressIndicator>> cancellableProcesses = getCancellableProcesses(e.getProject());
int todoSize = stoppableDescriptors.size() + cancellableProcesses.size();
if (todoSize > 1) {
presentation.setText(getTemplatePresentation().getText() + "...");
} else if (todoSize == 1) {
if (stoppableDescriptors.size() == 1) {
presentation.setText(ExecutionBundle.message("stop.configuration.action.name", StringUtil.escapeMnemonics(stoppableDescriptors.get(0).getDisplayName())));
} else {
TaskInfo taskInfo = cancellableProcesses.get(0).first;
presentation.setText(taskInfo.getCancelText() + " " + taskInfo.getTitle());
}
} else {
presentation.setText(getTemplatePresentation().getText());
}
enable = todoSize > 0;
if (todoSize > 1) {
icon = IconUtil.addText(icon, String.valueOf(todoSize));
}
} else {
RunContentDescriptor contentDescriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
ProcessHandler processHandler = contentDescriptor == null ? null : contentDescriptor.getProcessHandler();
if (processHandler != null && !processHandler.isProcessTerminated()) {
if (!processHandler.isProcessTerminating()) {
enable = true;
} else if (processHandler instanceof KillableProcess && ((KillableProcess) processHandler).canKillProcess()) {
enable = true;
icon = AllIcons.Debugger.KillProcess;
description = "Kill process";
}
}
RunProfile runProfile = e.getData(LangDataKeys.RUN_PROFILE);
if (runProfile == null && contentDescriptor == null) {
presentation.setText(getTemplatePresentation().getText());
} else {
presentation.setText(ExecutionBundle.message("stop.configuration.action.name", StringUtil.escapeMnemonics(runProfile == null ? contentDescriptor.getDisplayName() : runProfile.getName())));
}
}
presentation.setEnabled(enable);
presentation.setIcon(icon);
presentation.setDescription(description);
}
use of com.intellij.execution.configurations.RunProfile in project intellij-community by JetBrains.
the class TestConsoleProperties method initScope.
@NotNull
protected GlobalSearchScope initScope() {
RunProfile configuration = getConfiguration();
if (!(configuration instanceof ModuleRunProfile)) {
return GlobalSearchScope.allScope(myProject);
}
Module[] modules = ((ModuleRunProfile) configuration).getModules();
if (modules.length == 0) {
return GlobalSearchScope.allScope(myProject);
}
GlobalSearchScope scope = GlobalSearchScope.EMPTY_SCOPE;
for (Module each : modules) {
scope = scope.uniteWith(GlobalSearchScope.moduleRuntimeScope(each, true));
}
return scope;
}
Aggregations