예제 #1
0
        private FileSystemSnapshot BuildNewFileSystemSnapshot(IList <IProject> projects,
                                                              FileSystemSnapshot oldSnapshot, FullPathChanges pathChanges, CancellationToken cancellationToken)
        {
            using (new TimeElapsedLogger("Computing snapshot delta from list of file changes")) {
                // file name factory
                var fileNameFactory = _fileSystemNameFactory;
                if (ReuseFileNameInstances)
                {
                    if (oldSnapshot.ProjectRoots.Count > 0)
                    {
                        fileNameFactory = new FileSystemTreeSnapshotNameFactory(oldSnapshot, fileNameFactory);
                    }
                }

                // Compute new snapshot
                var newSnapshot = _fileSystemSnapshotBuilder.Compute(
                    fileNameFactory,
                    oldSnapshot,
                    pathChanges,
                    projects,
                    Interlocked.Increment(ref _version),
                    cancellationToken);

                // Monitor all project roots for file changes.
                var newRoots = newSnapshot.ProjectRoots
                               .Select(entry => entry.Directory.DirectoryName.FullPath);
                _directoryChangeWatcher.WatchDirectories(newRoots);

                return(newSnapshot);
            }
        }
예제 #2
0
        private void RecomputeGraph()
        {
            _snapshotOperationProcessor.Execute(new OperationInfo <SnapshotComputedEventArgs> {
                OnBeforeExecute = args => OnSnapshotComputing(args),
                OnAfterExecute  = args => OnSnapshotComputed(args),
                Execute         = args => {
                    Logger.Log("Collecting list of files from file system.");
                    Logger.LogMemoryStats();
                    var sw = Stopwatch.StartNew();

                    var files = new List <FullPathName>();
                    lock (_lock) {
                        ValidateKnownFiles();
                        files.AddRange(_addedFiles);
                    }

                    IFileSystemNameFactory fileNameFactory = _fileSystemNameFactory;
                    if (ReuseFileNameInstances)
                    {
                        if (_fileSystemSnapshot.ProjectRoots.Count > 0)
                        {
                            fileNameFactory = new FileSystemTreeSnapshotNameFactory(_fileSystemSnapshot, fileNameFactory);
                        }
                    }
                    var newSnapshot = _fileSystemSnapshotBuilder.Compute(fileNameFactory, files, Interlocked.Increment(ref _version));

                    // Monitor all the Chromium directories for changes.
                    var newRoots = newSnapshot.ProjectRoots
                                   .Select(entry => entry.Directory.DirectoryName);
                    _directoryChangeWatcher.WatchDirectories(newRoots);

                    // Update current tree atomically
                    FileSystemTreeSnapshot previousSnapshot;
                    lock (_lock) {
                        previousSnapshot    = _fileSystemSnapshot;
                        _fileSystemSnapshot = newSnapshot;
                    }

                    sw.Stop();
                    Logger.Log(">>>>>>>> Done collecting list of files: {0:n0} files in {1:n0} directories collected in {2:n0} msec.",
                               newSnapshot.ProjectRoots.Aggregate(0, (acc, x) => acc + CountFileEntries(x.Directory)),
                               newSnapshot.ProjectRoots.Aggregate(0, (acc, x) => acc + CountDirectoryEntries(x.Directory)),
                               sw.ElapsedMilliseconds);
                    Logger.LogMemoryStats();

                    return(new SnapshotComputedEventArgs {
                        PreviousSnapshot = previousSnapshot,
                        NewSnapshot = newSnapshot
                    });
                }
            });
        }
예제 #3
0
        private FileSystemTreeSnapshot ComputeNewSnapshot(FileSystemTreeSnapshot oldSnapshot, FullPathChanges pathChanges)
        {
            using (new TimeElapsedLogger("Computing snapshot delta from list of file changes")) {
                // Get list of currently registered files.
                var rootFiles = new List <FullPath>();
                lock (_lock) {
                    ValidateKnownFiles();
                    rootFiles.AddRange(_registeredFiles);
                }

                // file name factory
                var fileNameFactory = _fileSystemNameFactory;
                if (ReuseFileNameInstances)
                {
                    if (_fileSystemSnapshot.ProjectRoots.Count > 0)
                    {
                        fileNameFactory = new FileSystemTreeSnapshotNameFactory(_fileSystemSnapshot, fileNameFactory);
                    }
                }

                // Compute new snapshot
                var newSnapshot = _fileSystemSnapshotBuilder.Compute(
                    fileNameFactory,
                    oldSnapshot,
                    pathChanges,
                    rootFiles,
                    Interlocked.Increment(ref _version));

                // Monitor all the Chromium directories for changes.
                var newRoots = newSnapshot.ProjectRoots
                               .Select(entry => entry.Directory.DirectoryName.FullPath);
                _directoryChangeWatcher.WatchDirectories(newRoots);

                return(newSnapshot);
            }
        }