示例#1
0
        private void LoadArchive(BackgroundWorker worker, string pathToMappingFile, out SrcMLArchive archive, out AbstractWorkingSet data, out string projectName) {
            throw new NotImplementedException();
            //string pathToArchive = FilePath.GetDirectoryName(pathToMappingFile);
            //string archiveDirectoryName = FilePath.GetFileName(pathToArchive);
            //string baseDirectory = FilePath.GetFullPath(FilePath.GetDirectoryName(pathToArchive));

            //projectName = FilePath.GetFileName(baseDirectory);
            //worker.ReportProgress(0, String.Format("Loading {0}", projectName));
            //archive = new SrcMLArchive(baseDirectory, archiveDirectoryName);
            //int numberOfFiles = archive.FileUnits.Count();
            //worker.ReportProgress(0, String.Format("Loading {0} ({1} files)", projectName, numberOfFiles));

            //data = new DataRepository(archive);
            //int i = 0;
            //foreach(var unit in archive.FileUnits) {
            //    try {
            //        data.AddFile(unit);
            //    } catch(Exception) {
            //    }

            //    if(++i % 25 == 0) {
            //        int percentComplete = (int) (100 * (double) i / (double) numberOfFiles);
            //        worker.ReportProgress(percentComplete, String.Format("Loading {0} ({1} / {2} files)", projectName, i, numberOfFiles));
            //    }
            //}
            //worker.ReportProgress(100, String.Format("Loaded {0} ({1} files)", baseDirectory, i));
        }
示例#2
0
        /// <summary>
        /// Sets up the <see cref="CurrentDataArchive"/> and <see cref="CurrentWorkingSet"/> to respond to events from the srcML service
        /// </summary>
        protected override void Setup() {
            string storagePath = _srcMLService.CurrentMonitor.MonitorStoragePath;
            SrcMLArchive sourceArchive = _srcMLService.CurrentSrcMLArchive;

            CurrentDataArchive = new DataArchive(storagePath, sourceArchive, GlobalScheduler);
            CurrentDataArchive.Generator.ErrorLog = sourceArchive.Generator.ErrorLog;
            CurrentDataArchive.Generator.IsLoggingErrors = true;

            _srcMonitor = new ArchiveMonitor<SrcMLArchive>(GlobalScheduler, storagePath, sourceArchive, CurrentDataArchive);
            CurrentWorkingSet = _workingSetFactories.Default.CreateWorkingSet(storagePath, CurrentDataArchive, GlobalTaskFactory);
            CurrentWorkingSet.UseAsynchronousMethods = true;
        }
        private static MethodDefinition GetMethodWithName(AbstractWorkingSet workingSet, int timeout, string methodName) {
            MethodDefinition result = null;
            NamespaceDefinition globalScope;
            Assert.That(workingSet.TryObtainReadLock(timeout, out globalScope));
            try {
                result = globalScope.GetNamedChildren<MethodDefinition>("foo").FirstOrDefault();
                return result;
            } finally {
                workingSet.ReleaseReadLock();
            }

        }
        private static MethodDefinition GetMethodWithName(AbstractWorkingSet workingSet, int timeout, string methodName)
        {
            MethodDefinition    result = null;
            NamespaceDefinition globalScope;

            Assert.That(workingSet.TryObtainReadLock(timeout, out globalScope));
            try {
                result = globalScope.GetNamedChildren <MethodDefinition>("foo").FirstOrDefault();
                return(result);
            } finally {
                workingSet.ReleaseReadLock();
            }
        }
        /// <summary>
        /// Sets up the <see cref="CurrentDataArchive"/> and <see cref="CurrentWorkingSet"/> to respond to events from the srcML service
        /// </summary>
        protected override void Setup()
        {
            string       storagePath   = _srcMLService.CurrentMonitor.MonitorStoragePath;
            SrcMLArchive sourceArchive = _srcMLService.CurrentSrcMLArchive;

            CurrentDataArchive = new DataArchive(storagePath, sourceArchive, GlobalScheduler);
            CurrentDataArchive.Generator.ErrorLog        = sourceArchive.Generator.ErrorLog;
            CurrentDataArchive.Generator.IsLoggingErrors = true;

            _srcMonitor       = new ArchiveMonitor <SrcMLArchive>(GlobalScheduler, storagePath, sourceArchive, CurrentDataArchive);
            CurrentWorkingSet = _workingSetFactories.Default.CreateWorkingSet(storagePath, CurrentDataArchive, GlobalTaskFactory);
            CurrentWorkingSet.UseAsynchronousMethods = true;
        }
 /// <summary>
 /// Implementation method for <see cref="AbstractMonitoringService.StopMonitoring"/>
 /// </summary>
 protected override void StopMonitoringImpl()
 {
     if (null != CurrentWorkingSet)
     {
         _srcMonitor.FileChanged -= _srcMonitor_FileChanged;
         CurrentWorkingSet.StopMonitoring();
         _srcMonitor.StopMonitoring();
         CurrentWorkingSet.Dispose();
         _srcMonitor.Dispose();
         CurrentWorkingSet  = null;
         CurrentDataArchive = null;
         _srcMonitor        = null;
     }
 }
示例#7
0
        public MethodCallSample(SrcMLArchive archive, AbstractWorkingSet data, int sampleSize) {
            this.Archive = archive;
            this.Data = data;
            this.Date = DateTime.Now;
            this._projectName = string.Empty;
            this.SampleSize = sampleSize;

            FirstMatchIsValid = new Statistic("FirstMatchIsValid", SampleSize);
            HasMatches = new Statistic("HasMatches", SampleSize);
            HasNoMatches = new Statistic("HasNoMatches", SampleSize);
            IsExternal = new Statistic("IsExternal", SampleSize);

            FirstMatchIsValid.PropertyChanged += StatisticChanged;
            HasMatches.PropertyChanged += StatisticChanged;
            HasNoMatches.PropertyChanged += StatisticChanged;
            IsExternal.PropertyChanged += StatisticChanged;
        }
        public MethodCallSample(SrcMLArchive archive, AbstractWorkingSet data, int sampleSize)
        {
            this.Archive      = archive;
            this.Data         = data;
            this.Date         = DateTime.Now;
            this._projectName = string.Empty;
            this.SampleSize   = sampleSize;

            FirstMatchIsValid = new Statistic("FirstMatchIsValid", SampleSize);
            HasMatches        = new Statistic("HasMatches", SampleSize);
            HasNoMatches      = new Statistic("HasNoMatches", SampleSize);
            IsExternal        = new Statistic("IsExternal", SampleSize);

            FirstMatchIsValid.PropertyChanged += StatisticChanged;
            HasMatches.PropertyChanged        += StatisticChanged;
            HasNoMatches.PropertyChanged      += StatisticChanged;
            IsExternal.PropertyChanged        += StatisticChanged;
        }
        private void LoadArchive(BackgroundWorker worker, string pathToMappingFile, out SrcMLArchive archive, out AbstractWorkingSet data, out string projectName)
        {
            throw new NotImplementedException();
            //string pathToArchive = FilePath.GetDirectoryName(pathToMappingFile);
            //string archiveDirectoryName = FilePath.GetFileName(pathToArchive);
            //string baseDirectory = FilePath.GetFullPath(FilePath.GetDirectoryName(pathToArchive));

            //projectName = FilePath.GetFileName(baseDirectory);
            //worker.ReportProgress(0, String.Format("Loading {0}", projectName));
            //archive = new SrcMLArchive(baseDirectory, archiveDirectoryName);
            //int numberOfFiles = archive.FileUnits.Count();
            //worker.ReportProgress(0, String.Format("Loading {0} ({1} files)", projectName, numberOfFiles));

            //data = new DataRepository(archive);
            //int i = 0;
            //foreach(var unit in archive.FileUnits) {
            //    try {
            //        data.AddFile(unit);
            //    } catch(Exception) {
            //    }

            //    if(++i % 25 == 0) {
            //        int percentComplete = (int) (100 * (double) i / (double) numberOfFiles);
            //        worker.ReportProgress(percentComplete, String.Format("Loading {0} ({1} / {2} files)", projectName, i, numberOfFiles));
            //    }
            //}
            //worker.ReportProgress(100, String.Format("Loaded {0} ({1} files)", baseDirectory, i));
        }
示例#10
0
        /// <summary>
        /// Implementation method for <see cref="AbstractMonitoringService.Update"/>
        /// </summary>
        protected override void UpdateImpl() {
            _srcMonitor.UpdateArchivesAsync().Wait();

            bool workingSetFailed = false;
            try {
                CurrentWorkingSet.InitializeAsync().Wait();
            } catch(AggregateException e) {
                workingSetFailed = true;
                var logFileName = Path.Combine(ServiceProvider.ExtensionDirectory, "update_error.log");
                bool logFileIsNew = !File.Exists(logFileName);
                using(var error = new StreamWriter(logFileName, true)) {
                    if(logFileIsNew) {
                        error.WriteLine("Please e-mail the contents of this file to [email protected]");
                        error.WriteLine();
                        error.WriteLine("Calling Assembly: {0}", this.GetType().AssemblyQualifiedName);
                        error.WriteLine("Working Set: {0}", CurrentWorkingSet.GetType().AssemblyQualifiedName);
                    }
                    
                    foreach(var exception in e.InnerExceptions) {
                        error.WriteLine();
                        error.WriteLine("=========================================================");
                        error.WriteLine("Message: {0}", exception.Message);
                        error.WriteLine("Source: {0}", exception.Source);
                        error.WriteLine(exception.StackTrace);
                    }
                }

                if(workingSetFailed) {
                    var failoverFileName = Path.Combine(_srcMonitor.MonitorStoragePath, WS_FAILOVER_FILENAME);
                    bool useCompleteWorkingSet;
                    bool askUser = true;

                    if(File.Exists(failoverFileName) && Boolean.TryParse(File.ReadAllText(failoverFileName), out useCompleteWorkingSet)) {
                        askUser = false;
                    } else {
                        useCompleteWorkingSet = false;
                    }

                    if(askUser) {
                        string message = String.Format("Prodet selective analysis has encountered an error. Do you want to load analysis for all files? Your solution has {0} files. Solutions with >1000 files may consume too much memory.", CurrentDataArchive.GetFiles().Count());
                        int fileCount = CurrentDataArchive.GetFiles().Count();
                        MessageBoxResult defaultResult = (fileCount > 1000 ? MessageBoxResult.No : MessageBoxResult.Yes);
                        Application.Current.Dispatcher.Invoke(new Action(() => {
                            var userInput = MessageBox.Show(Application.Current.MainWindow, message, "Working Set Error", MessageBoxButton.YesNo, MessageBoxImage.Error, defaultResult);

                            switch(userInput) {
                                case MessageBoxResult.Yes:
                                    useCompleteWorkingSet = true;
                                    break;
                                case MessageBoxResult.No:
                                    useCompleteWorkingSet = false;
                                    break;
                                default:
                                    useCompleteWorkingSet = false;
                                    break;
                            }
                        }));

                        File.WriteAllText(failoverFileName, useCompleteWorkingSet.ToString());
                    }

                    if(logFileIsNew) {
                        System.Diagnostics.Process.Start("notepad.exe", logFileName);
                    }

                    CurrentWorkingSet.Dispose();
                    if(useCompleteWorkingSet) {
                        CurrentWorkingSet = new CompleteWorkingSet(CurrentDataArchive, GlobalTaskFactory);
                        CurrentWorkingSet.InitializeAsync().Wait();
                    } else {
                        CurrentWorkingSet = null;
                    }
                }
            }
        }
示例#11
0
 /// <summary>
 /// Implementation method for <see cref="AbstractMonitoringService.StopMonitoring"/>
 /// </summary>
 protected override void StopMonitoringImpl() {
     if(null != CurrentWorkingSet) {
         _srcMonitor.FileChanged -= _srcMonitor_FileChanged;
         CurrentWorkingSet.StopMonitoring();
         _srcMonitor.StopMonitoring();
         CurrentWorkingSet.Dispose();
         _srcMonitor.Dispose();
         CurrentWorkingSet = null;
         CurrentDataArchive = null;
         _srcMonitor = null;
     }
 }
示例#12
0
 /// <summary>
 /// Creates a new query object
 /// </summary>
 /// <param name="workingSet">The working set to query</param>
 /// <param name="lockTimeout">The time in milliseconds to wait for the read lock</param>
 /// <param name="factory">The task factory to use for asynchronous methods</param>
 public FindMethodCallsAtLocationQuery(AbstractWorkingSet workingSet, int lockTimeout, TaskFactory factory)
     : base(workingSet, lockTimeout, factory)
 {
 }
示例#13
0
 /// <summary>
 /// Creates a new query object
 /// </summary>
 /// <param name="workingSet">The working set to query</param>
 /// <param name="lockTimeout">The time in milliseconds to wait for the read lock</param>
 public FindMethodCallsAtLocationQuery(AbstractWorkingSet workingSet, int lockTimeout)
     : base(workingSet, lockTimeout)
 {
 }
 /// <summary>
 /// Create a new query object
 /// </summary>
 /// <param name="workingSet">The working set to query</param>
 /// <param name="lockTimeout">The time in milliseconds to wait for the read lock</param>
 /// <param name="factory">The task factory for asynchronous queries</param>
 public StatementForLocationQuery(AbstractWorkingSet workingSet, int lockTimeout, TaskFactory factory)
     : base(workingSet, lockTimeout, factory)
 {
 }
 /// <summary>
 /// Create a new query object
 /// </summary>
 /// <param name="workingSet">The working set to query</param>
 /// <param name="lockTimeout">The time in milliseconds to wait for the read lock</param>
 public StatementForLocationQuery(AbstractWorkingSet workingSet, int lockTimeout)
     : base(workingSet, lockTimeout)
 {
 }
示例#16
0
        /// <summary>
        /// Implementation method for <see cref="AbstractMonitoringService.Update"/>
        /// </summary>
        protected override void UpdateImpl()
        {
            _srcMonitor.UpdateArchivesAsync().Wait();

            bool workingSetFailed = false;

            try {
                CurrentWorkingSet.InitializeAsync().Wait();
            } catch (AggregateException e) {
                workingSetFailed = true;
                var  logFileName  = Path.Combine(ServiceProvider.ExtensionDirectory, "update_error.log");
                bool logFileIsNew = !File.Exists(logFileName);
                using (var error = new StreamWriter(logFileName, true)) {
                    if (logFileIsNew)
                    {
                        error.WriteLine("Please e-mail the contents of this file to [email protected]");
                        error.WriteLine();
                        error.WriteLine("Calling Assembly: {0}", this.GetType().AssemblyQualifiedName);
                        error.WriteLine("Working Set: {0}", CurrentWorkingSet.GetType().AssemblyQualifiedName);
                    }

                    foreach (var exception in e.InnerExceptions)
                    {
                        error.WriteLine();
                        error.WriteLine("=========================================================");
                        error.WriteLine("Message: {0}", exception.Message);
                        error.WriteLine("Source: {0}", exception.Source);
                        error.WriteLine(exception.StackTrace);
                    }
                }

                if (workingSetFailed)
                {
                    var  failoverFileName = Path.Combine(_srcMonitor.MonitorStoragePath, WS_FAILOVER_FILENAME);
                    bool useCompleteWorkingSet;
                    bool askUser = true;

                    if (File.Exists(failoverFileName) && Boolean.TryParse(File.ReadAllText(failoverFileName), out useCompleteWorkingSet))
                    {
                        askUser = false;
                    }
                    else
                    {
                        useCompleteWorkingSet = false;
                    }

                    if (askUser)
                    {
                        string           message       = String.Format("Prodet selective analysis has encountered an error. Do you want to load analysis for all files? Your solution has {0} files. Solutions with >1000 files may consume too much memory.", CurrentDataArchive.GetFiles().Count());
                        int              fileCount     = CurrentDataArchive.GetFiles().Count();
                        MessageBoxResult defaultResult = (fileCount > 1000 ? MessageBoxResult.No : MessageBoxResult.Yes);
                        Application.Current.Dispatcher.Invoke(new Action(() => {
                            var userInput = MessageBox.Show(Application.Current.MainWindow, message, "Working Set Error", MessageBoxButton.YesNo, MessageBoxImage.Error, defaultResult);

                            switch (userInput)
                            {
                            case MessageBoxResult.Yes:
                                useCompleteWorkingSet = true;
                                break;

                            case MessageBoxResult.No:
                                useCompleteWorkingSet = false;
                                break;

                            default:
                                useCompleteWorkingSet = false;
                                break;
                            }
                        }));

                        File.WriteAllText(failoverFileName, useCompleteWorkingSet.ToString());
                    }

                    if (logFileIsNew)
                    {
                        System.Diagnostics.Process.Start("notepad.exe", logFileName);
                    }

                    CurrentWorkingSet.Dispose();
                    if (useCompleteWorkingSet)
                    {
                        CurrentWorkingSet = new CompleteWorkingSet(CurrentDataArchive, GlobalTaskFactory);
                        CurrentWorkingSet.InitializeAsync().Wait();
                    }
                    else
                    {
                        CurrentWorkingSet = null;
                    }
                }
            }
        }