// For testing purposes only.
 internal EditorDocumentManagerListener(EditorDocumentManager documentManager, EventHandler onChangedOnDisk, EventHandler onChangedInEditor, EventHandler onOpened, EventHandler onClosed)
 {
     _documentManager   = documentManager;
     _onChangedOnDisk   = onChangedOnDisk;
     _onChangedInEditor = onChangedInEditor;
     _onOpened          = onOpened;
     _onClosed          = onClosed;
 }
Ejemplo n.º 2
0
        public override void Initialize(ProjectSnapshotManagerBase projectManager)
        {
            if (projectManager == null)
            {
                throw new ArgumentNullException(nameof(projectManager));
            }

            _projectManager  = projectManager;
            _documentManager = projectManager.Workspace.Services.GetRequiredService <EditorDocumentManager>();

            _projectManager.Changed += ProjectManager_Changed;
        }
Ejemplo n.º 3
0
 // For testing purposes only.
 internal EditorDocumentManagerListener(
     ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
     JoinableTaskContext joinableTaskContext,
     EditorDocumentManager documentManager,
     EventHandler onChangedOnDisk,
     EventHandler onChangedInEditor,
     EventHandler onOpened,
     EventHandler onClosed)
 {
     _projectSnapshotManagerDispatcher = projectSnapshotManagerDispatcher;
     _joinableTaskContext = joinableTaskContext;
     _documentManager     = documentManager;
     _onChangedOnDisk     = onChangedOnDisk;
     _onChangedInEditor   = onChangedInEditor;
     _onOpened            = onOpened;
     _onClosed            = onClosed;
 }
Ejemplo n.º 4
0
        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;
            }
        }