public static void SourceFileChanged(string configFile, string sourceFile) { ThreadPool.QueueUserWorkItem((o) => { try { WebCompilerInitPackage.StatusText($"Compiling..."); var activeProject = ProjectHelpers.GetActiveProject(); var projectRoot = ProjectHelpers.GetRootFolder(activeProject); var result = Processor.SourceFileChanged(configFile, sourceFile, projectRoot); ErrorListService.ProcessCompilerResults(result); } catch (FileNotFoundException ex) { Logger.Log($"{Constants.VSIX_NAME} could not find \"{ex.FileName}\""); WebCompilerInitPackage.StatusText($"{Constants.VSIX_NAME} could not find \"{ex.FileName}\""); } catch (Exception ex) { Logger.Log(ex); ShowError(configFile); } }); }
public static void Process(string configFile, IEnumerable <Config> configs = null, bool force = false) { ThreadPool.QueueUserWorkItem((o) => { try { var result = Processor.Process(configFile, configs, force); ErrorListService.ProcessCompilerResults(result); if (!result.Any(c => c.HasErrors)) { WebCompilerInitPackage.StatusText("Done compiling"); } } catch (Exception ex) when(ex is FileNotFoundException || ex is DirectoryNotFoundException) { string message = $"{Constants.VSIX_NAME} found an error in {Constants.CONFIG_FILENAME}"; Logger.Log(message); WebCompilerInitPackage.StatusText(message); _dte.StatusBar.Progress(false); } catch (Exception ex) { Logger.Log(ex); ShowError(configFile); _dte.StatusBar.Progress(false); WebCompilerInitPackage.StatusText($"{Constants.VSIX_NAME} couldn't compile successfully"); } finally { _dte.StatusBar.Progress(false); } }); }
public static void ProcessCompilerResults(IEnumerable <CompilerResult> results) { var errors = results.Where(r => r.HasErrors).SelectMany(r => r.Errors); var clean = results.Where(r => !r.HasErrors).Select(r => r.FileName); if (errors.Any()) { TableDataSource.Instance.AddErrors(errors); } if (results.Any(r => r.HasErrors)) { if (results.Any(r => r.Errors.Any(e => !e.IsWarning))) { WebCompilerPackage._dte.StatusBar.Text = "Error compiling. See Error List for details"; TableDataSource.Instance.BringToFront(); } else { WebCompilerInitPackage.StatusText($"Compiled with warnings"); } } else { WebCompilerInitPackage.StatusText($"Compiled successfully"); } TableDataSource.Instance.CleanErrors(clean); }