private void UpdateFileContents(IEnumerable <ProjectFileName> files) { OperationInfo operationInfo = null; _operationProcessor.Execute(new OperationHandlers { OnBeforeExecute = info => operationInfo = info, OnError = (info, error) => { OnFilesLoading(info); OnFilesLoaded(new FilesLoadedResult { OperationInfo = info, Error = error, TreeVersion = _currentTreeVersion, }); }, Execute = info => { _currentFileDatabase = _fileDatabaseFactory.CreateWithChangedFiles( _currentFileDatabase, files, onLoading: () => OnFilesLoading(operationInfo), onLoaded: () => OnFilesLoaded(new FilesLoadedResult { OperationInfo = operationInfo, TreeVersion = _currentTreeVersion, })); } }); }
private void UpdateFileContents(IEnumerable <Tuple <IProject, FileName> > paths) { _fileLoadingOperationProcessor.Execute(new OperationInfo <OperationResultEventArgs> { OnBeforeExecute = args => OnFilesLoading(args), OnAfterExecute = args => OnFilesLoaded(args), Execute = _ => { paths.ForAll(x => _currentFileDatabase.UpdateFileContents(x)); return(new OperationResultEventArgs()); } }); }
private void RecomputeGraph(FullPathChanges pathChanges) { _operationProcessor.Execute(new OperationHandlers { OnBeforeExecute = info => OnSnapshotComputing(info), OnError = (info, error) => OnSnapshotComputed(new SnapshotComputedResult { OperationInfo = info, Error = error }), Execute = info => { // Compute and assign new snapshot var oldSnapshot = _fileSystemSnapshot; var newSnapshot = ComputeNewSnapshot(oldSnapshot, pathChanges); // Update of new tree (assert calls are serialized). Debug.Assert(ReferenceEquals(oldSnapshot, _fileSystemSnapshot)); _fileSystemSnapshot = newSnapshot; if (Logger.Info) { Logger.LogInfo("+++++++++++ Collected {0:n0} files in {1:n0} directories", newSnapshot.ProjectRoots.Aggregate(0, (acc, x) => acc + CountFileEntries(x.Directory)), newSnapshot.ProjectRoots.Aggregate(0, (acc, x) => acc + CountDirectoryEntries(x.Directory))); } // Post event OnSnapshotComputed(new SnapshotComputedResult { OperationInfo = info, PreviousSnapshot = oldSnapshot, FullPathChanges = pathChanges, NewSnapshot = newSnapshot }); } }); }
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 }); } }); }
private void RescanFileSystem(IList <IProject> projects, FullPathChanges pathChanges /* may be null */, CancellationToken cancellationToken) { _registeredProjects = projects; _operationProcessor.Execute(new OperationHandlers { OnBeforeExecute = info => OnSnapshotScanStarted(info), OnError = (info, error) => { if (!error.IsCanceled()) { Logger.LogError(error, "File system rescan error"); } OnSnapshotScanFinished(new SnapshotScanResult { OperationInfo = info, Error = error }); }, Execute = info => { // Compute and assign new snapshot var oldSnapshot = _currentSnapshot; var newSnapshot = BuildNewFileSystemSnapshot(projects, oldSnapshot, pathChanges, cancellationToken); // Update of new tree (assert calls are serialized). Invariants.Assert(ReferenceEquals(oldSnapshot, _currentSnapshot)); _currentSnapshot = newSnapshot; if (Logger.IsInfoEnabled) { Logger.LogInfo("FileSystemSnapshotManager: New snapshot contains {0:n0} files in {1:n0} directories", newSnapshot.ProjectRoots.Aggregate(0, (acc, x) => acc + CountFileEntries(x.Directory)), newSnapshot.ProjectRoots.Aggregate(0, (acc, x) => acc + CountDirectoryEntries(x.Directory))); } // Post event OnSnapshotScanFinished(new SnapshotScanResult { OperationInfo = info, PreviousSnapshot = oldSnapshot, FullPathChanges = pathChanges, NewSnapshot = newSnapshot }); } }); }