public void StartTracking(EditSession editSession)
 {
     if (Interlocked.CompareExchange(ref _session, new TrackingSession(this, editSession), null) != null)
     {
         Debug.Assert(false, "Can only track active statements for a single edit session.");
     }
 }
        public void StartEditSession(
            Solution currentSolution,
            IReadOnlyDictionary<DocumentId, ImmutableArray<ActiveStatementSpan>> activeStatements,
            ImmutableDictionary<ProjectId, ProjectReadOnlyReason> projects,
            bool stoppedAtException)
        {
            Debug.Assert(_debuggingSession != null && _editSession == null);

            var newSession = new EditSession(currentSolution, activeStatements, _debuggingSession, projects, stoppedAtException);

            Interlocked.CompareExchange(ref _editSession, newSession, null);

            // TODO(tomat): allow changing documents
            // TODO(tomat): document added
        }
        public void EndEditSession()
        {
            Debug.Assert(_debuggingSession != null && _editSession != null);

            var session = _editSession;

            // first, publish null session:
            _editSession = null;

            // then cancel all ongoing work bound to the session:
            session.Cancellation.Cancel();

            // then clear all reported rude edits:
            _diagnosticService.Reanalyze(_debuggingSession.InitialSolution.Workspace, documentIds: session.GetDocumentsWithReportedRudeEdits());

            // TODO(tomat): allow changing documents
        }
            public TrackingSession(ActiveStatementTrackingService service, EditSession editSession)
            {
                Debug.Assert(service != null);
                Debug.Assert(editSession != null);

                _service = service;
                _editSession = editSession;
                _trackingSpans = new Dictionary<DocumentId, ITrackingSpan[]>();

                editSession.BaseSolution.Workspace.DocumentOpened += DocumentOpened;
                TrackActiveSpans();

                service.OnTrackingSpansChanged(leafChanged: true);
            }