Beispiel #1
0
        /// <summary>
        /// Called after the execution of run/compile/check/prolint
        /// </summary>
        public static void OnSingleExecutionOk(ProExecutionHandleCompilation lastExec, List <FileToCompile> filesToCompile, List <FileToDeploy> filesToDeploy)
        {
            try {
                var treatedFile = lastExec.Files.First();
                CurrentOperation currentOperation;
                if (!Enum.TryParse(lastExec.ExecutionType.ToString(), true, out currentOperation))
                {
                    currentOperation = CurrentOperation.Run;
                }

                var isCurrentFile     = treatedFile.SourcePath.EqualsCi(Npp.CurrentFileInfo.Path);
                var otherFilesInError = false;
                int nbWarnings        = 0;
                int nbErrors          = 0;

                // count number of warnings/errors, loop through files > loop through errors in each file
                foreach (var fileInError in filesToCompile.Where(file => file.Errors != null))
                {
                    foreach (var error in fileInError.Errors)
                    {
                        if (error.Level <= ErrorLevel.StrongWarning)
                        {
                            nbWarnings++;
                        }
                        else
                        {
                            nbErrors++;
                        }
                    }
                    otherFilesInError = otherFilesInError || !treatedFile.SourcePath.EqualsCi(fileInError.SourcePath);
                }

                // Prepare the notification content
                var notifTitle    = currentOperation.GetAttribute <CurrentOperationAttr>().Name;
                var notifImg      = (nbErrors > 0) ? MessageImg.MsgError : ((nbWarnings > 0) ? MessageImg.MsgWarning : MessageImg.MsgOk);
                var notifTimeOut  = (nbErrors > 0) ? 0 : ((nbWarnings > 0) ? 10 : 5);
                var notifSubtitle = lastExec.ExecutionType == ExecutionType.Prolint ? (nbErrors + nbWarnings) + " problem" + ((nbErrors + nbWarnings) > 1 ? "s" : "") + " detected" :
                                    (nbErrors > 0) ? nbErrors + " error" + (nbErrors > 1 ? "s" : "") + " found" :
                                    ((nbWarnings > 0) ? nbWarnings + " warning" + (nbWarnings > 1 ? "s" : "") + " found" :
                                     "Syntax correct");

                // when compiling, transferring .r/.lst to compilation dir
                if (filesToDeploy != null)
                {
                    filesToDeploy = lastExec.ProEnv.Deployer.DeployFiles(filesToDeploy, null, null);
                }

                // Notify the user, or not
                if (Config.Instance.CompileAlwaysShowNotification || !isCurrentFile || !Sci.GetFocus() || otherFilesInError)
                {
                    UserCommunication.NotifyUnique(treatedFile.SourcePath, "<div style='padding-bottom: 5px;'>Was " + currentOperation.GetAttribute <CurrentOperationAttr>().ActionText + " :</div>" + ProExecutionCompile.FormatCompilationResultForSingleFile(treatedFile.SourcePath, treatedFile, filesToDeploy), notifImg, notifTitle, notifSubtitle, null, notifTimeOut);
                }
            } catch (Exception e) {
                ErrorHandler.ShowErrors(e, "Error in OnExecutionOk");
            }
        }
Beispiel #2
0
        private static void OnGenerateDebugFileOk(ProExecutionHandleCompilation lastExec, List <FileToCompile> fileToCompiles, List <FileToDeploy> filesToDeploy)
        {
            var exec = (ProExecutionGenerateDebugfile)lastExec;

            if (!string.IsNullOrEmpty(exec.GeneratedFilePath) && File.Exists(exec.GeneratedFilePath))
            {
                if (exec.CompileWithDebugList)
                {
                    //make the .dbg file more readable
                    var output = new StringBuilder();
                    Utils.ForEachLine(exec.GeneratedFilePath, new byte[0], (i, line) => {
                        output.AppendLine(line.Length > 12 ? line.Substring(12) : string.Empty);
                    });
                    Utils.FileWriteAllText(exec.GeneratedFilePath, output.ToString());
                }
                Npp.Goto(exec.GeneratedFilePath);
            }
            OnSingleExecutionOk(lastExec, fileToCompiles, filesToDeploy);
        }
Beispiel #3
0
 /// <summary>
 /// Each time progress files are compiled, we update their respective error list to display them in notepad++
 /// </summary>
 public static void ProExecutionHandleCompilationOnEachCompilationOk(ProExecutionHandleCompilation proExecutionHandleCompilation, List <FileToCompile> fileToCompiles, List <FileToDeploy> filesToDeploy)
 {
     // clear errors on each compiled file
     if (fileToCompiles != null)
     {
         foreach (var file in fileToCompiles)
         {
             if (file.Errors != null && file.Errors.Count > 0)
             {
                 foreach (var fileErrors in file.Errors.GroupBy(error => error.SourcePath))
                 {
                     UpdateFileErrors(fileErrors.First().SourcePath, fileErrors.ToList());
                 }
             }
             else
             {
                 ClearAllErrors(file.SourcePath, true);
             }
         }
     }
 }