public void ProcessOpen(ITextBuffer textBuffer) { if (textBuffer == null) { throw new ArgumentNullException(nameof(textBuffer)); } _fileTracker.StopListening(); _snapshotTracker.StartTracking(textBuffer); EditorTextBuffer = textBuffer; EditorTextContainer = textBuffer.AsTextContainer(); EditorTextContainer.TextChanged += TextContainer_Changed; _opened?.Invoke(this, EventArgs.Empty); }
public void ProcessOpen(ITextBuffer textBuffer) { if (textBuffer == null) { throw new ArgumentNullException(nameof(textBuffer)); } _ = _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync( () => _fileTracker.StopListening(), CancellationToken.None).ConfigureAwait(false); _snapshotTracker.StartTracking(textBuffer); EditorTextBuffer = textBuffer; EditorTextContainer = textBuffer.AsTextContainer(); EditorTextContainer.TextChanged += TextContainer_Changed; _opened?.Invoke(this, EventArgs.Empty); }
public EditorDocument( EditorDocumentManager documentManager, string projectFilePath, string documentFilePath, TextLoader textLoader, FileChangeTracker fileTracker, ITextBuffer textBuffer, EventHandler changedOnDisk, EventHandler changedInEditor, EventHandler opened, EventHandler closed) { if (documentManager == null) { throw new ArgumentNullException(nameof(documentManager)); } if (projectFilePath == null) { throw new ArgumentNullException(nameof(projectFilePath)); } if (documentFilePath == null) { throw new ArgumentNullException(nameof(documentFilePath)); } if (textLoader == null) { throw new ArgumentNullException(nameof(textLoader)); } if (fileTracker == null) { throw new ArgumentNullException(nameof(fileTracker)); } _documentManager = documentManager; ProjectFilePath = projectFilePath; DocumentFilePath = documentFilePath; TextLoader = textLoader; _fileTracker = fileTracker; _changedOnDisk = changedOnDisk; _changedInEditor = changedInEditor; _opened = opened; _closed = closed; _snapshotTracker = new SnapshotChangeTracker(); _fileTracker.Changed += ChangeTracker_Changed; // Only one of these should be active at a time. if (textBuffer == null) { _fileTracker.StartListening(); } else { _snapshotTracker.StartTracking(textBuffer); EditorTextBuffer = textBuffer; EditorTextContainer = textBuffer.AsTextContainer(); EditorTextContainer.TextChanged += TextContainer_Changed; } }
public EditorDocument( EditorDocumentManager documentManager, ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher, JoinableTaskContext joinableTaskContext, string projectFilePath, string documentFilePath, TextLoader textLoader, FileChangeTracker fileTracker, ITextBuffer textBuffer, EventHandler changedOnDisk, EventHandler changedInEditor, EventHandler opened, EventHandler closed) { if (documentManager is null) { throw new ArgumentNullException(nameof(documentManager)); } if (projectSnapshotManagerDispatcher is null) { throw new ArgumentNullException(nameof(projectSnapshotManagerDispatcher)); } if (joinableTaskContext is null) { throw new ArgumentNullException(nameof(joinableTaskContext)); } if (projectFilePath is null) { throw new ArgumentNullException(nameof(projectFilePath)); } if (documentFilePath is null) { throw new ArgumentNullException(nameof(documentFilePath)); } if (textLoader is null) { throw new ArgumentNullException(nameof(textLoader)); } if (fileTracker is null) { throw new ArgumentNullException(nameof(fileTracker)); } _documentManager = documentManager; _projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher; _joinableTaskContext = joinableTaskContext; ProjectFilePath = projectFilePath; DocumentFilePath = documentFilePath; TextLoader = textLoader; _fileTracker = fileTracker; _changedOnDisk = changedOnDisk; _changedInEditor = changedInEditor; _opened = opened; _closed = closed; _snapshotTracker = new SnapshotChangeTracker(); _fileTracker.Changed += ChangeTracker_Changed; // Only one of these should be active at a time. if (textBuffer == null) { _ = _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync( () => _fileTracker.StartListening(), CancellationToken.None).ConfigureAwait(false); } else { _snapshotTracker.StartTracking(textBuffer); EditorTextBuffer = textBuffer; EditorTextContainer = textBuffer.AsTextContainer(); EditorTextContainer.TextChanged += TextContainer_Changed; } }