/// <summary> /// Called after the execution of run/compile/check/prolint, clear the current operation from the file /// </summary> public static void OnSingleExecutionEnd(ProExecution lastExec) { try { var exec = (ProExecutionHandleCompilation)lastExec; var treatedFile = exec.Files.First(); CurrentOperation currentOperation; if (!Enum.TryParse(exec.ExecutionType.ToString(), true, out currentOperation)) { currentOperation = CurrentOperation.Run; } // Clear flag or we can't do any other actions on this file OpenedFilesInfo.GetOpenedFileInfo(treatedFile.SourcePath).CurrentOperation &= ~currentOperation; var isCurrentFile = treatedFile.SourcePath.EqualsCi(Npp.CurrentFileInfo.Path); if (isCurrentFile) { OpenedFilesInfo.UpdateFileStatus(); } OpenedFilesInfo.CurrentOpenedFileInfo.ProgressExecution = null; } catch (Exception e) { ErrorHandler.ShowErrors(e, "Error in OnExecutionEnd"); } }
/// <summary> /// Called to run/compile/check/prolint the current program /// </summary> public static void StartProgressExec(ExecutionType executionType, Action <ProExecutionHandleCompilation> execSetter = null) { CurrentOperation currentOperation; if (!Enum.TryParse(executionType.ToString(), true, out currentOperation)) { currentOperation = CurrentOperation.Run; } // process already running? if (OpenedFilesInfo.CurrentOpenedFileInfo.CurrentOperation >= CurrentOperation.Prolint) { UserCommunication.NotifyUnique("KillExistingProcess", "This file is already being compiled, run or lint-ed.<br>Please wait the end of the previous action,<br>or click the link below to interrupt the previous action :<br><a href='#'>Click to kill the associated prowin process</a>", MessageImg.MsgRip, currentOperation.GetAttribute <CurrentOperationAttr>().Name, "Already being compiled/run", args => { KillCurrentProcess(); StartProgressExec(executionType); args.Handled = true; }, 5); return; } if (!Npp.CurrentFileInfo.IsProgress) { UserCommunication.Notify("Can only compile and run progress files!", MessageImg.MsgWarning, "Invalid file type", "Progress files only", 10); return; } if (string.IsNullOrEmpty(Npp.CurrentFileInfo.Path) || !File.Exists(Npp.CurrentFileInfo.Path)) { UserCommunication.Notify("Couldn't find the following file :<br>" + Npp.CurrentFileInfo.Path, MessageImg.MsgError, "Execution error", "File not found", 10); return; } if (!Npp.CurrentFileInfo.IsCompilable) { UserCommunication.Notify("Sorry, the file extension " + Path.GetExtension(Npp.CurrentFileInfo.Path).Quoter() + " isn't a valid extension for this action!<br><i>You can change the list of valid extensions in the settings window</i>", MessageImg.MsgWarning, "Invalid file extension", "Not an executable", 10); return; } // when running a procedure, check that a .r is not hiding the program, if that's the case we warn the user if (executionType == ExecutionType.Run && !_dontWarnAboutRCode) { if (File.Exists(Path.ChangeExtension(Npp.CurrentFileInfo.Path, ".r"))) { UserCommunication.NotifyUnique("rcodehide", "Friendly warning, an <b>r-code</b> <i>(i.e. *.r file)</i> is hiding the current program<br>If you modified it since the last compilation you might not have the expected behavior...<br><br><i>" + "stop".ToHtmlLink("Click here to not show this message again for this session") + "</i>", MessageImg.MsgWarning, "Progress execution", "An Rcode hides the program", args => { _dontWarnAboutRCode = true; UserCommunication.CloseUniqueNotif("rcodehide"); }, 5); } } // update function prototypes ProGenerateCode.Factory.UpdateFunctionPrototypesIfNeeded(true); // launch the compile process for the current file OpenedFilesInfo.CurrentOpenedFileInfo.ProgressExecution = (ProExecutionHandleCompilation)ProExecution.Factory(executionType); OpenedFilesInfo.CurrentOpenedFileInfo.ProgressExecution.Files = new List <FileToCompile> { new FileToCompile(Npp.CurrentFileInfo.Path) }; OpenedFilesInfo.CurrentOpenedFileInfo.ProgressExecution.OnExecutionEnd += OnSingleExecutionEnd; if (execSetter != null) { execSetter(OpenedFilesInfo.CurrentOpenedFileInfo.ProgressExecution); OpenedFilesInfo.CurrentOpenedFileInfo.ProgressExecution.OnCompilationOk += OnGenerateDebugFileOk; } else { OpenedFilesInfo.CurrentOpenedFileInfo.ProgressExecution.OnCompilationOk += OnSingleExecutionOk; } if (!OpenedFilesInfo.CurrentOpenedFileInfo.ProgressExecution.Start()) { return; } // change file object current operation, set flag OpenedFilesInfo.CurrentOpenedFileInfo.CurrentOperation |= currentOperation; OpenedFilesInfo.UpdateFileStatus(); // clear current errors (updates the current file info) OpenedFilesInfo.ClearAllErrors(Npp.CurrentFileInfo.Path, true); }