internal void ProjectSnapshotManager_Changed(object sender, ProjectChangeEventArgs args)
        {
            // Don't do any work if the solution is closing
            if (args.SolutionIsClosing)
            {
                return;
            }

            _projectSnapshotManagerDispatcher.AssertDispatcherThread();

            switch (args.Kind)
            {
            case ProjectChangeKind.DocumentChanged:
            case ProjectChangeKind.DocumentRemoved:
                lock (_store)
                {
                    if (_store.ContainsKey(args.DocumentFilePath) &&
                        !_projectSnapshotManager.IsDocumentOpen(args.DocumentFilePath))
                    {
                        // Document closed or removed, evict entry.
                        _store.TryRemove(args.DocumentFilePath, out var _);
                    }
                }

                break;
            }
        }
Beispiel #2
0
        // Internal for testing
        internal void ProjectSnapshotManager_Changed(object sender, ProjectChangeEventArgs args)
        {
            _foregroundDispatcher.AssertForegroundThread();

            switch (args.Kind)
            {
            case ProjectChangeKind.DocumentChanged:
            case ProjectChangeKind.DocumentRemoved:
                lock (_store)
                {
                    if (_store.ContainsKey(args.DocumentFilePath) &&
                        !_projectSnapshotManager.IsDocumentOpen(args.DocumentFilePath))
                    {
                        // Document closed or removed, evict entry.
                        _store.TryRemove(args.DocumentFilePath, out var _);
                    }
                }
                break;
            }
        }
        // Internal for testing
        internal void Enqueue(DocumentSnapshot document)
        {
            _projectSnapshotManagerDispatcher.AssertDispatcherThread();

            if (!_projectManager.IsDocumentOpen(document.FilePath))
            {
                // We don't parse closed documents
                return;
            }

            lock (_work)
            {
                // We only want to store the last 'seen' version of any given document. That way when we pick one to process
                // it's always the best version to use.
                _work[document.FilePath] = document;

                StartWorker();
            }
        }
Beispiel #4
0
        private void ProjectSnapshotManager_Changed(object sender, ProjectChangeEventArgs args)
        {
            _foregroundDispatcher.AssertForegroundThread();

            switch (args.Kind)
            {
            case ProjectChangeKind.DocumentChanged:
            case ProjectChangeKind.DocumentRemoved:
                if (_publishedSourceText.ContainsKey(args.DocumentFilePath) &&
                    !_projectSnapshotManager.IsDocumentOpen(args.DocumentFilePath))
                {
                    // Document closed or removed, evict published source text.
                    var removed = _publishedSourceText.Remove(args.DocumentFilePath);

                    Debug.Assert(removed, "Published source text should be protected by the foreground thread and should never fail to remove.");
                }
                break;
            }
        }
Beispiel #5
0
        private void ProjectSnapshotManager_Changed(object sender, ProjectChangeEventArgs args)
        {
            _foregroundDispatcher.AssertForegroundThread();

            switch (args.Kind)
            {
            case ProjectChangeKind.ProjectAdded:
            {
                var projectSnapshot = _projectManager.GetLoadedProject(args.ProjectFilePath);
                foreach (var documentFilePath in projectSnapshot.DocumentFilePaths)
                {
                    if (_projectManager.IsDocumentOpen(documentFilePath))
                    {
                        var document = projectSnapshot.GetDocument(documentFilePath);
                        Enqueue(document);
                    }
                }

                break;
            }

            case ProjectChangeKind.ProjectChanged:
            {
                var projectSnapshot = _projectManager.GetLoadedProject(args.ProjectFilePath);
                foreach (var documentFilePath in projectSnapshot.DocumentFilePaths)
                {
                    if (_projectManager.IsDocumentOpen(documentFilePath))
                    {
                        var document = projectSnapshot.GetDocument(documentFilePath);
                        Enqueue(document);
                    }
                }

                break;
            }

            case ProjectChangeKind.DocumentAdded:
            {
                var project = _projectManager.GetLoadedProject(args.ProjectFilePath);
                if (_projectManager.IsDocumentOpen(args.DocumentFilePath))
                {
                    var document = project.GetDocument(args.DocumentFilePath);
                    Enqueue(document);
                }

                break;
            }

            case ProjectChangeKind.DocumentChanged:
            {
                var project = _projectManager.GetLoadedProject(args.ProjectFilePath);
                if (_projectManager.IsDocumentOpen(args.DocumentFilePath))
                {
                    var document = project.GetDocument(args.DocumentFilePath);
                    Enqueue(document);
                }

                break;
            }

            case ProjectChangeKind.ProjectRemoved:
            case ProjectChangeKind.DocumentRemoved:
            {
                // ignore
                break;
            }

            default:
                throw new InvalidOperationException($"Unknown ProjectChangeKind {args.Kind}");
            }
        }