/// <summary> /// Creates a new project object /// </summary> /// <param name="scheduler">The task scheduler</param> /// <param name="monitor">The file monitor</param> ///<param name="generator">The SrcML generator to use</param> public SrcMLProject(TaskScheduler scheduler, AbstractFileMonitor monitor, SrcMLGenerator generator) { Scheduler = scheduler; Monitor = monitor; SetupMonitor(generator); SourceArchive.Generator.IsLoggingErrors = true; SourceArchive.Generator.ErrorLog = new StreamWriter(Path.Combine(StoragePath, "error.log"), false); }
/// <summary> /// Creates a new project object /// </summary> /// <param name="scheduler">The task scheduler</param> /// <param name="monitor">The file monitor</param> ///<param name="generator">The SrcML generator to use</param> public SrcMLProject(TaskScheduler scheduler, AbstractFileMonitor monitor, SrcMLGenerator generator) { Scheduler = scheduler; Monitor = monitor; SetupMonitor(generator); SourceArchive.Generator.IsLoggingErrors = true; SourceArchive.Generator.ErrorLog = new StreamWriter(Path.Combine(StoragePath, "error.log"), false); }
/// <summary> /// SrcML service starts to monitor the opened solution. /// </summary> /// <param name="srcMLArchiveDirectory"></param> /// <param name="useExistingSrcML"></param> public void StartMonitoring(bool useExistingSrcML, string srcMLBinaryDirectory) { // Get the path of the folder that storing the srcML archives string srcMLArchiveDirectory = GetSrcMLArchiveFolder(SolutionMonitorFactory.GetOpenSolution()); SrcMLFileLogger.DefaultLogger.Info("SrcMLGlobalService.StartMonitoring( " + srcMLArchiveDirectory + " )"); try { // Create a new instance of SrcML.NET's LastModifiedArchive LastModifiedArchive lastModifiedArchive = new LastModifiedArchive(srcMLArchiveDirectory); // Create a new instance of SrcML.NET's SrcMLArchive SrcMLArchive sourceArchive = new SrcMLArchive(srcMLArchiveDirectory, useExistingSrcML, new SrcMLGenerator(srcMLBinaryDirectory)); CurrentSrcMLArchive = sourceArchive; // Create a new instance of SrcML.NET's solution monitor CurrentMonitor = SolutionMonitorFactory.CreateMonitor(srcMLArchiveDirectory, lastModifiedArchive, sourceArchive); // Subscribe events from Solution Monitor CurrentMonitor.FileChanged += RespondToFileChangedEvent; CurrentMonitor.IsReadyChanged += RespondToIsReadyChangedEvent; CurrentMonitor.MonitoringStopped += RespondToMonitoringStoppedEvent; // Initialize the progress bar. if(statusBar != null) { statusBar.Progress(ref cookie, 1, "", 0, 0); } // Start monitoring duringStartup = true; CurrentMonitor.StartMonitoring(); } catch(Exception e) { SrcMLFileLogger.DefaultLogger.Error(SrcMLExceptionFormatter.CreateMessage(e, "Exception in SrcMLGlobalService.StartMonitoring()")); } }
/// <summary> /// SrcML service stops monitoring the opened solution. /// </summary> public void StopMonitoring() { SrcMLFileLogger.DefaultLogger.Info("SrcMLGlobalService.StopMonitoring()"); try { if(CurrentMonitor != null && CurrentSrcMLArchive != null) { CurrentMonitor.StopMonitoring(); CurrentSrcMLArchive = null; CurrentMonitor = null; } } catch(Exception e) { SrcMLFileLogger.DefaultLogger.Error(SrcMLExceptionFormatter.CreateMessage(e, "Exception in SrcMLGlobalService.StopMonitoring()")); } }