Search in sources :

Example 11 with RunProfile

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) RunProfile(com.intellij.execution.configurations.RunProfile) Module(com.intellij.openapi.module.Module) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration) Nullable(org.jetbrains.annotations.Nullable)

Example 12 with RunProfile

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) GoRunConfigurationBase(com.goide.runconfig.GoRunConfigurationBase) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PsiDirectory(com.intellij.psi.PsiDirectory) GoUtil(com.goide.util.GoUtil) RunProfile(com.intellij.execution.configurations.RunProfile) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with RunProfile

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();
}
Also used : DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) Executor(com.intellij.execution.Executor) RunProfileState(com.intellij.execution.configurations.RunProfileState) DefaultProgramRunner(com.intellij.execution.runners.DefaultProgramRunner) ProcessHandler(com.intellij.execution.process.ProcessHandler) ExecutionResult(com.intellij.execution.ExecutionResult) RunProfile(com.intellij.execution.configurations.RunProfile) DefaultProgramRunner(com.intellij.execution.runners.DefaultProgramRunner) ProgramRunner(com.intellij.execution.runners.ProgramRunner) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull) ExecutionException(com.intellij.execution.ExecutionException)

Example 14 with RunProfile

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);
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) RunProfile(com.intellij.execution.configurations.RunProfile) KillableProcess(com.intellij.execution.KillableProcess) TaskInfo(com.intellij.openapi.progress.TaskInfo) ProcessHandler(com.intellij.execution.process.ProcessHandler) Pair(com.intellij.openapi.util.Pair)

Example 15 with RunProfile

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;
}
Also used : ModuleRunProfile(com.intellij.execution.configurations.ModuleRunProfile) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ModuleRunProfile(com.intellij.execution.configurations.ModuleRunProfile) RunProfile(com.intellij.execution.configurations.RunProfile) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RunProfile (com.intellij.execution.configurations.RunProfile)21 NotNull (org.jetbrains.annotations.NotNull)7 ProcessHandler (com.intellij.execution.process.ProcessHandler)6 Nullable (org.jetbrains.annotations.Nullable)6 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)5 Project (com.intellij.openapi.project.Project)5 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)4 RunConfigurationBase (com.intellij.execution.configurations.RunConfigurationBase)4 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)4 ExecutionException (com.intellij.execution.ExecutionException)3 ExecutionResult (com.intellij.execution.ExecutionResult)3 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)3 ProcessEvent (com.intellij.execution.process.ProcessEvent)3 ExecutionEnvironmentBuilder (com.intellij.execution.runners.ExecutionEnvironmentBuilder)3 Module (com.intellij.openapi.module.Module)3 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)2 CompatibilityAwareRunProfile (com.intellij.execution.configuration.CompatibilityAwareRunProfile)2 RunProfileState (com.intellij.execution.configurations.RunProfileState)2 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)2 ProgramRunner (com.intellij.execution.runners.ProgramRunner)2